我需要画像素,然后改变它们的大小,所以一个显示像素包含9个程序像素
import random
from pyglet.gl import *
from OpenGL.GLUT import *
win = pyglet.window.Window()
@win.event
def on_draw():
W = 200
H = 200
glClearColor(0, 0, 0, 1)
glClear(GL_COLOR_BUFFER_BIT)
data = [[[0] * 3 for j in range(W)] for i in range(H)]
for y in range (0, H):
for x in range (0, W):
data[y][x][0] = random.randint(0, 255)
data[y][x][1] = random.randint(0, 255)
data[y][x][2] = random.randint(0, 255)
glDrawPixels(W, H, GL_RGB, GL_UNSIGNED_INT, data)
glutSwapBuffers()
pyglet.app.run()
我得到这个错误
glDrawPixels(W, H, GL_RGB, GL_UNSIGNED_INT, data)
ctypes.ArgumentError: argument 5: : wrong type
传递给
glDrawPixels
的数据必须是GLuint
值的数组,而不是嵌套的值列表。如果要通过[0,255]范围内的整数值定义颜色通道,则必须使用数据类型
GLubyte
和相应的OpenGL枚举器常量GL_UNSIGNED_BYTE
,而不是GL_UNSIGNED_INT
。你知道吗例如
如果要分别使用
GLuint
GL_UNSIGNED_INT
,则积分色通道必须在[0,2147483647]范围内:例如
相关问题 更多 >
编程相关推荐