Python GUI + OpenGL
cptnwillard at gmail.com
cptnwillard at gmail.com
Mon Mar 5 11:24:33 EST 2007
You don't necessarily need an OpenGL wrapper like PyOpenGL. If you
only use a handful of OpenGL functions, it would be relatively
straight-forward to make your own, using ctypes.
Here is what it would look like:
from ctypes import cdll, windll, c_double, c_float, c_int
GL_POINTS = 0x0000
GL_LINES = 0x0001
GL_LINE_LOOP = 0x0002
GL_LINE_STRIP = 0x0003
GL_TRIANGLES = 0x0004
GL_TRIANGLE_STRIP = 0x0005
GL_TRIANGLE_FAN = 0x0006
GL_QUADS = 0x0007
GL_QUAD_STRIP = 0x0008
GL_POLYGON = 0x0009
gl = windll.LoadLibrary("opengl32")
glEnd = gl.glEnd
glEnd.restype = None
glBegin = gl.glBegin
glBegin.argtypes = [c_int]
glBegin.restype = None
glVertex2f = gl.glVertex2d
glVertex2f.argtypes = [c_double, c_double]
glVertex2f.restype = None
glColor3f = gl.glColor3d
glColor3f.argtypes = [c_double, c_double, c_double]
glColor3f.restype = None
glClear = gl.glClear
glClear.argtypes = [c_int]
glClear.restype = None
glClearColor = gl.glClearColor
glClearColor.argtypes = [c_double, c_double, c_double, c_double]
glClearColor.restype = None
glViewport = gl.glViewport
glViewport.argtypes = [c_int, c_int, c_int, c_int]
glViewport.restype = None
[...etc]
Regards,
Laurent
On Mar 2, 4:17 pm, Achim Domma <d... at procoders.net> wrote:
> Hi,
>
> I'm developing a GUI app in Python/C++ to visualize numerical results.
> Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there
> are no windows binaries for Python 2.5 for quite some time now.
>
> I need a OpenGL context without restrictions and some settings dialogs.
> Is wx + PyOpenGL the way to go? Or could somebody recommend a better set
> of tools/libs?
>
> regards,
> Achim
More information about the Python-list
mailing list