Python GUI + OpenGL

A

Achim Domma

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
 
D

Diez B. Roggisch

Achim said:
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?

PyQt, but then there is the licensing question of course.

Diez
 
M

Mike C. Fletcher

Achim said:
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
PyOpenGL 3.x (currently in alpha state, but reasonably usable) works on
Python 2.5, there are no binaries because the system no longer requires
binary versions. Install the setuptools package, then run easy_install
PyOpenGL and the egg file should be downloaded and installed to your
machine. The current version doesn't package GLE along with the code,
however, so you'll have to find a DLL for that if you need it.

HTH,
Mike

--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
 
D

Dag

PyQt, but then there is the licensing question of course.

I'm facing a similar problem. Would you care to explain why PyQt is
better in this particular case. I've used both PyQt and wx for 'normal'
GUI programming (but I'm more familiar with wx) so I know about their
difference in general. But why is PyQt better than wx for working with
OpenGL?

Dag
 
C

cptnwillard

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
 
D

Diez B. Roggisch

Dag said:
I'm facing a similar problem. Would you care to explain why PyQt is
better in this particular case. I've used both PyQt and wx for 'normal'
GUI programming (but I'm more familiar with wx) so I know about their
difference in general. But why is PyQt better than wx for working with
OpenGL?

I didn't say so. I just pointed out an alternative, as the OP had issues
with obtaining binary packages for wx + py2.5

Beside that, I do love the Qt library and would always use it in preference
to wx, but this is a general thing and by no means tied to the
OpenGL-programming. After all, that actually is done using PyOpenGL

Diez
 
C

Chris Mellon

I didn't say so. I just pointed out an alternative, as the OP had issues
with obtaining binary packages for wx + py2.5

I believe he was having trouble with binary packages for PyOpenGL,
wxPython has 2.5 binaries and has since it was released.

That said, it's my understanding that the most recent version of
PyOpenGL uses ctypes and no longer requires a windows binary, which is
why they are not provided.

Also, if you're writing a C++/Python app on Windows then you must have
the correct environment to build Python extensions, so even if my
understanding is incorrect, you should be able to build PyOpenGL via
distutils with minimal if any trouble.
Beside that, I do love the Qt library and would always use it in preference
to wx, but this is a general thing and by no means tied to the
OpenGL-programming. After all, that actually is done using PyOpenGL

wx and Qt support OpenGL in essentially the same manner. I believe he
took from your earlier post that Qt had its own built in OpenGL
wrapper (and thus didn't rely on PyOpenGL) but to my knowledge that is
not correct.
 
D

David Boddie

wx and Qt support OpenGL in essentially the same manner. I believe he
took from your earlier post that Qt had its own built in OpenGL
wrapper (and thus didn't rely on PyOpenGL) but to my knowledge that is
not correct.

Yes, you need PyOpenGL (or any other suitable OpenGL wrapper) to use
OpenGL with PyQt. Qt itself doesn't provide its own API for OpenGL; you
just use the implementation available on your system.

It is possible to get OpenGL-rendered 2D graphics without having
PyOpenGL installed; you just paint on a QGLWidget in the usual way.
However, I suspect that the original poster wanted to render 3D
graphics, so Python bindings to the system's OpenGL library are still
required.

David
 
D

Diez B. Roggisch

I didn't say so. I just pointed out an alternative, as the OP had issues
I believe he was having trouble with binary packages for PyOpenGL,
wxPython has 2.5 binaries and has since it was released.


Ah, I didn't read it that way as the OP didn't say exactly _what_ package he
was missing. Obviously if it's PyOpenGL then using Qt won't buy him much...


Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top