How do i use the function glDrawnPixels in pyopengl?
Solution 1:
You can use OpenGL/PyOpenGL in a tkinter frame with pyopengltk. An example can be found here: tkinter_opengl_shader_ctypes_glm_meshes.py.glDrawPixels
is deprecated, do not use it. Render primitives instead. See Primitive.
Anyway you need to set the color date in the buffer (as suggested in a comment). e.g:
buffer = bytearray(800 * 600 * 3)
display = (1280, 750)
buffer_data = [255, 128, 0] * (display[0] * display[1])
buffer = (GLubyte * (display[0] * display[1] * 3))(*buffer_data)
glDrawPixels(display[1], display[0], GL_RGB, GL_UNSIGNED_BYTE, buffer)
glDrawPixels(display[0], display[1], GL_RGB, GL_UNSIGNED_BYTE, buffer)
However, if you just want to set the clear color for the display, use glClearColor
:
glClearColor(1, 0.5, 0, 1)
glClear(GL_COLOR_BUFFER_BIT)
The color can be read back from the framebuffer with glReadPixels
:
color = glReadPixels(0, 0, display[0], display[1], GL_RGB, GL_UNSIGNED_BYTE, outputType='raw')