CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pyopengl

Comprehensive ctypes-based OpenGL binding for Python providing access to OpenGL, GLU, and GLUT functionality

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

glut-window.mddocs/

GLUT Window Management

OpenGL Utility Toolkit (GLUT) providing complete window management and event handling system for creating OpenGL applications. Includes support for keyboard input, mouse interaction, timer callbacks, and display modes with automatic context creation.

Capabilities

Initialization and Setup

GLUT initialization and display mode configuration.

def glutInit(argv: list):
    """
    Initialize GLUT library.
    
    Parameters:
    - argv: Command line arguments (typically sys.argv)
    """

def glutInitDisplayMode(mode):
    """
    Set initial display mode.
    
    Parameters:
    - mode: Display mode flags (GLUT_SINGLE, GLUT_DOUBLE, GLUT_RGB, etc.)
    """

def glutInitWindowSize(width: int, height: int):
    """
    Set initial window size.
    
    Parameters:
    - width, height: Window dimensions in pixels
    """

def glutInitWindowPosition(x: int, y: int):
    """
    Set initial window position.
    
    Parameters:
    - x, y: Window position on screen
    """

def glutGet(pname) -> int:
    """
    Get GLUT state information.
    
    Parameters:
    - pname: State parameter (GLUT_WINDOW_WIDTH, GLUT_WINDOW_HEIGHT, etc.)
    
    Returns:
    State value
    """

Window Management

Window creation, manipulation, and destruction.

def glutCreateWindow(title: str) -> int:
    """
    Create top-level window.
    
    Parameters:
    - title: Window title string
    
    Returns:
    Window identifier
    """

def glutCreateSubWindow(win: int, x: int, y: int, width: int, height: int) -> int:
    """
    Create subwindow.
    
    Parameters:
    - win: Parent window identifier
    - x, y: Position relative to parent
    - width, height: Subwindow dimensions
    
    Returns:
    Subwindow identifier
    """

def glutDestroyWindow(win: int):
    """
    Destroy window.
    
    Parameters:
    - win: Window identifier to destroy
    """

def glutSetWindow(win: int):
    """
    Set current window.
    
    Parameters:
    - win: Window identifier to make current
    """

def glutGetWindow() -> int:
    """
    Get current window identifier.
    
    Returns:
    Current window identifier
    """

def glutSetWindowTitle(title: str):
    """Set current window title."""

def glutSetIconTitle(title: str):
    """Set current window icon title."""

def glutReshapeWindow(width: int, height: int):
    """Resize current window."""

def glutPositionWindow(x: int, y: int):
    """Move current window."""

def glutShowWindow():
    """Show current window."""

def glutHideWindow():
    """Hide current window."""

def glutIconifyWindow():
    """Iconify current window."""

def glutPushWindow():
    """Push current window to back."""

def glutPopWindow():
    """Pop current window to front."""

def glutFullScreen():
    """Make current window full screen."""

Event Loop and Callbacks

Main event loop and callback registration system.

def glutMainLoop():
    """
    Enter GLUT event processing loop.
    This function never returns.
    """

def glutDisplayFunc(func):
    """
    Set display callback function.
    
    Parameters:
    - func: Function called when window needs redrawing
    """

def glutReshapeFunc(func):
    """
    Set reshape callback function.
    
    Parameters:
    - func: Function called when window is resized
           Signature: func(width: int, height: int)
    """

def glutKeyboardFunc(func):
    """
    Set keyboard callback function.
    
    Parameters:
    - func: Function called on key press
           Signature: func(key: bytes, x: int, y: int)
    """

def glutKeyboardUpFunc(func):
    """
    Set keyboard up callback function.
    
    Parameters:
    - func: Function called on key release
           Signature: func(key: bytes, x: int, y: int)
    """

def glutSpecialFunc(func):
    """
    Set special key callback function.
    
    Parameters:
    - func: Function called on special key press
           Signature: func(key: int, x: int, y: int)
    """

def glutSpecialUpFunc(func):
    """
    Set special key up callback function.
    
    Parameters:
    - func: Function called on special key release
           Signature: func(key: int, x: int, y: int)
    """

def glutMouseFunc(func):
    """
    Set mouse button callback function.
    
    Parameters:
    - func: Function called on mouse button press/release
           Signature: func(button: int, state: int, x: int, y: int)
    """

def glutMotionFunc(func):
    """
    Set mouse motion callback (with button pressed).
    
    Parameters:
    - func: Function called during mouse drag
           Signature: func(x: int, y: int)
    """

def glutPassiveMotionFunc(func):
    """
    Set passive mouse motion callback.
    
    Parameters:
    - func: Function called during mouse movement (no buttons)
           Signature: func(x: int, y: int)
    """

