代码拉出一个没有类型的对象 pyglet
code pulls up an object has no type pyglet
这是我知道出错的代码
self.scale_loc = glGetUniformLocation(shader, b"scale")
self.rotate_loc = glGetUniformLocation(shader, b"rotate")
self.scale = pyrr.Matrix44.identity()
self.rot_y = pyrr.Matrix44.identity()
def rotate(self):
self.scale = pyrr.Matrix44.from_scale(pyrr.Vector3([0.2, 0.2, 1.0])).flatten()
self.rot_y = pyrr.Matrix44.from_y_rotation(time.perf_counter() * 2).flatten
#self.rot_y = [y for x in self.rot_y for y in x]
c_scale = (GLfloat * len(self.scale))(*self.scale)
c_rotate_y = (GLfloat * len(self.rot_y))(*self.rot_y)
glUniformMatrix4fv(self.scale_loc, 1, GL_FALSE, c_scale)
glUniformMatrix4fv(self.rotate_loc, 1, GL_FALSE, c_rotate_y)
错误是
c_rotate_y = (GLfloat * len(self.rot_y))(*self.rot_y)
TypeError: object of type 'builtin_function_or_method' has no len()
我不知道它是过时了还是什么。我正在学习一个 4 年前的教程系列。如果您需要更多信息,请告诉我
Pyrr - Matrices are represented by 2 dimensional NumPy arrays. To convert the NumPy array to a ctypes
you have to flatten
it. The number of elements in the array can be get from the size
属性:
self.scale = pyrr.Matrix44.from_scale(pyrr.Vector3([0.2, 0.2, 1.0])).flatten()
self.rot_y = pyrr.Matrix44.from_y_rotation(time.perf_counter() * 2).flatten()
c_scale = (GLfloat * self.scale.size)(*self.scale)
c_rotate_y = (GLfloat * self.rot_y.size)(*self.rot_y)
glUniformMatrix4fv(self.scale_loc, 1, GL_FALSE, c_scale)
glUniformMatrix4fv(self.rotate_loc, 1, GL_FALSE, c_rotate_y)
这是我知道出错的代码
self.scale_loc = glGetUniformLocation(shader, b"scale")
self.rotate_loc = glGetUniformLocation(shader, b"rotate")
self.scale = pyrr.Matrix44.identity()
self.rot_y = pyrr.Matrix44.identity()
def rotate(self):
self.scale = pyrr.Matrix44.from_scale(pyrr.Vector3([0.2, 0.2, 1.0])).flatten()
self.rot_y = pyrr.Matrix44.from_y_rotation(time.perf_counter() * 2).flatten
#self.rot_y = [y for x in self.rot_y for y in x]
c_scale = (GLfloat * len(self.scale))(*self.scale)
c_rotate_y = (GLfloat * len(self.rot_y))(*self.rot_y)
glUniformMatrix4fv(self.scale_loc, 1, GL_FALSE, c_scale)
glUniformMatrix4fv(self.rotate_loc, 1, GL_FALSE, c_rotate_y)
错误是
c_rotate_y = (GLfloat * len(self.rot_y))(*self.rot_y)
TypeError: object of type 'builtin_function_or_method' has no len()
我不知道它是过时了还是什么。我正在学习一个 4 年前的教程系列。如果您需要更多信息,请告诉我
Pyrr - Matrices are represented by 2 dimensional NumPy arrays. To convert the NumPy array to a ctypes
you have to flatten
it. The number of elements in the array can be get from the size
属性:
self.scale = pyrr.Matrix44.from_scale(pyrr.Vector3([0.2, 0.2, 1.0])).flatten()
self.rot_y = pyrr.Matrix44.from_y_rotation(time.perf_counter() * 2).flatten()
c_scale = (GLfloat * self.scale.size)(*self.scale)
c_rotate_y = (GLfloat * self.rot_y.size)(*self.rot_y)
glUniformMatrix4fv(self.scale_loc, 1, GL_FALSE, c_scale)
glUniformMatrix4fv(self.rotate_loc, 1, GL_FALSE, c_rotate_y)