Skip to content

renderer

FreeBodyEngine.graphics.gl33.renderer #

GL33Renderer() #

Bases: Renderer

The OpenGL renderer. Uses OpenGL version 330 Core.

Sets the backend's Mesh subclass; GPU context creation happens in on_initialize() instead, since it depends on a window (or lack thereof) that doesn't exist yet at construction time.

create_framebuffer property #

Returns GLFramebuffer.

mesh_class = GLMesh instance-attribute #

clear(color) #

Clears the color and depth buffers of the currently bound framebuffer to color.

clear_scissor() #

See Renderer.clear_scissor().

create_buffer(data) #

Wraps data in a UBOBuffer, GL33's Buffer implementation.

destroy() #

Releases the OpenGL context (win32 only - wglMakeCurrent/wglDeleteContext are Windows-specific).

disable_depth_testing() #

Disables GL_DEPTH_TEST.

draw_circle(radius, position, color) #

Not yet implemented - always a no-op.

draw_line(start, end, width, color) #

Draws a line segment from start to end using a dedicated line shader program (self.line_program), building a fresh 2-point VAO/VBO every call.

draw_mesh(mesh, material) #

Binds material and draws mesh's indexed triangles. Temporarily switches to wireframe polygon mode if material.data['render_mode'] == "wireframe" - silently skipped (drawn filled instead) on a driver with no glPolygonMode at all, which includes every GLES driver (Android): unlike GL_DEBUG_OUTPUT above, there's no ES extension that adds this back, since GLES dropped the whole fixed-function polygon-mode concept, not just made it optional.

draw_mesh_instanced(mesh, material, model_matrices, camera) #

Draws one copy of mesh per row of model_matrices (shape (N, 4, 4)) in a single glDrawElementsInstanced call. Builds a fresh per-instance VBO each call (bound to consecutive locations after mesh's own vertex attributes, one per matrix column, each with glVertexAttribDivisor(loc, 1)) - simple and correct, not the fastest possible (a persistent, resized-as-needed buffer would avoid the realloc), but this has no caller yet (see graphics/instancing.py's module docstring) so there's nothing to profile against.

enable_depth_testing() #

Enables GL_DEPTH_TEST.

get_max_buffer_size() #

Returns the max size of a UBOBuffer, in bytes.

get_mesh_class() #

Returns GLMesh.

load_shader(vertex, fragment, injector=Injector(), geometry=None) #

Compiles vertex/fragment (and optional geometry) FBUSL source into a GLShader, using injector to resolve engine-provided builtins.

on_initialize() #

Creates (or attaches to) the OpenGL context for the current window backend (glfw/wayland/win32/x11), or - if no 'window' service is registered at all - assumes a raw offscreen context already exists and is current (a true headless compute session, see graphics.ensure_gpu_context()). Also enables GL_DEBUG_OUTPUT and sets the initial viewport.

resize(size) #

Updates the GL viewport to size, and resizes the platform-specific window surface (wayland/x11) to match.

set_blend_mode(mode) #

See Renderer.set_blend_mode. Skips the actual GL calls if mode already matches the last mode set, since flush() calls this between every group even when consecutive groups share a mode.

set_scissor(x, y, width, height) #

See Renderer.set_scissor(). x/y come in top-left-origin, Y-down (UIRenderer's convention) - glScissor wants bottom-left origin, so y is flipped against the framebuffer height.

swap_buffers() #

Swaps the front/back buffers for a manually-created wayland/x11 context. glfw drives its own swap directly (see core/window/glfw.py) instead of going through the renderer, so this is a no-op there.

debug_callback(source, type, id, severity, length, message, userParam) #

GL_DEBUG_OUTPUT callback (see glDebugMessageCallback in on_initialize) - decodes the driver's UTF-8 message and prints it, so GL errors/ warnings surface immediately instead of needing a manual glGetError() poll.