def glutIdleFunc(func):
    """
    Set idle callback function.
    
    Parameters:
    - func: Function called when no events pending, or None to disable
    """

def glutTimerFunc(msecs: int, func, value: int):
    """
    Set timer callback function.
    
    Parameters:
    - msecs: Milliseconds until callback
    - func: Timer callback function
           Signature: func(value: int)
    - value: Value passed to callback
    """

def glutVisibilityFunc(func):
    """
    Set window visibility callback.
    
    Parameters:
    - func: Function called on visibility change
           Signature: func(state: int)
    """

def glutEntryFunc(func):
    """
    Set mouse entry/exit callback.
    
    Parameters:
    - func: Function called when mouse enters/exits window
           Signature: func(state: int)
    """

Display and Rendering

Display buffer management and rendering control.

def glutSwapBuffers():
    """Swap front and back buffers (double buffering)."""

def glutPostRedisplay():
    """Mark current window for redisplay."""

def glutPostWindowRedisplay(win: int):
    """
    Mark specified window for redisplay.
    
    Parameters:
    - win: Window identifier
    """

Menu System

Pop-up menu creation and management.

def glutCreateMenu(func) -> int:
    """
    Create pop-up menu.
    
    Parameters:
    - func: Menu callback function
           Signature: func(value: int)
    
    Returns:
    Menu identifier
    """

def glutDestroyMenu(menu: int):
    """
    Destroy menu.
    
    Parameters:
    - menu: Menu identifier
    """

def glutGetMenu() -> int:
    """
    Get current menu identifier.
    
    Returns:
    Current menu identifier
    """

def glutSetMenu(menu: int):
    """
    Set current menu.
    
    Parameters:
    - menu: Menu identifier to make current
    """

def glutAddMenuEntry(label: str, value: int):
    """
    Add menu entry.
    
    Parameters:
    - label: Menu item text
    - value: Value passed to menu callback
    """

def glutAddSubMenu(label: str, submenu: int):
    """
    Add submenu entry.
    
    Parameters:
    - label: Submenu text
    - submenu: Submenu identifier
    """

def glutChangeToMenuEntry(item: int, label: str, value: int):
    """Change menu item to regular entry."""

def glutChangeToSubMenu(item: int, label: str, submenu: int):
    """Change menu item to submenu."""

def glutRemoveMenuItem(item: int):
    """Remove menu item."""

def glutAttachMenu(button: int):
    """
    Attach current menu to mouse button.
    
    Parameters:
    - button: Mouse button (GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON)
    """

def glutDetachMenu(button: int):
    """Detach menu from mouse button."""

Font Rendering

Text rendering with bitmap and stroke fonts.

def glutBitmapCharacter(font, character: int):
    """
    Render bitmap character.
    
    Parameters:
    - font: Font identifier (GLUT_BITMAP_9_BY_15, GLUT_BITMAP_HELVETICA_18, etc.)
    - character: Character code to render
    """

def glutBitmapString(font, string: str):
    """
    Render bitmap string.
    
    Parameters:
    - font: Font identifier
    - string: String to render
    """

def glutBitmapWidth(font, character: int) -> int:
    """
    Get bitmap character width.
    
    Returns:
    Character width in pixels
    """

def glutBitmapLength(font, string: str) -> int:
    """
    Get bitmap string length.
    
    Returns:
    String width in pixels
    """

def glutStrokeCharacter(font, character: int):
    """
    Render stroke character.
    
    Parameters:
    - font: Stroke font (GLUT_STROKE_ROMAN, GLUT_STROKE_MONO_ROMAN)
    - character: Character code to render
    """

def glutStrokeString(font, string: str):
    """Render stroke string."""

def glutStrokeWidth(font, character: int) -> float:
    """
    Get stroke character width.
    
    Returns:
    Character width in font units
    """

def glutStrokeLength(font, string: str) -> float:
    """
    Get stroke string length.
    
    Returns:
    String width in font units
    """

Geometric Primitives

Built-in geometric shapes for quick prototyping.

def glutWireSphere(radius: float, slices: int, stacks: int):
    """
    Render wireframe sphere.
    
    Parameters:
    - radius: Sphere radius
    - slices: Number of longitude lines
    - stacks: Number of latitude lines
    """

def glutSolidSphere(radius: float, slices: int, stacks: int):
    """Render solid sphere."""

def glutWireCube(size: float):
    """
    Render wireframe cube.
    
    Parameters:
    - size: Edge length
    """

def glutSolidCube(size: float):
    """Render solid cube."""

