Simple PyOpenGL Shader
Hi,
I'm looking for a very simple shader tutorial in PyOpenGL (not PyGlet) that works.
I found some tutorials online, but they didn't work. This one, for example, which looks good: http://www.pygame.org/wiki/GLSLExample?parent=CookBook doesn't run--it crashes at 'glCreateShader = gl.glCreateShader' with 'AttributeError: function 'glCreateShader' not found'. I kept at it, but eventually ran into problems with glShaderSource(), which doesn't like anything I feed it.
That PyOpenGL tutorial is outdated by nearly two years--I need some working examples.
Thanks,
Ian
The sample works just fine for me (under linux). The problem must be somewhere else. Are you sure your gpu supports glsl? Have you tried installing the latest driver?
glCreateShader is available only if the GL version is 2.0 or greater.
You can get the GL version using glGetString(GL_VERSION).
[Edited by - Kambiz on September 20, 2008 1:28:41 AM]
glCreateShader is available only if the GL version is 2.0 or greater.
You can get the GL version using glGetString(GL_VERSION).
[Edited by - Kambiz on September 20, 2008 1:28:41 AM]
Quote:The sample works just fine for me (under linux). The problem must be somewhere else. Are you sure your gpu supports glsl?No, but I bought my computer after that demo was made and it was middle-end tech-wise.
Quote:Have you tried installing the latest driver?I tried and I think I have it, but it still doesn't work.
Quote:glCreateShader is available only if the GL version is 2.0 or greater.>>> from OpenGL.GL import *
You can get the GL version using glGetString(GL_VERSION).
>>> print glGetString(GL_VERSION)
None
>>>
Quote:Original post by Geometrian
>>> from OpenGL.GL import *
>>> print glGetString(GL_VERSION)
None
>>>
Most of the opengl functions including glGetString(GL_VERSION) work only after opengl context creation. This means you have to call it after pygame.display.set_mode(...).
import pygamefrom pygame.locals import * from OpenGL.GL import *from OpenGL.GLUT import * if __name__ == '__main__': glutInit(sys.argv) width, height = 640, 480 pygame.init() pygame.display.set_mode((width, height), OPENGL | DOUBLEBUF) print glGetString(GL_VERSION)
Ah, thank you.
>>> import pygame
>>> from pygame.locals import *
>>> from OpenGL.GL import *
>>> from OpenGL.GLUT import *
>>> glutInit()
['foo']
>>> width, height = 640, 480
>>> pygame.init()
(6, 0)
>>> pygame.display.set_mode((width, height), OPENGL | DOUBLEBUF)
<Surface(640x480x32 SW)>
>>> print glGetString(GL_VERSION)
2.1.0
>>>
>>> import pygame
>>> from pygame.locals import *
>>> from OpenGL.GL import *
>>> from OpenGL.GLUT import *
>>> glutInit()
['foo']
>>> width, height = 640, 480
>>> pygame.init()
(6, 0)
>>> pygame.display.set_mode((width, height), OPENGL | DOUBLEBUF)
<Surface(640x480x32 SW)>
>>> print glGetString(GL_VERSION)
2.1.0
>>>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement