Re: [PyOpenGL-Users] problems with glMap1f in pyopengl2
Brought to you by:
mcfletch
From: Ralph G. <ral...@em...> - 2004-03-12 15:52:22
|
I am happy that you are there right now. This might save my weekend! (-; Anyway, I just hacked together an impressive example script. One for the old version which works fine and one for the new version. I hope I didn't make any stupid mistakes. PyGL 1.5.7: #!/usr/bin/env python import string, sys from OpenGL.GL import * from OpenGL.GLUT import * def display(*args): glClearColor(0.0, 0.0, 0.0, 0.0) glClear(GL_COLOR_BUFFER_BIT) glColor3f(1.0,1.0,1.0) glLineWidth(4.0) curve=[0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0] glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, curve) glEnable(GL_MAP1_VERTEX_3) glBegin(GL_LINE_STRIP) for i in range(0,30,1): glEvalCoord1f(i/30.0) glEnd() glDisable(GL_MAP1_VERTEX_3) glFlush() def setup_viewport(): glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(-1.0, 2.0, -1.0, 2.0, -1.0, 2.0) def reshape(w, h): glViewport(0, 0, w, h) setup_viewport() def main(): glutInit('foo') glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB) glutInitWindowSize(300, 300) glutCreateWindow('Test') setup_viewport() glutSetReshapeFuncCallback(reshape) glutReshapeFunc() glutSetDisplayFuncCallback(display) glutDisplayFunc() # glutSetIdleFuncCallback(display) # glutIdleFunc() glutMainLoop() main() PyGL 2.0.1.07: #!/usr/bin/env python import string, sys from OpenGL.GL import * from OpenGL.GLUT import * def display(*args): glClearColor(0.0, 0.0, 0.0, 0.0) glClear(GL_COLOR_BUFFER_BIT) glColor3f(1.0,1.0,1.0) glLineWidth(4.0) curve=[[0.0,0.0,0.0],[0.0,1.0,0.0],[0.0,1.0,0.0],[1.0,1.0,0.0]] glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, curve) glEnable(GL_MAP1_VERTEX_3) glBegin(GL_LINE_STRIP) for i in range(0,30,1): glEvalCoord1f(i/30.0) glEnd() glDisable(GL_MAP1_VERTEX_3) glFlush() def setup_viewport(): glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(-1.0, 2.0, -1.0, 2.0, -1.0, 2.0) def reshape(w, h): glViewport(0, 0, w, h) setup_viewport() def main(): glutInit(sys.argv) glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB) glutInitWindowSize(300, 300) glutCreateWindow('Test') setup_viewport() glutReshapeFunc(reshape) glutDisplayFunc(display) glutMainLoop() main() |