[PyOpenGL-Users] Problem with glDrawPixels!
Brought to you by:
mcfletch
From: William J. P. <wjp...@un...> - 2002-03-20 22:20:19
|
I am trying to use glDrawPixels, and I have looked at the example on the webpage but I still cannot get this gl call to function properly. I've created a small sample program that should simply use glDrawPixels to turn the canvas red after you click the button labeled 'call glDrawpixels' and then click on the canvas. All I get is some random gray. Does anyone have any idea what I am doing wrong. My code is below. Thanks! -- Jake from OpenGL.GL import * from OpenGL.Tk import * from Tkinter import * def gl_test(o): glClearColor(0.0, 0.0, 1.0, 0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) image=[] i=0 while i<(256*256): image.append(255) image.append(0) image.append(0) i=i+1 glPixelStorei(GL_PACK_ALIGNMENT, 1) glPixelStorei(GL_UNPACK_ALIGNMENT, 1) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluOrtho2D(0.0, 1.0, 0.0, 1.0) glViewport(0.0, 0.0, 256.0, 256.0) glMatrixMode(GL_MODELVIEW) glPushMatrix() glLoadIdentity() glDrawPixels(256, 256, GL_RGB, GL_UNSIGNED_BYTE, image) glFlush() glPopMatrix() print 'in gl_test..' def new_redraw(o): o.redraw=gl_test print 'in new_redraw' def redraw(o): glClearColor(0.0, 0.0, 0.0, 0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) print 'in redraw' widget = Frame() widget.pack() l=Label(widget, text='glDrawpixels test') l.pack(side=TOP) canvas=Opengl(widget, width=256, height=256, double=1) canvas.redraw=redraw canvas.pack(side=TOP) b=Button(widget, text='Call glDrawpixels', command=(lambda: new_redraw(canvas))) b.pack(side=TOP) widget.mainloop() |