def glutWireCone(base: float, height: float, slices: int, stacks: int):
    """
    Render wireframe cone.
    
    Parameters:
    - base: Base radius
    - height: Cone height
    - slices: Number of radial subdivisions
    - stacks: Number of height subdivisions
    """

def glutSolidCone(base: float, height: float, slices: int, stacks: int):
    """Render solid cone."""

def glutWireTorus(innerRadius: float, outerRadius: float, sides: int, rings: int):
    """
    Render wireframe torus.
    
    Parameters:
    - innerRadius: Inner radius
    - outerRadius: Outer radius
    - sides: Number of sides per ring
    - rings: Number of rings
    """

def glutSolidTorus(innerRadius: float, outerRadius: float, sides: int, rings: int):
    """Render solid torus."""

def glutWireTetrahedron():
    """Render wireframe tetrahedron."""

def glutSolidTetrahedron():
    """Render solid tetrahedron."""

def glutWireOctahedron():
    """Render wireframe octahedron."""

def glutSolidOctahedron():
    """Render solid octahedron."""

def glutWireDodecahedron():
    """Render wireframe dodecahedron."""

def glutSolidDodecahedron():
    """Render solid dodecahedron."""

def glutWireIcosahedron():
    """Render wireframe icosahedron."""

def glutSolidIcosahedron():
    """Render solid icosahedron."""

def glutWireTeapot(size: float):
    """
    Render wireframe teapot (Utah teapot).
    
    Parameters:
    - size: Teapot size scaling factor
    """

def glutSolidTeapot(size: float):
    """Render solid teapot."""

FreeGLUT Extensions

Extended functionality available when FreeGLUT is present.

def glutLeaveMainLoop():
    """
    Exit main event loop (FreeGLUT only).
    Available when HAVE_FREEGLUT is True.
    """

def glutMainLoopEvent():
    """
    Process single iteration of event loop (FreeGLUT only).
    """

def glutCloseFunc(func):
    """
    Set window close callback (FreeGLUT only).
    
    Parameters:
    - func: Function called when window is closed
    """

def glutWMCloseFunc(func):
    """Set window manager close callback (FreeGLUT only)."""

# FreeGLUT detection
HAVE_FREEGLUT: bool  # True if FreeGLUT extensions are available

Constants

Display Mode Flags

GLUT_SINGLE: int     # Single buffered
GLUT_DOUBLE: int     # Double buffered
GLUT_RGB: int        # RGB color mode
GLUT_RGBA: int       # RGBA color mode
GLUT_INDEX: int      # Color index mode
GLUT_DEPTH: int      # Depth buffer
GLUT_STENCIL: int    # Stencil buffer
GLUT_ACCUM: int      # Accumulation buffer
GLUT_ALPHA: int      # Alpha channel
GLUT_MULTISAMPLE: int # Multisampling

Mouse Buttons

GLUT_LEFT_BUTTON: int
GLUT_MIDDLE_BUTTON: int
GLUT_RIGHT_BUTTON: int

Mouse Button States

GLUT_DOWN: int       # Button pressed
GLUT_UP: int         # Button released

Special Keys

GLUT_KEY_F1: int through GLUT_KEY_F12: int  # Function keys
GLUT_KEY_LEFT: int      # Arrow keys
GLUT_KEY_UP: int
GLUT_KEY_RIGHT: int
GLUT_KEY_DOWN: int
GLUT_KEY_PAGE_UP: int   # Navigation keys
GLUT_KEY_PAGE_DOWN: int
GLUT_KEY_HOME: int
GLUT_KEY_END: int
GLUT_KEY_INSERT: int

Visibility States

GLUT_NOT_VISIBLE: int
GLUT_VISIBLE: int

Entry States

GLUT_LEFT: int       # Mouse left window
GLUT_ENTERED: int    # Mouse entered window

Font Identifiers

# Bitmap fonts
GLUT_BITMAP_9_BY_15: int
GLUT_BITMAP_8_BY_13: int
GLUT_BITMAP_TIMES_ROMAN_10: int
GLUT_BITMAP_TIMES_ROMAN_24: int
GLUT_BITMAP_HELVETICA_10: int
GLUT_BITMAP_HELVETICA_12: int
GLUT_BITMAP_HELVETICA_18: int

# Stroke fonts
GLUT_STROKE_ROMAN: int
GLUT_STROKE_MONO_ROMAN: int

Install with Tessl CLI

npx tessl i tessl/pypi-pyopengl

docs

array-operations.md

core-opengl.md

error-handling.md

glu-utilities.md

glut-window.md

index.md

platform-support.md

shaders.md

tile.json