Module albow.openGL.GLPerspective
Source code
from pygame import Rect
from OpenGL import GLU
from albow.openGL.GLViewport import GLViewport
class GLPerspective(GLViewport):
"""
`GLPerspective` provides an OpenGL drawing area with a perspective projection.
Using a GLPerspective widget is the same as using a `GLViewport`, except that you do not need to provide
a `setup_projection()` method.
"""
def __init__(self, rect: Rect=None, fovy: int=20, near: float=0.1, far: int=1000, **kwds):
"""
Creates a GLPerspective instance with the given initial values for its projection parameters.
The projection parameters, as used by `gluPerspective()`. You can change these to dynamically modify
the projection. The aspect ratio is calculated automatically from the widget dimensions.
Args:
rect:
fovy:
near:
far:
**kwds:
"""
#
# Python 3 update
#
# GLViewport.__init__(self, rect, **kwds)
super().__init__(rect, **kwds)
self.fovy = fovy
self.near = near
self.far = far
def setup_projection(self):
aspect = self.width / self.height
GLU.gluPerspective(self.fovy, aspect, self.near, self.far)
Classes
class GLPerspective (rect=None, fovy=20, near=0.1, far=1000, **kwds)-
GLPerspectiveprovides an OpenGL drawing area with a perspective projection.Using a GLPerspective widget is the same as using a
GLViewport, except that you do not need to provide asetup_projection()method.Creates a GLPerspective instance with the given initial values for its projection parameters.
The projection parameters, as used by
gluPerspective(). You can change these to dynamically modify the projection. The aspect ratio is calculated automatically from the widget dimensions.Args
rect:
fovy:
near:
far:
**kwds:
Source code
class GLPerspective(GLViewport): """ `GLPerspective` provides an OpenGL drawing area with a perspective projection. Using a GLPerspective widget is the same as using a `GLViewport`, except that you do not need to provide a `setup_projection()` method. """ def __init__(self, rect: Rect=None, fovy: int=20, near: float=0.1, far: int=1000, **kwds): """ Creates a GLPerspective instance with the given initial values for its projection parameters. The projection parameters, as used by `gluPerspective()`. You can change these to dynamically modify the projection. The aspect ratio is calculated automatically from the widget dimensions. Args: rect: fovy: near: far: **kwds: """ # # Python 3 update # # GLViewport.__init__(self, rect, **kwds) super().__init__(rect, **kwds) self.fovy = fovy self.near = near self.far = far def setup_projection(self): aspect = self.width / self.height GLU.gluPerspective(self.fovy, aspect, self.near, self.far)Ancestors
Subclasses
- albow.demo.openGL.PerspectiveDemo.PerspectiveDemo
Inherited members
GLViewport:addadd_anchoradd_centeredanchorattention_lostaugment_mouse_eventbg_colorbg_imageborder_colorborder_widthcall_handlercall_parent_handlerdefer_drawingdismissdrawdraw_overfg_colorfocusfocus_switchfontget_cursorget_focusget_margin_rectget_rootget_top_widgetget_visiblegl_drawgl_draw_selfgl_draw_viewportglobal_to_localhas_focusinheritedinvalidatekey_downkey_uplocal_to_globalmarginmenu_barparentparent_resizedpresentrectrelative_moderemoveremove_anchorresizedscale_bgsel_colorset_parentset_size_for_textsetup_matricessetup_modelviewsetup_projectiontab_stopvisible
Widget: