On Mar 25, 9:50 pm, Crispin Wellington <[email protected]>
wrote:
> Woops. I keep forgetting to mail the list...
>
> For the specific import replace the PYGLET part of the header with
>
> --------------------------------------------
> if 'PYGLET' in os.environ:
> from pyglet.gl import glMultMatrixf, glClearColor,
> glShadeModel, glTranslated, glClear
> from pyglet.gl import glColor3f, glLoadIdentity, glScalef,
> glVertex3f, glNormal3f
> from pyglet.gl import glBegin, glEnd, glFlush, GLfloat,
> glViewport, glMatrixMode, glFrustum
> from pyglet.gl import GL_TRIANGLES, GL_FLAT,
> GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW
>
> def glmult(l):
> return glMultMatrixf( (GLfloat * len(l))(*l) )
I used the above, and tried delaying the pyglet.gl import in a cleaner
way. (Diff -c with your original example is below.)
This convinces me that my original theory is not what's happening
here. With the pyglet.gl imports deferred until the GL context is
current, there is no behavior difference related to dragging the
window. (Something else I did caused the rendering to not show up
until you resize the window. I can't guess what caused that.)
(FYI I also swapped the args of resizeGL to fix a bug.)
Other speculations: maybe pyglet does something which locks the
window, which it normally undoes somehow when it first shows a window
of its own? Maybe it does something which tells the OS window manager
that this Qt window is not the right one to receive some sort of
events? (I think I better stop speculating and wait for the experts to
weigh in.)
- Bruce
P.S. Here's what I tried, relative to your original example code:
*** crispin_qt-ORIG.py 2009-03-25 20:47:23.000000000 -0700
--- crispin_qt.py 2009-03-25 21:56:53.000000000 -0700
***************
*** 1,29 ****
#!/usr/bin/env python
import sys, math, os
- from PyQt4 import QtGui, QtCore, QtOpenGL
! if 'PYGLET' in os.environ:
! from pyglet.gl import *
def glmult(l):
! return glMultMatrixf( (GLfloat * len(l))(*l) )
! else:
! from OpenGL.GL import *
def glmult(l):
return glMultMatrixf( l )
class GLWidget(QtOpenGL.QGLWidget):
def __init__(self, parent=None):
QtOpenGL.QGLWidget.__init__(self, parent)
def initializeGL(self):
glClearColor(0.0, 0.0, 0.0, 0.0)
glShadeModel(GL_FLAT)
def lookAt(self,ex,ey,ez,cx,cy,cz,ux,uy,uz):
F = [cx-ex, cy-ey, cz-ez]
Fmag = math.sqrt(sum([a*a for a in F]))
fnorm = [a/Fmag for a in F]
--- 1,59 ----
#!/usr/bin/env python
import sys, math, os
! glMultMatrixf, glClearColor, glShadeModel, glTranslated, glClear =
0,0,0,0,0
! glColor3f, glLoadIdentity, glScalef, glVertex3f, glNormal3f =
0,0,0,0,0
! glBegin, glEnd, glFlush, GLfloat, glViewport, glMatrixMode,
glFrustum = 0,0,0,0,0,0,0
! GL_TRIANGLES, GL_FLAT, GL_COLOR_BUFFER_BIT, GL_PROJECTION,
GL_MODELVIEW = 0,0,0,0,0
!
! glmult = 0
!
! def _import_gl():
! global glMultMatrixf, glClearColor, glShadeModel, glTranslated,
glClear
! global glColor3f, glLoadIdentity, glScalef, glVertex3f,
glNormal3f
! global glBegin, glEnd, glFlush, GLfloat, glViewport,
glMatrixMode, glFrustum
! global GL_TRIANGLES, GL_FLAT, GL_COLOR_BUFFER_BIT,
GL_PROJECTION, GL_MODELVIEW
! global glmult
!
! if 'PYGLET' in os.environ:
! ## from pyglet.gl import *
!
! from pyglet.gl import glMultMatrixf, glClearColor,
glShadeModel, glTranslated, glClear
! from pyglet.gl import glColor3f, glLoadIdentity, glScalef,
glVertex3f, glNormal3f
! from pyglet.gl import glBegin, glEnd, glFlush, GLfloat,
glViewport, glMatrixMode, glFrustum
! from pyglet.gl import GL_TRIANGLES, GL_FLAT,
GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW
def glmult(l):
! return glMultMatrixf( (GLfloat * len(l))(*l) )
!
! ## pwin = pyglet.window.Window(resizable=True)
! else:
! ## from OpenGL.GL import *
! from OpenGL.GL import glMultMatrixf, glClearColor,
glShadeModel, glTranslated, glClear
! from OpenGL.GL import glColor3f, glLoadIdentity, glScalef,
glVertex3f, glNormal3f
! from OpenGL.GL import glBegin, glEnd, glFlush, GLfloat,
glViewport, glMatrixMode, glFrustum
! from OpenGL.GL import GL_TRIANGLES, GL_FLAT,
GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW
def glmult(l):
return glMultMatrixf( l )
+
+ from PyQt4 import QtGui, QtCore, QtOpenGL
+
class GLWidget(QtOpenGL.QGLWidget):
def __init__(self, parent=None):
QtOpenGL.QGLWidget.__init__(self, parent)
def initializeGL(self):
+ _import_gl()
+ self.resizeGL(self.width(), self.height()) #
probably not needed
glClearColor(0.0, 0.0, 0.0, 0.0)
glShadeModel(GL_FLAT)
def lookAt(self,ex,ey,ez,cx,cy,cz,ux,uy,uz):
+ _import_gl()
F = [cx-ex, cy-ey, cz-ez]
Fmag = math.sqrt(sum([a*a for a in F]))
fnorm = [a/Fmag for a in F]
***************
*** 44,49 ****
--- 74,80 ----
glTranslated(-ex, -ey, -ez)
def paintGL(self):
+ _import_gl()
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(1.0,1.0,1.0)
***************
*** 58,64 ****
glEnd()
glFlush()
! def resizeGL(self, height, width):
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
--- 89,96 ----
glEnd()
glFlush()
! def resizeGL(self, width, height): # bugfix, swapped args
! _import_gl()
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---