Re: [pygame] Shaders and Examples not Working
Looks like you need to make a call to glutInit() at the start of InitGL. Won't run here without it. -FM On Thu, Oct 23, 2008 at 5:31 PM, Ian Mallett [EMAIL PROTECTED] wrote: I've condensed it down and ported it to pygame. http://www.geometrian.com/Programs/Tutorials/pygameshaders.zip Ian
Re: [pygame] Shaders and Examples not Working
Hi, yes, I noticed that for some reason my computer doesn't require this, but nearly everyone I've talked to seems to need it. Is there a reason why glutInit() is required on some computers and not on others? Ian
Re: [pygame] Shaders and Examples not Working
Ian Mallett wrote: Hi, yes, I noticed that for some reason my computer doesn't require this, but nearly everyone I've talked to seems to need it. Is there a reason why glutInit() is required on some computers and not on others? Ian GLUT has some book-keeping stuff that it needs initialized, and IIRC it needs some help with shutting down that we set up in glutInit. Basically if you are calling *any* glut function you need to have glutInit called to be sure it will work. HTH, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com
Re: [pygame] Shaders and Examples not Working
Ian Mallett wrote: Hi, I get (adding the necessary import ctypes at the top): AttributeError: function 'glCreateShader' not found Thanks, Ian You'll likely need to use the extension-based version (ARB.shader_objects). If you have a modern Nvidia/ATI card it will almost certainly have shader support available in an extension. Note that some older cards (e.g. integrated graphics chips) only support the lower-level APIs (i.e. you can't use GLSL with them). BTW just tested this demo, it works fine with PyOpenGL bzr head (on Linux, with a reasonable Nvidia card): http://bazaar.launchpad.net/~mcfletch/pyopengl-demo/trunk/annotate/2?file_id=shader_test.py-20080923005140-67c17kywpwxa2usj-25 HTH, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com
Re: [pygame] Shaders and Examples not Working
On Thu, Oct 23, 2008 at 12:03 PM, Mike C. Fletcher [EMAIL PROTECTED]wrote: Ian Mallett wrote: Hi, I get (adding the necessary import ctypes at the top): AttributeError: function 'glCreateShader' not found Thanks, Ian You'll likely need to use the extension-based version (ARB.shader_objects). If you have a modern Nvidia/ATI card it will almost certainly have shader support available in an extension. Note that some older cards (e.g. integrated graphics chips) only support the lower-level APIs (i.e. you can't use GLSL with them). BTW just tested this demo, it works fine with PyOpenGL bzr head (on Linux, with a reasonable Nvidia card): http://bazaar.launchpad.net/~mcfletch/pyopengl-demo/trunk/annotate/2?file_id=shader_test.py-20080923005140-67c17kywpwxa2usj-25 HTH, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com just FYI, it works also in windows ( win xp sp3 ), pyOpenGL-3.0.0b6, nvidia geforce 6600. -- claxo
Re: [pygame] Shaders and Examples not Working
YAY! Thank you all so much! that works! PyOpenGL 3.0.0b6, nVidia Go 7600 Ian
Re: [pygame] Shaders and Examples not Working
I've condensed it down and ported it to pygame. http://www.geometrian.com/Programs/Tutorials/pygameshaders.zip Ian
Re: [pygame] Shaders and Examples not Working
Ian Mallett wrote: Perhaps I'm doing something wrong--I get another error when using the OpenGLContext example: File C:\dev\Python25\Lib\site-packages\OpenGLContext\arrays.py, line 2, in module from vrml.arrays import * ImportError: No module named vrml.arrays My intention was be to suggest you just look at the code for the sample. OpenGLContext's setup requires rather a lot of dependencies. I have making installing those dependencies easier on my list of things to do, but little time to address that list. Good luck, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com
Re: [pygame] Shaders and Examples not Working
Hi Ian, Ian Mallett wrote: On 10/20/08, Greg Ewing [EMAIL PROTECTED] wrote: How exactly do they fail? Do you get an exception? Well, they certainly don't run right out of the box. The ARB example seems more complete, but it whines about the ARB extensions--how it can't find them for some reason. Probably because the proper import statements aren't there (I don't know them, and they weren't included). Changing them to non-ARB functions fixes this problem, but then a host of other problems crops up involving the arguments to certain calls (specifics if requested). Nothing I tried seems to appease them. Here, try this. In the GLSLExample replace all the: try: # For OpenGL-ctypes from OpenGL import platform gl = platform.OpenGL except ImportError: . with: gl = ctypes.windll.opengl32 The example expects the pure Python OpenGL 3.0. If it doesn't find it it falls back on a bunch of Unix specific searches. Windows os functions use the standard calling convention, which differs from C. -- Lenard Lindstrom [EMAIL PROTECTED]
Re: [pygame] Shaders and Examples not Working
Hi, I get (adding the necessary import ctypes at the top): AttributeError: function 'glCreateShader' not found Thanks, Ian
Re: [pygame] Shaders and Examples not Working
On Tue, Oct 21, 2008 at 10:15 PM, Ian Mallett [EMAIL PROTECTED] wrote: Hi, On Tue, Oct 21, 2008 at 12:28 PM, claudio canepa [EMAIL PROTECTED]wrote: Searching the pygame site with 'shaders + opengl' got many hits. Can you point to the specif script(s) in trouble ? I was referring to these tutorials: http://www.pygame.org/wiki/GLSLExample?parent=CookBook http://www.pygame.org/wiki/GLSL_ARB_Example?parent=GLSLExample Which when modified give me this error: ValueError: glShaderSource requires 2 arguments (shaderObj, string), received 4: (2L, 1, cparam 'P' (046cc5f8), cparam 'P' (046cc4b8)) I got away with this, only to get a: (1) : error C: syntax error, unexpected '(' at token ( (1) : error C0501: type name expected at token ( ValueError: Shader compilation failed Esentially, instehad to try to bind directly with ctypes I used the ~new modules OpenGL.GL.ARB.shader_objects and OpenGL.GL.ARB.vertex_shader. If you want to look at the code (the cookbook modified one), I pasted at http://python.pastebin.com/m209c67af The problem is that I dont know enough about pyOpenGL, probably the preparation phase before calls to compile must be done. Using grep / find in files for 'shader' over pyglet 1.1.1 I see some promising calls, like: glShaderSourceARB glCompileShaderARB ... Maybe you can look how pyglet calls the shader related code ? Its a pure python library, as you probably knows. -- claxo
Re: [pygame] Shaders and Examples not Working
Ian Mallett wrote: However, neither of the shader examples work for me, even after I made the obvious modifications. How exactly do they fail? Do you get an exception? Does PyGlet use the PyOpenGL port of the outdated OpenGL 2.0? I think pyglet has its own wrappers for OpenGL, and doesn't use PyOpenGL. I can't think of any reason that PyGame in particular should fail to suppport shaders. The only involvement that PyGame has with OpenGL is to provide you with an OpenGL context. After that it's down to the capabilities of the OpenGL wrapper you're using -- PyOpenGL, pyglet or whatever. You might try using PyOpenGL 3.x, which I gather is based on ctypes as well. It might give you access to some newer OpenGL features, if that's what the problem is. -- Greg
Re: [pygame] Shaders and Examples not Working
On 10/20/08, Greg Ewing [EMAIL PROTECTED] wrote: How exactly do they fail? Do you get an exception? Well, they certainly don't run right out of the box. The ARB example seems more complete, but it whines about the ARB extensions--how it can't find them for some reason. Probably because the proper import statements aren't there (I don't know them, and they weren't included). Changing them to non-ARB functions fixes this problem, but then a host of other problems crops up involving the arguments to certain calls (specifics if requested). Nothing I tried seems to appease them. The not-ARB example comes in two files--the latter needing the addition of various statements to load the required modules. The end result looks somewhat like the modified ARB code, but in two files, and it doesn't work either. At some point, when the code just appears to have so many errors (I believe in this case due to PyOpenGL's progress, not to author incompetancy), I think it may be best just to start over with some new code. There has to be some working shader code that works with the current (or nearly current) version of PyOpenGL somewhere. I think pyglet has its own wrappers for OpenGL, and doesn't use PyOpenGL. I see. I can't think of any reason that PyGame in particular should fail to suppport shaders. The only involvement that PyGame has with OpenGL is to provide you with an OpenGL context. After that it's down to the capabilities of the OpenGL wrapper you're using -- PyOpenGL, pyglet or whatever. OK, but I'd be very suprised if PyOpenGL didn't support shaders. You might try using PyOpenGL 3.x, which I gather is based on ctypes as well. It might give you access to some newer OpenGL features, if that's what the problem is. I have PyOpenGL 3.0.0.b2 or something. I notice it goes up to b6. I'll upgrade when I get home just for kicks. Ian
Re: [pygame] Shaders and Examples not Working
On Mon, Oct 20, 2008 at 11:42 PM, Ian Mallett [EMAIL PROTECTED] wrote: Hi, I've been doing lots of cool stuff with PyOpenGL, but frankly, with cooler effects comes more complexity, and when things get more complex [...] The solution, I've gathered from day 1, is to use shaders, which are programs run on the GPU. They're faster, simpler to use, more powerful and flexible, and all-around just cool. That's great and everything, but shaders, simplifying and inherently simple though they are, seem immune to implementation in PyGame, by which I mean, no one seems to know how to do it. Which brings me to my point, or rather my exception. There *are*shader examples on our very own pygame.org http://www.pygame.org/wiki/GLSLExample?parent=CookBook. However, neither of the shader examples work for me, even after I made the obvious modifications. Ian Searching the pygame site with 'shaders + opengl' got many hits. Can you point to the specif script(s) in trouble ? -- claxo
Re: [pygame] Shaders and Examples not Working
Hi, at one point they did work... However pyopengl 3 is still in beta and has been changing a lot recently... causing some things to fail. There's been a recent fix in cvs to get them working on windows again (I think your platform). I know that recently a bunch of shader examples were added to cvs too. So... use pyopengl cvs, and help out with bug reports and patches :) Mike is pretty responsive over there, but if you have any patches I can apply them as well if you need. cheers, On Tue, Oct 21, 2008 at 1:42 PM, Ian Mallett [EMAIL PROTECTED] wrote: Hi, I've been doing lots of cool stuff with PyOpenGL, but frankly, with cooler effects comes more complexity, and when things get more complex, PyOpenGL fixed function techniques do not seem to be the answer. A dynamically rendered cubic reflectionmapped object is complicated enough. So is a dynamically updated framebuffer shadowmapped object. I just barely got these working, and they aren't simple to implement at all. Try putting the two together? How would you add real-time refraction? Caustics? Some of these fixed function effects aren't exact either, and some are slow. The solution, I've gathered from day 1, is to use shaders, which are programs run on the GPU. They're faster, simpler to use, more powerful and flexible, and all-around just cool. That's great and everything, but shaders, simplifying and inherently simple though they are, seem immune to implementation in PyGame, by which I mean, no one seems to know how to do it. Which brings me to my point, or rather my exception. There are shader examples on our very own pygame.org. However, neither of the shader examples work for me, even after I made the obvious modifications. The obvious observations were made: -These apparently worked as recently as OpenGL 2.0, which is recent, but not amazingly so. -My computer does support shaders, so it's not a hardware issue--It was bought after these tutorials were written, and it was middle-range at that time. Further, PyGlet shader programs, and commercial programs seem to work just dapper. -Aside from these tutorials, no other shader examples in PyGame and PyOpenGL could be had anywhere on the net. -PyGlet supports shaders, but PyGame doesn't? Seems improbable, as shaders are PyOpenGL stuff. Does PyGlet use the PyOpenGL port of the outdated OpenGL 2.0? If so, why did the PyOpenGL people depreciate what they call the future of graphics in a newer release? OpenGL 2.1 sure doesn't. So, does anyone know how to make a shader program? They should be really simple judging by the complexity of the broken examples and what I already know on the topic. Perhaps someone who knows a bit more PyOpenGL and/or is more familiar with Python and/or PyGame than I do could write a new tutorial? I'm really hoping to get somewhere with shaders, but the examples on pygame.org don't work. Please help, thanks, Ian
Re: [pygame] Shaders and Examples not Working
Hi, On Tue, Oct 21, 2008 at 12:28 PM, claudio canepa [EMAIL PROTECTED]wrote: Searching the pygame site with 'shaders + opengl' got many hits. Can you point to the specif script(s) in trouble ? I was referring to these tutorials: http://www.pygame.org/wiki/GLSLExample?parent=CookBook http://www.pygame.org/wiki/GLSL_ARB_Example?parent=GLSLExample Which when modified give me this error: ValueError: glShaderSource requires 2 arguments (shaderObj, string), received 4: (2L, 1, cparam 'P' (046cc5f8), cparam 'P' (046cc4b8)) The google search suggested returns a lot of references to those and to this one, which I hadn't seen, but no others: http://www.pygame.org/project/724/ It crashes too. On Tue, Oct 21, 2008 at 5:58 PM, René Dudfield [EMAIL PROTECTED] wrote: There's been a recent fix in cvs to get them working on windows again (I think your platform). That's great news! I know that recently a bunch of shader examples were added to cvs too. So... use pyopengl cvs, and help out with bug reports and patches :) Mike is pretty responsive over there, but if you have any patches I can apply them as well if you need. This will sound terribly stupid, but I don't know how to install PyOpenGl from cvs. Thanks, Ian
Re: [pygame] Shaders and Examples not Working
hi, it should be: python setup.py install Maybe remove your site-packages one first. cheers, On Wed, Oct 22, 2008 at 12:15 PM, Ian Mallett [EMAIL PROTECTED] wrote: Hi, On Tue, Oct 21, 2008 at 12:28 PM, claudio canepa [EMAIL PROTECTED] wrote: Searching the pygame site with 'shaders + opengl' got many hits. Can you point to the specif script(s) in trouble ? I was referring to these tutorials: http://www.pygame.org/wiki/GLSLExample?parent=CookBook http://www.pygame.org/wiki/GLSL_ARB_Example?parent=GLSLExample Which when modified give me this error: ValueError: glShaderSource requires 2 arguments (shaderObj, string), received 4: (2L, 1, cparam 'P' (046cc5f8), cparam 'P' (046cc4b8)) The google search suggested returns a lot of references to those and to this one, which I hadn't seen, but no others: http://www.pygame.org/project/724/ It crashes too. On Tue, Oct 21, 2008 at 5:58 PM, René Dudfield [EMAIL PROTECTED] wrote: There's been a recent fix in cvs to get them working on windows again (I think your platform). That's great news! I know that recently a bunch of shader examples were added to cvs too. So... use pyopengl cvs, and help out with bug reports and patches :) Mike is pretty responsive over there, but if you have any patches I can apply them as well if you need. This will sound terribly stupid, but I don't know how to install PyOpenGl from cvs. Thanks, Ian
Re: [pygame] Shaders and Examples not Working
Done. Where were the examples you mentioned?
Re: [pygame] Shaders and Examples not Working
René Dudfield wrote: Hi, at one point they did work... However pyopengl 3 is still in beta and has been changing a lot recently... causing some things to fail. There's been a recent fix in cvs to get them working on windows again (I think your platform). Actually, I'm using bzr these days for PyOpenGL. I know that recently a bunch of shader examples were added to cvs too. So... use pyopengl cvs, and help out with bug reports and patches :) Mike is pretty responsive over there, but if you have any patches I can apply them as well if you need. I can't claim to be all that responsive, but I try. There is working code in OpenGLContext/tests/shaderobjects.py which compiles and renders with a comic shader. HTH, Mike -- Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com
Re: [pygame] Shaders and Examples not Working
Perhaps I'm doing something wrong--I get another error when using the OpenGLContext example: File C:\dev\Python25\Lib\site-packages\OpenGLContext\arrays.py, line 2, in module from vrml.arrays import * ImportError: No module named vrml.arrays
[pygame] Shaders and Examples not Working
Hi, I've been doing lots of cool stuff with PyOpenGL, but frankly, with cooler effects comes more complexity, and when things get more complex, PyOpenGL fixed function techniques do not seem to be the answer. A dynamically rendered cubic reflectionmapped object is complicated enough. So is a dynamically updated framebuffer shadowmapped object. I just barely got these working, and they aren't simple to implement at all. Try putting the two together? How would you add real-time refraction? Caustics? Some of these fixed function effects aren't exact either, and some are slow. The solution, I've gathered from day 1, is to use shaders, which are programs run on the GPU. They're faster, simpler to use, more powerful and flexible, and all-around just cool. That's great and everything, but shaders, simplifying and inherently simple though they are, seem immune to implementation in PyGame, by which I mean, no one seems to know how to do it. Which brings me to my point, or rather my exception. There *are*shader examples on our very own pygame.org http://www.pygame.org/wiki/GLSLExample?parent=CookBook. However, neither of the shader examples work for me, even after I made the obvious modifications. The obvious observations were made: -These apparently worked as recently as OpenGL 2.0, which is recent, but not amazingly so. -My computer does support shaders, so it's not a hardware issue--It was bought after these tutorials were written, and it was middle-range at that time. Further, PyGlet shader programs, and commercial programs seem to work just dapper. -Aside from these tutorials, no other shader examples in PyGame and PyOpenGL could be had anywhere on the net. -PyGlet supports shaders, but PyGame doesn't? Seems improbable, as shaders are PyOpenGL stuff. Does PyGlet use the PyOpenGL port of the outdated OpenGL 2.0? If so, why did the PyOpenGL people *depreciate* what they call the future of graphics in a newer release? OpenGL 2.1 sure doesn't. So, does anyone know how to make a shader program? They should be really simple judging by the complexity of the broken examples and what I already know on the topic. Perhaps someone who knows a bit more PyOpenGL and/or is more familiar with Python and/or PyGame than I do could write a new tutorial? I'm really hoping to get somewhere with shaders, but the examples on pygame.org don't work. Please help, thanks, Ian