本文整理汇总了Python中pyglet.gl.glViewport方法的典型用法代码示例。如果您正苦于以下问题:Python gl.glViewport方法的具体用法?Python gl.glViewport怎么用?Python gl.glViewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet.gl
的用法示例。
在下文中一共展示了gl.glViewport方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_draw
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def on_draw(self):
gl.glClearColor(0, 0, 0, 0)
self.clear()
gl.glViewport(0, 0, self.width, self.height)
now = time.clock() - self._start_time
now *= self._speed
with self.bufferA:
with self.shaderA:
self.shaderA.uniformf("iTime", now)
self.shaderA.uniformi("iFrame", self._frame_count)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
with self.bufferB:
with self.shaderB:
self.shaderB.uniformf("iTime", now)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
with self.shaderC:
self.shaderC.uniformf("iTime", now)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
self._frame_count += 1
示例2: on_draw
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def on_draw(self):
gl.glClearColor(0, 0, 0, 0)
self.clear()
gl.glViewport(0, 0, self.width, self.height)
self._last = self._now
self._now = time.clock()
itime = self._now - self._start_time
idate = get_idate()
delta = self._now - self._last
with self.bufferA:
with self.shaderA:
self.shaderA.uniformf("iTime", itime)
self.shaderA.uniformf("iDate", *idate)
self.shaderA.uniformf("iTimeDelta", delta)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
with self.shaderB:
self.shaderB.uniformf("iTime", itime)
self.shaderB.uniformf("iDate", *idate)
self.shaderB.uniformf("iTimeDelta", delta)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
self._frame_count += 1
示例3: on_resize
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def on_resize(self, width, height):
'''A default resize event handler.
This default handler updates the GL viewport to cover the entire
window and sets the ``GL_PROJECTION`` matrix to be orthogonal in
window space. The bottom-left corner is (0, 0) and the top-right
corner is the width and height of the window in pixels.
Override this event handler with your own to create another
projection, for example in perspective.
'''
gl.glViewport(0, 0, width, height)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, width, 0, height, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
示例4: on_draw
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def on_draw(self):
gl.glClearColor(0, 0, 0, 0)
self.clear()
gl.glViewport(0, 0, self.width, self.height)
with self.shader:
self.shader.uniformf("iTime", time.clock() - self._start_time)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
示例5: on_draw
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def on_draw(self):
gl.glClearColor(0, 0, 0, 0)
self.clear()
gl.glViewport(0, 0, self.width, self.height)
now = time.clock() - self._start_time
now *= 20
with self.shader:
self.shader.uniformf("iTime", now)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
示例6: on_draw
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def on_draw(self):
gl.glClearColor(0, 0, 0, 0)
self.clear()
gl.glViewport(0, 0, self.width, self.height)
with self.shader:
self.shader.uniformf("iTime", time.clock() - self._start_time)
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP, 0, 4)
if self.video_on and (self.frame_count % self.sample_rate == 0):
self.write_video_frame()
self.frame_count += 1
示例7: _setup_2d
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def _setup_2d(self):
w, h = self.get_size()
gl.glDisable(gl.GL_DEPTH_TEST)
viewport = self.get_viewport_size()
gl.glViewport(0, 0, max(1, viewport[0]), max(1, viewport[1]))
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, max(1, w), 0, max(1, h), -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
示例8: _setup_3d
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def _setup_3d(self):
w, h = self.get_size()
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glDepthFunc(gl.GL_LEQUAL)
gl.glEnable(gl.GL_DEPTH_TEST)
gl.glEnable(gl.GL_CULL_FACE)
viewport = self.get_viewport_size()
gl.glViewport(0, 0, max(1, viewport[0]), max(1, viewport[1]))
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.gluPerspective(*self.perspective)
gl.glMatrixMode(gl.GL_MODELVIEW)
gl.glLoadIdentity()
y, x = self.rotation
gl.glRotatef(x, 0, 1, 0)
gl.glRotatef(-y, math.cos(math.radians(x)),
0, math.sin(math.radians(x)))
# NOTE: for GL render, its x-z plane is the ground plane,
# so we unpack the position using `(x, z, y)` instead of `(x, y, z)`
x, z, y = self.position
if not self.debug_mode:
y += self.perspective_over_drone[0]
z += self.perspective_over_drone[1]
gl.glTranslatef(-x, -y, -z)
示例9: set_3d
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def set_3d(self, size):
"""Configure OpenGL to draw in 3d."""
width, height = size
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glViewport(0, 0, width, height)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.gluPerspective(65.0, width / float(height), 0.1, 60.0)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
x, y = self.player.rotation
GL.glRotatef(x, 0, 1, 0)
GL.glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x)))
x, y, z = self.player.position
GL.glTranslatef(-x, -y, -z)
示例10: set_2d
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def set_2d(self, size):
"""Configure OpenGL to draw in 2d."""
width, height = size
GL.glDisable(GL.GL_DEPTH_TEST)
GL.glViewport(0, 0, width, height)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.glOrtho(0, width, 0, height, -1, 1)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
示例11: set
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def set(self, window_width, window_height, framebuffer_width, framebuffer_height):
width = max(1, window_width)
height = max(1, window_height)
gl.glViewport(0, 0, framebuffer_width, framebuffer_height)
with pyglet.graphics.get_default_shader().uniform_buffers['WindowBlock'] as window_block:
window_block.projection[:] = matrix.create_orthogonal(0, width, 0, height, -255, 255)
if not self._view:
# Set view to Identity Matrix
self._view = matrix.Mat4()
window_block.view[:] = self._view
示例12: get_framebuffer_size
# 需要导入模块: from pyglet import gl [as 别名]
# 或者: from pyglet.gl import glViewport [as 别名]
def get_framebuffer_size(self):
"""Return the size in actual pixels of the Window framebuffer.
When using HiDPI screens, the size of the Window's framebuffer
can be higher than that of the Window size requested. If you
are performing operations that require knowing the actual number
of pixels in the window, this method should be used instead of
:py:func:`Window.get_size()`. For example, setting the Window
projection or setting the glViewport size.
:rtype: (int, int)
:return: The width and height of the Window viewport, in pixels.
"""
return self.get_size()