473,385 Members | 1,392 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,385 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 4040
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.