473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Selection, picking with PyOpenGL?

I was interesting in adding selection and hit testing to ZOE, and was
looking at the PyOpenGL wrappers' handling of selection and picking. I
see glSelectBuffer to specify the size of the buffer, and glRenderMode
properly returns the number of hits when put back into GL_RENDER mode,
but I don't see any way within PyOpenGL itself to access the select
buffer to actually process the hits. Is there any way to do this
without using OpenGLContext? (If not, does this make sense, given that
OpenGLContext is supposed to be an additional helper library for a
gentle introduction to OpenGL?)

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
I will always remember / This moment
-- Sade
Jul 30 '05 #1
2 4041
Erik Max Francis wrote:
I was interesting in adding selection and hit testing to ZOE, and was
looking at the PyOpenGL wrappers' handling of selection and picking. I
see glSelectBuffer to specify the size of the buffer, and glRenderMode
properly returns the number of hits when put back into GL_RENDER mode,
but I don't see any way within PyOpenGL itself to access the select
buffer to actually process the hits. Is there any way to do this
without using OpenGLContext? (If not, does this make sense, given that
OpenGLContext is supposed to be an additional helper library for a
gentle introduction to OpenGL?)

I think you're missing what's returned from the glRenderMode code (which
is non-standard OpenGL, to avoid the need for Python code using and
decoding structured pointers), from OpenGLContext:

nameStack = list(glRenderMode(GL_RENDER))

that is, you get a stack of name records (i.e. your glSelectBuffer with
(near,far,names) records) back from the glRenderMode call, *not* just a
count of the records produced.

In general, you shouldn't *need* OpenGLContext to do anything, as all of
its OpenGL code is written directly in Python to PyOpenGL's API (that
was its original purpose in life, to test those APIs). It is, however,
intended to provide a source for sample code showing how to accomplish
effects when using PyOpenGL, so from renderpass.py:

event.setObjectPaths([
nodepath.NodePath(filter(None,[
self.selectable.get(name)
for name in names
]))
for (near,far,names) in nameStack
])

shows you how to deal with the glSelectBuffer result, namely that it's a
near value, a far value, and a set of integer names (the name stack) for
each record in the set. OpenGLContext is here creating a node-path of
all selectable objects from the scenegraph root to the final selected
object using the nameStack and a registered set of name:node values
(self.selectable). It will use those to populate the event objects that
show up in the OpenGLContext mouse-event-handling APIs.

HTH,
Mike

--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com

Jul 30 '05 #2
Mike C. Fletcher wrote:
I think you're missing what's returned from the glRenderMode code (which
is non-standard OpenGL, to avoid the need for Python code using and
decoding structured pointers), from OpenGLContext:


I was indeed. I was looking at the text description, which, like the
OpenGL documentation, talks about it returning the number of hits. I
didn't look carefully enough at the Python return value :-).

Thanks, Mike!

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
I am not a Virginian, but an American.
-- Patrick Henry
Jul 30 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jimmy Johns | last post by:
Hi, why hasn't there a version of pyOpenGL for python 2.3.x yet? Currently the binary installers for windows only work with python 2.2, and will give an when installing for python 2.3. I can't...
5
by: Sébastien Ramage | last post by:
Bonjour à tous, Dans la folie j'ai installé le nouveau python, impatient de voir les nouveautés mais je pense que j'ai été un peu rapide car j'ai voulu utiliser pyOpenGL et là problème il...
1
by: joroy | last post by:
Hi all, I think this is ctypes related but how can I call the glShaderSourceARB function? The function have this header: glShaderSourceARB( GLhandleARB(shaderObj), GLsizei(count),...
0
by: sweetmelon | last post by:
(I'm a newbie in Python and pyOpenGL.) Environment: WinXP SP2 Python ver. 2.5 WingIDE easy_install is installed PIL, pyNum is installed Download PyOpenGL-3.0.0a5-py2.5.egg run: easy_install...
0
by: shirish | last post by:
Hi all, Is it possible to have Python+Pygame+PyOpenGL in one compact package so people can play the games released at pyweek.org . I have been having a hard time getting the whole thing on windows...
2
by: seb.haase | last post by:
Hi, I am distributing a package with a precompiled collection of modules and packages useful for Python based medical/biological/astronomical image analysis and algorithm development. (Codename:...
0
by: Colin J. Williams | last post by:
I have just installed PyOpenGL and get a series of warning messages: Best match: PyOpenGL 3.0.0b3 Downloading...
1
by: Clay Hobbs | last post by:
I need a tutorial for PyOpenGL (specifically, to be used with wxPython). I searched with Google and didn't find one. Does anybody know where one is? -- Ratfink
0
by: kupendra | last post by:
I am using python with Qt from past 1 year.. now i have to use pyqt with opengl. i am tring to write a sample program which can able to draw object ( eg cube,dot) and user can able to select using...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.