本文整理匯總了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)