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)
-
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 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
:add
add_anchor
add_centered
anchor
attention_lost
augment_mouse_event
bg_color
bg_image
border_color
border_width
call_handler
call_parent_handler
defer_drawing
dismiss
draw
draw_over
fg_color
focus
focus_switch
font
get_cursor
get_focus
get_margin_rect
get_root
get_top_widget
get_visible
gl_draw
gl_draw_self
gl_draw_viewport
global_to_local
has_focus
inherited
invalidate
key_down
key_up
local_to_global
margin
menu_bar
parent
parent_resized
present
rect
relative_mode
remove
remove_anchor
resized
scale_bg
sel_color
set_parent
set_size_for_text
setup_matrices
setup_modelview
setup_projection
tab_stop
visible
Widget
: