GUI development with 3D view

A

Achim Domma

Hi,

I'm looking for quite some time now for a gui library for python,
which allows me to display 3D graphics. Main OS is windows, Mac OS X
and Linux would be nice to have. I want to use python 2.5. My first
try was wx + pyOpenGL but there are no working binaries for python
2.5. I simply have to display some dialogs for data input and a 3D
scene with lots of arrows. No fancy mesh and scene handling is needed.

Is there an alternative to wx+pyOpenGL?

regards,
Achim
 
D

Diez B. Roggisch

Achim said:
Hi,

I'm looking for quite some time now for a gui library for python,
which allows me to display 3D graphics. Main OS is windows, Mac OS X
and Linux would be nice to have. I want to use python 2.5. My first
try was wx + pyOpenGL but there are no working binaries for python
2.5. I simply have to display some dialogs for data input and a 3D
scene with lots of arrows. No fancy mesh and scene handling is needed.

Is there an alternative to wx+pyOpenGL?

The usual suspects - mainly Qt, possibly Tk (not sure if there is a
python-available version of open gl canvasses for Tk)

Diez
 
J

J. Robertson

Diez said:
Achim Domma wrote:
[snip]
Is there an alternative to wx+pyOpenGL?

The usual suspects - mainly Qt, possibly Tk (not sure if there is a
python-available version of open gl canvasses for Tk)

Diez

togl is a Tk/OpenGL widget that can be used with python as well. I
think it is included in PyOpenGL. It is quite easy to use iirc, but
I've got no idea how it works with windows.
 
A

Achim Domma

Hi!


On XP: fine.
On Vista: very difficult...

@+

MCI

Also with Python 2.5? If PyOpenGL would work with Python 2.5, I could
use wx too. But I could not get it to work with 2.5 on windows.

Achim
 
D

Diez B. Roggisch

Achim said:
Also with Python 2.5? If PyOpenGL would work with Python 2.5, I could
use wx too. But I could not get it to work with 2.5 on windows.

I was under the impression that PyOpenGL is ctypes-based in the new
versions?

Diez
 
M

Mike C. Fletcher

Diez B. Roggisch wrote:
....
I was under the impression that PyOpenGL is ctypes-based in the new
versions?
It is, but I haven't had the time to do a new release and check it on a
Windows box. There are minor fixes in CVS that *should* IIRC make us
run better on those Windows machines that have problems with the 3.x
alphas so far.

Tempus fugit,
Mike

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

Méta-MCI \(MVP\)

Re!

On Vista, OpenGL depend of (releases of) video-cards.
Some cards don't support OpenGL => problem!
Some cards have native openGL support => good (dream?)
Some cards need update (drivers)

@-salutations

Michel Claveau
 
S

sturlamolden

I'm looking for quite some time now for a gui library for python,
which allows me to display 3D graphics. Main OS is windows, Mac OS X
and Linux would be nice to have. I want to use python 2.5. My first
try was wx + pyOpenGL but there are no working binaries for python
2.5.

Huh? The latest version of PyOpenGL uses ctypes and has no binaries as
it is implemented in pure Python. Personally I use my own ctypes
wrapper for the few OpenGL routines I need. There is a lot of unwanted
overhead in PyOpenGL.

Also consider calling OpenGL from a Pyrex extension. That may save you
some overhead if you make a lot of calls to the OpenGL library. A
remedy for that may be to use display lists, or combine vertex arrays
or vertex buffers with NumPy arrays.


Excerpts from my OpenGL wrapper:

from ctypes import *
import numpy
from threading import Lock
opengl_lock = Lock()
GL = windll.opengl32
GLU = windll.glu32

GL_PROJECTION = 0x1701
GL_MODELVIEW = 0x1700
GL_DEPTH_TEST = 0x0B71
GL_VERTEX_ARRAY = 0x8074
GL_NORMAL_ARRAY = 0x8075

glBegin = GL.glBegin
glBegin.argtypes = (c_int,)
glBegin.restype = None

glEnd = GL.glEnd
glEnd.argtypes = ()
glEnd.restype = None

glVertex3f = GL.glVertex3f
glVertex3f.argtypes = (c_float, c_float, c_float)
glVertex3f.restype = None

gltypemap = {
GL_BYTE : numpy.ctypeslib.ndpointer(dtype = numpy.int8,
flags='aligned,contiguous'),
GL_UNSIGNED_BYTE : numpy.ctypeslib.ndpointer(dtype = numpy.uint8,
flags='aligned,contiguous'),
GL_SHORT : numpy.ctypeslib.ndpointer(dtype = numpy.int16,
flags='aligned,contiguous'),
GL_UNSIGNED_SHORT : numpy.ctypeslib.ndpointer(dtype =
numpy.uint16, flags='aligned,contiguous'),
GL_INT : numpy.ctypeslib.ndpointer(dtype = numpy.int32,
flags='aligned,contiguous'),
GL_UNSIGNED_INT : numpy.ctypeslib.ndpointer(dtype = numpy.uint32,
flags='aligned,contiguous'),
GL_FLOAT : numpy.ctypeslib.ndpointer(dtype = numpy.float32,
flags='aligned,contiguous'),
GL_DOUBLE : numpy.ctypeslib.ndpointer(dtype = numpy.float64,
flags='aligned,contiguous'),
GL_UNSIGNED_BYTE_3_3_2 : numpy.ctypeslib.ndpointer(dtype =
numpy.uint8, flags='aligned,contiguous')
}

def glVertexPointer(size, gltype, stride, array):
opengl_lock.acquire()
glfun = GL.glVertexPointer
glfun.argtypes = (c_int, c_int, c_int, gltypemap[gltype])
glfun.restype = None
glfun(size, gltype, stride, array)
opengl_lock.release()

def glGenBuffersARB(n):
opengl_lock.acquire()
PFNGLGENBUFFERSARBPROC = WINFUNCTYPE(None, c_uint,
gltypemap[GL_UNSIGNED_INT])
wglGetProcAddress = GL.wglGetProcAddress
wglGetProcAddress.argtypes = (c_char_p,)
wglGetProcAddress.restype = PFNGLGENBUFFERSARBPROC
glfun = wglGetProcAddress('glGenBuffersARB')
buffers = numpy.zeros(n, dtype=numpy.uint32)
glfun(n, buffers)
opengl_lock.release()
return buffers


Interfacing Python with OpenGL is not rocket science.
 
G

gsal

If all you need to do is display a bunch of arrows, as you mention,
the easiest thing to do might be to use Visual Python. It is
extremely easy to use.

gsal
 
G

Glenn Hutchings

If all you need to do is display a bunch of arrows, as you mention,
the easiest thing to do might be to use Visual Python. It is
extremely easy to use.

Another option, if your app is data-driven, is to check out the
Visualization Toolkit (VTK) at http://www.vtk.org. It also has 3D
graphics and a Python interface.

Glenn
 

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,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top