预期 LP_c_float 实例而不是 glVertex3fv 中的元组
expected LP_c_float instance instead of tuple in glVertex3fv
我正在使用 Python、OpenGL 和 Pyglet 渲染 3D 立方体,因此我在元组中定义了 vertices
和 edges
变量
vertices = (
(1, -1, -1),
(1, 1, -1),
(-1, 1, -1),
(-1, -1, -1),
(1, -1, 1),
(1, 1, 1),
(-1, -1, 1),
(-1, 1, 1))
edges = (
(0, 1),
(0, 3),
(0, 4),
(2, 1),
(2, 3),
(2, 7),
(6, 3),
(6, 4),
(6, 7),
(5, 1),
(5, 4),
(5, 7))
之后,我定义了一个函数 def Cube()
,该函数 创建 使用我在上面定义的坐标
这个 3D 立方体
def Cube():
glBegin(GL_LINES)
for edge in edges:
for vertex in edge:
glVertex3fv(vertices[vertex])
glEnd()
所以我创建了一个带有 on_draw()
函数的 window,它调用了 Cube()
函数。
当我 运行 在我的 Linux 终端上使用命令 python3 main.py
这个应用程序时,我得到以下错误
ctypes.ArgumentError: argument 1: : expected LP_c_float instance instead of tuple
所以我猜这段代码的主要错误是行 glVertex3fv(vertices[vertex])
我想知道我需要什么才能正确绘制这个 3D 立方体。
我正在使用 Python、OpenGL 和 Pyglet 渲染 3D 立方体,因此我在元组中定义了 vertices
和 edges
变量
vertices = (
(1, -1, -1),
(1, 1, -1),
(-1, 1, -1),
(-1, -1, -1),
(1, -1, 1),
(1, 1, 1),
(-1, -1, 1),
(-1, 1, 1))
edges = (
(0, 1),
(0, 3),
(0, 4),
(2, 1),
(2, 3),
(2, 7),
(6, 3),
(6, 4),
(6, 7),
(5, 1),
(5, 4),
(5, 7))
之后,我定义了一个函数 def Cube()
,该函数 创建 使用我在上面定义的坐标
def Cube():
glBegin(GL_LINES)
for edge in edges:
for vertex in edge:
glVertex3fv(vertices[vertex])
glEnd()
所以我创建了一个带有 on_draw()
函数的 window,它调用了 Cube()
函数。
当我 运行 在我的 Linux 终端上使用命令 python3 main.py
这个应用程序时,我得到以下错误
ctypes.ArgumentError: argument 1: : expected LP_c_float instance instead of tuple
所以我猜这段代码的主要错误是行 glVertex3fv(vertices[vertex])
我想知道我需要什么才能正确绘制这个 3D 立方体。