Comprehensive ctypes-based OpenGL binding for Python providing access to OpenGL, GLU, and GLUT functionality
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
OpenGL Utility Library (GLU) providing high-level convenience functions for common OpenGL operations including perspective projection, coordinate transformations, geometric primitive rendering, polygon tessellation, and NURBS surface generation.
Viewing transformation utilities that simplify camera setup and coordinate system management.
def gluPerspective(fovy: float, aspect: float, zNear: float, zFar: float):
"""
Set up perspective projection matrix.
Parameters:
- fovy: Field of view angle in Y direction (degrees)
- aspect: Aspect ratio (width/height)
- zNear: Distance to near clipping plane (must be positive)
- zFar: Distance to far clipping plane (must be positive)
"""
def gluLookAt(eyeX: float, eyeY: float, eyeZ: float,
centerX: float, centerY: float, centerZ: float,
upX: float, upY: float, upZ: float):
"""
Set up viewing transformation matrix.
Parameters:
- eyeX, eyeY, eyeZ: Eye position (camera location)
- centerX, centerY, centerZ: Look-at point (target)
- upX, upY, upZ: Up vector direction
"""
def gluOrtho2D(left: float, right: float, bottom: float, top: float):
"""
Set up 2D orthographic projection.
Parameters:
- left, right: Left and right clipping planes
- bottom, top: Bottom and top clipping planes
"""
def gluPickMatrix(x: float, y: float, delX: float, delY: float, viewport: list):
"""
Set up picking matrix for selection.
Parameters:
- x, y: Pick point in window coordinates
- delX, delY: Pick region size
- viewport: Current viewport [x, y, width, height]
"""Functions for converting between different coordinate systems.
def gluProject(objX: float, objY: float, objZ: float,
model: list, proj: list, view: list) -> tuple:
"""
Map object coordinates to window coordinates.
Parameters:
- objX, objY, objZ: Object coordinates
- model: Model-view matrix (16-element array)
- proj: Projection matrix (16-element array)
- view: Viewport [x, y, width, height]
Returns:
Tuple of (winX, winY, winZ) window coordinates
"""
def gluUnProject(winX: float, winY: float, winZ: float,
model: list, proj: list, view: list) -> tuple:
"""
Map window coordinates to object coordinates.
Parameters:
- winX, winY: Window coordinates
- winZ: Window Z coordinate (depth value 0.0-1.0)
- model: Model-view matrix (16-element array)
- proj: Projection matrix (16-element array)
- view: Viewport [x, y, width, height]
Returns:
Tuple of (objX, objY, objZ) object coordinates
"""
def gluUnProject4(winX: float, winY: float, winZ: float, clipW: float,
model: list, proj: list, view: list,
nearVal: float, farVal: float) -> tuple:
"""
Enhanced unprojection with explicit near/far planes.
Returns:
Tuple of (objX, objY, objZ, objW) object coordinates
"""Geometric primitive generation for common 3D shapes.
def gluNewQuadric() -> GLUquadric:
"""
Create quadric object for rendering geometric primitives.
Returns:
Quadric object handle
"""
def gluDeleteQuadric(quad: GLUquadric):
"""
Delete quadric object.
Parameters:
- quad: Quadric object to delete
"""
def gluQuadricDrawStyle(quad: GLUquadric, draw):
"""
Set quadric rendering style.
Parameters:
- quad: Quadric object
- draw: Draw style (GLU_FILL, GLU_LINE, GLU_SILHOUETTE, GLU_POINT)
"""
def gluQuadricOrientation(quad: GLUquadric, orientation):
"""
Set quadric orientation.
Parameters:
- orientation: GLU_OUTSIDE (default) or GLU_INSIDE
"""
def gluQuadricNormals(quad: GLUquadric, normal):
"""
Set normal generation for quadric.
Parameters:
- normal: GLU_NONE, GLU_FLAT, or GLU_SMOOTH
"""
def gluQuadricTexture(quad: GLUquadric, texture: bool):
"""
Enable/disable texture coordinate generation.
Parameters:
- texture: True to generate texture coordinates
"""Ready-to-use geometric shapes with customizable parameters.
def gluSphere(quad: GLUquadric, radius: float, slices: int, stacks: int):
"""
Render sphere primitive.
Parameters:
- quad: Quadric object
- radius: Sphere radius
- slices: Number of longitude subdivisions
- stacks: Number of latitude subdivisions
"""
def gluCylinder(quad: GLUquadric, base: float, top: float,
height: float, slices: int, stacks: int):
"""
Render cylinder primitive.
Parameters:
- quad: Quadric object
- base: Base radius
- top: Top radius (can differ from base for cone)
- height: Cylinder height
- slices: Number of subdivisions around Z axis
- stacks: Number of subdivisions along Z axis
"""
def gluDisk(quad: GLUquadric, inner: float, outer: float,
slices: int, loops: int):
"""
Render disk primitive.
Parameters:
- quad: Quadric object
- inner: Inner radius (0 for solid disk)
- outer: Outer radius
- slices: Number of radial subdivisions
- loops: Number of concentric ring subdivisions
"""
def gluPartialDisk(quad: GLUquadric, inner: float, outer: float,
slices: int, loops: int, start: float, sweep: float):
"""
Render partial disk (sector) primitive.
Parameters:
- inner, outer: Inner and outer radii
- slices, loops: Subdivision counts
- start: Starting angle in degrees
- sweep: Sweep angle in degrees
"""Complex polygon tessellation for rendering arbitrary polygons with holes.
def gluNewTess() -> GLUtesselator:
"""
Create tessellation object.
Returns:
Tessellator object handle
"""
def gluDeleteTess(tess: GLUtesselator):
"""
Delete tessellation object.
Parameters:
- tess: Tessellator object to delete
"""
def gluTessProperty(tess: GLUtesselator, which, data: float):
"""
Set tessellation property.
Parameters:
- tess: Tessellator object
- which: Property type (GLU_TESS_WINDING_RULE, GLU_TESS_BOUNDARY_ONLY)
- data: Property value
"""
def gluTessCallback(tess: GLUtesselator, which, function):
"""
Set tessellation callback function.
Parameters:
- tess: Tessellator object
- which: Callback type (GLU_TESS_BEGIN, GLU_TESS_VERTEX, GLU_TESS_END, etc.)
- function: Callback function or None
"""
def gluTessBeginPolygon(tess: GLUtesselator, data):
"""
Begin polygon definition.
Parameters:
- tess: Tessellator object
- data: User data passed to callbacks
"""
def gluTessEndPolygon(tess: GLUtesselator):
"""End polygon definition and perform tessellation."""
def gluTessBeginContour(tess: GLUtesselator):
"""Begin contour definition (polygon outline or hole)."""
def gluTessEndContour(tess: GLUtesselator):
"""End current contour definition."""
def gluTessVertex(tess: GLUtesselator, location: list, data):
"""
Specify tessellation vertex.
Parameters:
- tess: Tessellator object
- location: Vertex coordinates [x, y, z]
- data: User data for this vertex
"""Non-Uniform Rational B-Spline surface generation for smooth curved surfaces.
def gluNewNurbsRenderer() -> GLUnurbs:
"""
Create NURBS renderer object.
Returns:
NURBS renderer handle
"""
def gluDeleteNurbsRenderer(nurb: GLUnurbs):
"""
Delete NURBS renderer.
Parameters:
- nurb: NURBS renderer to delete
"""
def gluNurbsProperty(nurb: GLUnurbs, property, value: float):
"""
Set NURBS rendering property.
Parameters:
- nurb: NURBS renderer
- property: Property type (GLU_SAMPLING_TOLERANCE, GLU_DISPLAY_MODE)
- value: Property value
"""
def gluNurbsCallback(nurb: GLUnurbs, which, function):
"""
Set NURBS callback function.
Parameters:
- nurb: NURBS renderer
- which: Callback type (GLU_NURBS_ERROR)
- function: Callback function
"""
def gluBeginSurface(nurb: GLUnurbs):
"""Begin NURBS surface definition."""
def gluEndSurface(nurb: GLUnurbs):
"""End NURBS surface definition."""
def gluNurbsSurface(nurb: GLUnurbs, sKnotCount: int, sKnots: list,
tKnotCount: int, tKnots: list, sStride: int, tStride: int,
control: list, sOrder: int, tOrder: int, type):
"""
Define NURBS surface.
Parameters:
- nurb: NURBS renderer
- sKnotCount, tKnotCount: Number of knots in s and t directions
- sKnots, tKnots: Knot sequences
- sStride, tStride: Control point strides
- control: Control point array
- sOrder, tOrder: Surface order in s and t directions
- type: Surface type (GL_MAP2_VERTEX_3, GL_MAP2_COLOR_4, etc.)
"""
def gluBeginCurve(nurb: GLUnurbs):
"""Begin NURBS curve definition."""
def gluEndCurve(nurb: GLUnurbs):
"""End NURBS curve definition."""
def gluNurbsCurve(nurb: GLUnurbs, knotCount: int, knots: list,
stride: int, control: list, order: int, type):
"""
Define NURBS curve.
Parameters:
- knotCount: Number of knots
- knots: Knot sequence
- stride: Control point stride
- control: Control point array
- order: Curve order
- type: Curve type
"""GLU-specific error reporting and string conversion.
def gluErrorString(error: int) -> str:
"""
Convert GLU error code to descriptive string.
Parameters:
- error: GLU error code
Returns:
Error description string
"""
def gluGetString(name: int) -> str:
"""
Get GLU version or extension string.
Parameters:
- name: String identifier (GLU_VERSION, GLU_EXTENSIONS)
Returns:
Information string
"""class GLUquadric:
"""Opaque quadric object handle for geometric primitive rendering."""
class GLUtesselator:
"""Opaque tessellator object handle for polygon tessellation."""
class GLUnurbs:
"""Opaque NURBS renderer object handle for surface generation."""GLU_FILL: int # Filled polygons
GLU_LINE: int # Wireframe
GLU_SILHOUETTE: int # Silhouette edges only
GLU_POINT: int # Points onlyGLU_OUTSIDE: int # Normals point outward
GLU_INSIDE: int # Normals point inwardGLU_NONE: int # No normals generated
GLU_FLAT: int # Flat normals
GLU_SMOOTH: int # Smooth normalsGLU_TESS_WINDING_RULE: int
GLU_TESS_BOUNDARY_ONLY: int
GLU_TESS_TOLERANCE: intGLU_TESS_BEGIN: int
GLU_TESS_VERTEX: int
GLU_TESS_END: int
GLU_TESS_ERROR: int
GLU_TESS_EDGE_FLAG: int
GLU_TESS_COMBINE: intGLU_SAMPLING_TOLERANCE: int
GLU_DISPLAY_MODE: int
GLU_CULLING: int
GLU_AUTO_LOAD_MATRIX: intInstall with Tessl CLI
npx tessl i tessl/pypi-pyopengl