本文整理汇总了Python中pyglet.gl.glUseProgram函数的典型用法代码示例。如果您正苦于以下问题:Python glUseProgram函数的具体用法?Python glUseProgram怎么用?Python glUseProgram使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glUseProgram函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_to_texture
def render_to_texture():
# select the target to draw into
gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, framebuffer)
draw_buffers = (gl.GLenum * 1)(gl.GL_COLOR_ATTACHMENT0)
gl.glDrawBuffers(1, draw_buffers)
gl.glViewport(0, 0, FB_WIDTH, FB_HEIGHT)
# clear the destination
gl.glClearColor(0.5, 0.6, 0.7, 1.0)
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
# prepare the rendering
gl.glUseProgram(render_program)
# send the vertex data
data = (COLOR_VERTEX * 3)(((-0.6, -0.5), (1.0, 0.0, 0.0, 1.0)),
((0.6, -0.5), (0.0, 1.0, 0.0, 1.0)),
((0.0, 0.5), (0.0, 0.0, 1.0, 1.0)))
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, render_vertexbuffer)
gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(data), data, gl.GL_DYNAMIC_DRAW)
# draw using the vertex array for vertex information
gl.glBindVertexArray(render_vao)
gl.glDrawArrays(gl.GL_TRIANGLES, 0, 3)
gl.glBindVertexArray(0)
示例2: copy_texture_to_screen
def copy_texture_to_screen():
# select the target to draw into
gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
gl.glViewport(0, 0, window.width, window.height)
# clear the destination
gl.glClearColor(0.4, 0.4, 0.4, 1.0)
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
# select the program for drawing
gl.glUseProgram(copy_program)
# send the vertex data
data = (TEXTURE_VERTEX * 8)(((-0.9, -0.9), (0.0, 0.0)),
((0.5, -0.9), (1.0, 0.0)),
((0.5, 0.5), (1.0, 1.0)),
((-0.9, 0.5), (0.0, 1.0)),
((0.6, 0.6), (0.0, 1.0)),
((1.0, 0.6), (1.0, 1.0)),
((1.0, 1.0), (1.0, 0.0)),
((0.6, 1.0), (0.0, 0.0)),
)
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, copy_vertexbuffer)
gl.glBufferData(gl.GL_ARRAY_BUFFER, ctypes.sizeof(data), data, gl.GL_DYNAMIC_DRAW)
# draw
gl.glBindVertexArray(copy_vao)
gl.glDrawArrays(gl.GL_QUADS, 0, 8)
gl.glBindVertexArray(0)
示例3: unuse
def unuse(self):
"""P.unuse()
Disable the program for rendering.
"""
gl.glUseProgram(0)
示例4: use
def use(self):
"""P.use()
Enables the program for rendering.
"""
gl.glUseProgram(self.__program)
示例5: use
def use(self):
"""Bind the program into the rendering pipeline.
"""
if not self.linked:
self._link()
# bind the program
gl.glUseProgram(self.handle)
self.bound = True
示例6: use
def use(self):
self.id = gl.glCreateProgram()
for shader in self.shaders:
shader.compile()
gl.glAttachShader(self.id, shader.id)
gl.glLinkProgram(self.id)
message = self._getMessage()
if not self.getLinkStatus():
raise LinkError(message)
gl.glUseProgram(self.id)
return message
示例7: __draw
def __draw(self):
gl.glClearColor(self.__bg_color[0],
self.__bg_color[1],
self.__bg_color[2],
self.__bg_color[3])
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
gl.glUseProgram(self.__prog.value)
# update data buffer if necessary
with self.__data_lock:
if self.__data_altered:
self.__setup_data_buffer()
self.__set_uniforms()
self.__set_attributes()
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE)
gl.glEnable(gl.GL_BLEND)
gl.glEnable(gl.GL_CULL_FACE)
gl.glDrawArraysInstanced(gl.GL_TRIANGLES,
0, 36, self.__data.size / (self.__downsample**3))
示例8: _prepareFBOrender
def _prepareFBOrender(self):
if self.mode=='mono++':
GL.glUseProgram(self._shaders['mono++'])
elif self.mode=='color++':
GL.glUseProgram(self._shaders['color++'])
else:
GL.glUseProgram(self.win._progFBOtoFrame)
示例9: _finishFBOrender
def _finishFBOrender(self):
if self.mode[:4] in ['mono','colo']:
GL.glUseProgram(0)
elif self.mode[:4]=='bits':
self._drawLUTtoScreen()
示例10: unbind
def unbind(self):
# unbind whatever program is currently bound - not necessarily this program,
# so this should probably be a class method instead
GL.glUseProgram(0)
示例11: _prepareFBOrender
def _prepareFBOrender(self):
if self.mode=='mono++':
GL.glUseProgram(self._shaders['mono++'])
if self.mode=='color++':
GL.glUseProgram(self._shaders['color++'])
示例12: disable
def disable(self):
"""Unbind all programs in use.
"""
gl.glUseProgram(0)
self.bound = False
示例13: bind
def bind(self):
# bind the program
GL.glUseProgram(self.handle)
示例14: unbind
def unbind(self):
gl.glUseProgram(0)