469,142 Members | 1,097 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,142 developers. It's quick & easy.

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 3721
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jimmy Johns | last post: by
5 posts views Thread by Sébastien Ramage | last post: by
1 post views Thread by joroy | last post: by
reply views Thread by sweetmelon | last post: by
reply views Thread by shirish | last post: by
2 posts views Thread by seb.haase | last post: by
reply views Thread by Colin J. Williams | last post: by
1 post views Thread by Clay Hobbs | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.