本文整理汇总了Python中pyrr.Matrix44.orthogonal_projection方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix44.orthogonal_projection方法的具体用法?Python Matrix44.orthogonal_projection怎么用?Python Matrix44.orthogonal_projection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyrr.Matrix44
的用法示例。
在下文中一共展示了Matrix44.orthogonal_projection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from pyrr import Matrix44 [as 别名]
# 或者: from pyrr.Matrix44 import orthogonal_projection [as 别名]
def load (self: 'GLQuadRenderer') -> None:
self.make_current ()
GL.glDisable (GL.GL_CULL_FACE)
self.program = GL.glCreateProgram ()
self.vertex_shader = GL.glCreateShader (GL.GL_VERTEX_SHADER)
self.fragment_shader = GL.glCreateShader (GL.GL_FRAGMENT_SHADER)
vs_file = open ("color_harmonization/gui/glsl/vertex_shader.vsh", 'r')
vs_code = vs_file.read ()
vs_file.close ()
fs_file = open ("color_harmonization/gui/glsl/fragment_shader.fsh", 'r')
fs_code = fs_file.read ()
fs_file.close ()
GL.glShaderSource (self.vertex_shader, vs_code)
GL.glShaderSource (self.fragment_shader, fs_code)
GL.glCompileShader (self.vertex_shader)
if DEBUG:
error_log = GL.glGetShaderInfoLog (self.vertex_shader)
print ("Vertex shader: {}".format (error_log.decode ()))
GL.glCompileShader (self.fragment_shader)
if DEBUG:
error_log = GL.glGetShaderInfoLog (self.fragment_shader)
print ("Fragment shader: {}".format (error_log.decode ()))
GL.glAttachShader (self.program, self.vertex_shader)
GL.glAttachShader (self.program, self.fragment_shader)
GL.glLinkProgram (self.program)
if DEBUG:
error_log = GL.glGetProgramInfoLog (self.program)
print ("Program link: {}".format (error_log.decode ()))
self.array_buffer = GL.glGenBuffers (1)
self.vertex_array = GL.glGenVertexArrays (1)
data = numpy.array ([0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 0.0, 0.0,
1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
dtype = numpy.float32)
GL.glBindVertexArray (self.vertex_array)
GL.glBindBuffer (GL.GL_ARRAY_BUFFER, self.array_buffer)
GL.glBufferData (GL.GL_ARRAY_BUFFER, data.nbytes, data, GL.GL_STATIC_DRAW)
GL.glEnableVertexAttribArray (0)
GL.glVertexAttribPointer (0, 2, GL.GL_FLOAT, False, 24, GL.ctypes.c_void_p (0))
GL.glEnableVertexAttribArray (1)
GL.glVertexAttribPointer (1, 2, GL.GL_FLOAT, False, 24, GL.ctypes.c_void_p (8))
GL.glEnableVertexAttribArray (2)
GL.glVertexAttribPointer (2, 2, GL.GL_FLOAT, False, 24, GL.ctypes.c_void_p (16))
GL.glUseProgram (self.program)
self.__uniform_world = GL.glGetUniformLocation (self.program, "WorldMatrix")
self.__uniform_projection = GL.glGetUniformLocation (self.program, "ProjectionMatrix")
self.__uniform_texture = GL.glGetUniformLocation (self.program, "Texture")
self.__uniform_data_texture = GL.glGetUniformLocation (self.program, "DataTexture")
self.__uniform_do_harmonization = GL.glGetUniformLocation (self.program, "DoHarmonization")
self.__texture = 0
self.__data_texture = 0
GL.glUniformMatrix4fv (self.__uniform_projection, 1, False,
Matrix44.orthogonal_projection (0, 1, 0, 1, 0, 1))
GL.glUniform1i (self.__uniform_do_harmonization, self.__do_harmonization)