Thread: [PyOpenGL-Users] Vertex Buffer Objects
Brought to you by:
mcfletch
From: J. A. <ja...@ca...> - 2007-03-07 23:39:42
|
I've been fiddling around trying to get the Nehe example code for lesson 45 working with PyOpenGl 3.xxx, however I can't seem to work out how to get it to work - I keep getting memory read errors. Has anybody managed to get VBOs working? Any pointers? Example code? Thanks, Jeremy Appleyard |
From: Steven W. <st...@li...> - 2008-11-07 01:41:19
|
I need some advice with creating VBOs in PyOpenGL. I was writing a demo app to use a template for a student assignment and ironically I can not seem to create one myself. I've included some excerpts from the demo application and the top of the call stack from the crash log. I am working under the assumption that I just do not know how to pass memory address properly in python. Any advice would be appreciated. Test System is a MacBook Pro ATI graphics card. VertexBuffer = GL.GLuint(0) IndexBuffer = GL.GLuint(0) def initBuffer global VertexBuffer,IndexBuffer VertexBuffer = glGenBuffersARB(1) IndexBuffer = glGenBuffersARB(1) def DrawGLScene(): """ Main drawing function """ # Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity() # Reset The View glTranslatef( 0.0, 0.0, -25.0) # Move out a bit to see everything. global VertexBuffer,IndexData glColor3f(1,1,1) glDisable(GL_TEXTURE_2D) glDisable(GL_LIGHTING) glColor3f(1,1,1) glBegin(GL_QUADS) # Create a White Polygon glVertex3d(-25,-10,-25); glVertex3d( 25,-10,-25); glVertex3d( 25,-10, 25); glVertex3d(-25,-10, 25); glEnd() glColor3f(1,0,0) indexData=array([0,1,2,3], dtype=int)#Load The VBO With the same polygon just a little higher vertexCoordData=array([-25, -8, -25, 25, -8, -25, 25, -8, 25, -25, -8, 25],dtype=float) glEnableClientState(GL_VERTEX_ARRAY) glBindBufferARB(GL_ARRAY_BUFFER_ARB, VertexBuffer); glBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexCoordData, GL_STREAM_DRAW); glVertexPointer(3,GL_FLOAT,0,None); glEnableClientState(GL_VERTEX_ARRAY) glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, IndexBuffer); glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER, indexData, GL_STREAM_DRAW); glIndexPointer(GL_INT,0,None); glDrawElements( GL_QUADS,12, GL_UNSIGNED_INT,indexData); glDisableClientState(GL_VERTEX_ARRAY); glEnable(GL_TEXTURE_2D) glEnable(GL_LIGHTING) # since this is double buffered, swap the buffers to display what just got # drawn. glutSwapBuffers() Crash Log Thread 0 Crashed: 0 libSystem.B.dylib 0xffff07c2 __memcpy + 34 1 ...pple.ATIRadeonX1000GLDriver 0x131d7ee1 gldAllocVertexBuffer + 27809 2 GLEngine 0x130b54ee gleDrawArraysOrElements_VBO_Exec + 1950 3 libGL.dylib 0x93302aa4 glDrawElements + 52 4 _ctypes.so 0x00abb41d .LCFI1 + 23 (darwin.S:84) 5 _ctypes.so 0x00abb3be ffi_call + 98 (ffi_darwin.c:265) 6 _ctypes.so 0x00ab5e98 _CallProc + 355 (callproc.c:679) ...... |
From: JoN <jo...@we...> - 2007-03-09 01:24:01
|
Under Linux. Ok this is really strictly a python question, but its in an opengl context (sic), so I thought I'd start here. I'll find some python lists to ask as well. I have an environment under design that drives pyopengl but there is a lot of threaded stuff going on using python threads. Part of it is a 3d editor (yes yes I know there are good ones already, its just the data model this one uses is for solid rendering and i need some custom code). Now ideally whilst building the editor I'd be able to run IDLE in one X window and have the GL output in another X window (albeit via MESA, but thats good enough for debugging). Question is, can I safely launch threads from inside IDLE? That's it, that's my Q! Jon -------------------------------------------------------------------- Come and visit Web Prophets Website at http://www.webprophets.net.au |
From: JoN <jo...@we...> - 2007-03-13 01:12:42
|
And then he realizes he's asked the completely wrong question. What I meant to ask was: Can IDLE - or any python command interpreter for that matter? - be run itself as a pythread ? I have a threaded environment. It would be really nice if I could pretend to be just another thread and do my locking and unlocking etc as that thread, in the course of development. (Of course not all modules in python are pythread-safe, but I've factored that in as the threaded environment I'm using makes almost no standard module calls, and the rest I can deal with case-by-case). Jon Quoting JoN <jo...@we...>: > > Under Linux. > > Ok this is really strictly a python question, but its in an opengl context > (sic), so I thought I'd start here. I'll find some python lists to ask as > well. > > I have an environment under design that drives pyopengl but there is a lot > of > threaded stuff going on using python threads. Part of it is a 3d editor > (yes > yes I know there are good ones already, its just the data model this one uses > is > for solid rendering and i need some custom code). > > Now ideally whilst building the editor I'd be able to run IDLE in one X > window > and have the GL output in another X window (albeit via MESA, but thats good > enough for debugging). > > Question is, can I safely launch threads from inside IDLE? > > That's it, that's my Q! > > Jon > > > > > > > -------------------------------------------------------------------- > Come and visit Web Prophets Website at http://www.webprophets.net.au > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > -------------------------------------------------------------------- Come and visit Web Prophets Website at http://www.webprophets.net.au |
From: JoN <jo...@we...> - 2007-03-13 02:56:35
|
Actually the 'cmd' module seems to fit the bill. Anybody had experience running it as a thread? http://docs.python.org/lib/module-cmd.html Jon Quoting JoN <jo...@we...>: > > And then he realizes he's asked the completely wrong question. > > What I meant to ask was: > > Can IDLE - or any python command interpreter for that matter? - be run itself > as > a pythread ? > > I have a threaded environment. It would be really nice if I could pretend to > be > just another thread and do my locking and unlocking etc as that thread, in > the > course of development. > > (Of course not all modules in python are pythread-safe, but I've factored > that > in as the threaded environment I'm using makes almost no standard module > calls, > and the rest I can deal with case-by-case). > > Jon > > > Quoting JoN <jo...@we...>: > > > > > Under Linux. > > > > Ok this is really strictly a python question, but its in an opengl context > > (sic), so I thought I'd start here. I'll find some python lists to ask as > > well. > > > > I have an environment under design that drives pyopengl but there is a lot > > of > > threaded stuff going on using python threads. Part of it is a 3d editor > > (yes > > yes I know there are good ones already, its just the data model this one > uses > > is > > for solid rendering and i need some custom code). > > > > Now ideally whilst building the editor I'd be able to run IDLE in one X > > window > > and have the GL output in another X window (albeit via MESA, but thats > good > > enough for debugging). > > > > Question is, can I safely launch threads from inside IDLE? > > > > That's it, that's my Q! > > > > Jon > > > > > > > > > > > > > > -------------------------------------------------------------------- > > Come and visit Web Prophets Website at http://www.webprophets.net.au > > > > > > ------------------------------------------------------------------------- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > > opinions on IT & business topics through brief surveys-and earn cash > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > > PyOpenGL Homepage > > http://pyopengl.sourceforge.net > > _______________________________________________ > > PyOpenGL-Users mailing list > > PyO...@li... > > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > > > > > > -------------------------------------------------------------------- > Come and visit Web Prophets Website at http://www.webprophets.net.au > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > -------------------------------------------------------------------- Come and visit Web Prophets Website at http://www.webprophets.net.au |
From: Mike C. F. <mcf...@vr...> - 2007-03-13 04:37:28
|
JoN wrote: > And then he realizes he's asked the completely wrong question. > > What I meant to ask was: > > Can IDLE - or any python command interpreter for that matter? - be run itself as > a pythread ? > There have been systems that used Idle connected up to a GUI with PyOpenGL running in it. I seem to recall systems with IPython and a Tk OpenGL GUI as well. I haven't done it myself, nor do I know if they actually used threads. Normally what happens is that you need to arrange to have two event loops running. Some GUIs (wxPython, for instance) can handle that using threads as long as you make sure that your first import of wxPython is in the secondary thread (IIRC). Running an interpreter thread using cmd should allow you to run that in a background thread and let the GUI use the main thread AFAICS. I code my own systems using something like the wxPython shell widget hooked up to a wxPython GUI, so the system all runs in the same thread, but that has its own challenges when you want a user to code (e.g. they want to time.sleep() in a script). HTH, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: JoN <jo...@we...> - 2007-03-09 01:25:58
|
By the way, has the traffic on this list dropped dramatically or are my mail filter rules up the duff? I seem to only have 21 messages stored since 12 feb 2007. Jon -------------------------------------------------------------------- Come and visit Web Prophets Website at http://www.webprophets.net.au |
From: Shane H. <sha...@ie...> - 2007-03-13 06:09:29
|
ipython is certainly doing this. I saw the demo at PyCon, and have been using it to great effect in debugging and interacting with my wx app. > ipython -wthread Works for wxPython guis. --help gives more options and a bit more insight into it. I'd have a look at what they did to see if it will work for you as is, or for your own cmd-based interactive app. -Shane On Mar 12, 2007, at 10:37 PM, Mike C. Fletcher wrote: > JoN wrote: >> And then he realizes he's asked the completely wrong question. >> >> What I meant to ask was: >> >> Can IDLE - or any python command interpreter for that matter? - be >> run itself as >> a pythread ? >> > There have been systems that used Idle connected up to a GUI with > PyOpenGL running in it. I seem to recall systems with IPython and > a Tk > OpenGL GUI as well. I haven't done it myself, nor do I know if they > actually used threads. Normally what happens is that you need to > arrange to have two event loops running. Some GUIs (wxPython, for > instance) can handle that using threads as long as you make sure that > your first import of wxPython is in the secondary thread (IIRC). > Running an interpreter thread using cmd should allow you to run > that in > a background thread and let the GUI use the main thread AFAICS. > > I code my own systems using something like the wxPython shell widget > hooked up to a wxPython GUI, so the system all runs in the same > thread, > but that has its own challenges when you want a user to code (e.g. > they > want to time.sleep() in a script). > > HTH, > Mike |
From: JoN <jo...@we...> - 2007-03-14 01:45:40
|
Much thanks Mike and Shane, I'll look into these. Cheers Jon Quoting Shane Holloway <sha...@ie...>: > ipython is certainly doing this. I saw the demo at PyCon, and have > been using it to great effect in debugging and interacting with my wx > app. > > > ipython -wthread > > Works for wxPython guis. --help gives more options and a bit more > insight into it. I'd have a look at what they did to see if it will > work for you as is, or for your own cmd-based interactive app. > > -Shane > > On Mar 12, 2007, at 10:37 PM, Mike C. Fletcher wrote: > > > JoN wrote: > >> And then he realizes he's asked the completely wrong question. > >> > >> What I meant to ask was: > >> > >> Can IDLE - or any python command interpreter for that matter? - be > >> run itself as > >> a pythread ? > >> > > There have been systems that used Idle connected up to a GUI with > > PyOpenGL running in it. I seem to recall systems with IPython and > > a Tk > > OpenGL GUI as well. I haven't done it myself, nor do I know if they > > actually used threads. Normally what happens is that you need to > > arrange to have two event loops running. Some GUIs (wxPython, for > > instance) can handle that using threads as long as you make sure that > > your first import of wxPython is in the secondary thread (IIRC). > > Running an interpreter thread using cmd should allow you to run > > that in > > a background thread and let the GUI use the main thread AFAICS. > > > > I code my own systems using something like the wxPython shell widget > > hooked up to a wxPython GUI, so the system all runs in the same > > thread, > > but that has its own challenges when you want a user to code (e.g. > > they > > want to time.sleep() in a script). > > > > HTH, > > Mike > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > -------------------------------------------------------------------- Come and visit Web Prophets Website at http://www.webprophets.net.au |