▼V Reference
52 Find a task or a name
53 Modules to require
54 Scenes and sampling
55 Scene states
56 Animation requests
57 Native model details
58 Visuals
59 Geometry
60 Number Lines and Coordinate Decorations
61 Point Markers, Scatter Plots, and Filled Areas
62 Probability and Statistical Diagrams
63 Calculus lessons
64 Colors
65 Slides
66 Slide command-line tools
67 Source Programs and Authored Timelines
68 Interactive Preview and Inspection
69 Preview controls and diagnostics
70 Projects and Final Rendering
71 Project execution and cache details
72 Pict Renderer Protocol
73 3D reference map
74 3D:   Objects, groups, and paths
75 3D:   Cameras and projection
76 3D:   Views inside a Scene
77 3D:   Animating 3D objects
78 3D:   Animating the 3D camera
79 3D:   Cuts, caps, and section measurements
80 3D:   Supplementary surface, section, and annotation bindings
81 3D:   Cuts, sections, and numerical volume
82 3D:   Vectors
83 3D:   Linear maps and rotations
84 3D:   Affine transforms
85 3D:   Bounds, rays, and planes
86 3D:   Spatial maps and homotopies
87 3D:   Materials and lights
88 3D:   Lighting inspection
89 3D:   Shadow descriptors and stable bounds
90 3D:   Finite-light animation
91 3D:   Software finite-light evaluation
92 3D:   Colour space and final output
93 3D:   Relations and geometric annotations
94 3D:   Projected labels
95 3D:   Textured billboards
96 3D:   Spatial curves and vector diagrams
97 3D:   Spatial anchors and label layout
98 3D:   Anchors and projected labels
99 3D:   Parametric surfaces and calculus
100 3D:   Adaptive, trimmed, and implicit surfaces
101 3D:   Constructive solids
102 3D:   Surface constructors and queries
103 3D:   Meshes
104 3D:   Triangle topology
105 3D:   Polygonal faces
106 3D:   Deterministic convex hulls
107 3D:   Polyhedral duals
108 3D:   Schlegel diagrams and polyhedral nets
109 3D:   Conservative mesh correspondence
110 3D:   Topology-safe mesh matching
111 3D:   Checking and repairing mesh orientation
112 3D:   Clipping, sections, and transparency
113 3D:   Prepared spatial ODE trajectories and vector fields
114 3D:   Seeds and streamline sets
115 3D:   Poincare sections and return maps
116 3D:   Equilibria and local linearization
117 3D:   Flow maps and volume change
118 3D:   Drawing and inspecting trajectories
119 3D:   Reading prepared trajectories
120 3D:   Drawing vector fields and particles
121 3D:   Trajectory display
122 3D:   Spatial inspection and exact picking
123 3D:   Retained renderer backends
124 3D:   Compiled geometry and instances
125 3D:   Frame requests and results
126 3D:   Software rendering and statistics
127 3D:   Optional Racket/  Open  GL backend
128 Experimental Derived Visuals
129 Source Package Hygiene
On this page:
opengl-renderer3d-spec
opengl-renderer3d-spec?
opengl-renderer3d
opengl-renderer3d?
opengl-renderer3d-available?
opengl-renderer3d-info
opengl-renderer3d-statistics
opengl-renderer3d-reset-statistics!
opengl-renderer3d-release!
9.3

127 3D: Optional Racket/OpenGL backend🔗ℹ

3D reference map · First 3D picture

 (require animate/3d/opengl) package: animate

This module provides an explicit GPU implementation of the renderer3d protocol. Requiring this module is the opt-in boundary for opengl and racket/gui/base; neither animate, animate/3d, nor animate/3d/render loads it. The renderer owns a hidden canvas only to obtain a context, renders each view3d to an owned RGBA8/depth framebuffer, reads it back, flips the rows, and returns the ordinary top-down straight-alpha ARGB result used by the Pict compositor.

procedure

(opengl-renderer3d-spec [#:samples samples 
  #:cache-megabytes cache-megabytes 
  #:fallback fallback]) 
 → opengl-renderer3d-spec?
  samples : exact-positive-integer? = 4
  cache-megabytes : exact-positive-integer? = 512
  fallback : (or/c 'error 'software) = 'error
Declares an explicit backend configuration. 'error rejects an unavailable context. 'software is the only deliberate fallback policy and is reported in backend statistics; no request silently changes backend. The requested sample count is clamped to the live driver’s maximum before rendering. Diagnostics report both the requested and effective counts, and persistent cache identity uses the effective count.

procedure

(opengl-renderer3d-spec? value) → boolean?

  value : any/c
Recognizes an OpenGL backend declaration.
Creates a retained backend with one serialized owned OpenGL context. It checks for OpenGL 3.2 and GLSL 1.50 plus VBO/EBO/VAO/FBO/depth/readback support before returning.

procedure

(opengl-renderer3d? value) → boolean?

  value : any/c
Recognizes an OpenGL renderer instance, including one whose explicit fallback is active.
Creates and closes a short lived hidden context to test availability. It is a real capability probe, not a package-presence test.

procedure

(opengl-renderer3d-info renderer) → immutable-hash?

  renderer : opengl-renderer3d?
Returns serializable GL version, GLSL version, vendor, renderer, profile, limits, required-capability, and optional-feature diagnostics. Its optional backend diagnostic data includes both requested and effective multisample counts.

procedure

(opengl-renderer3d-statistics renderer) → immutable-hash?

  renderer : opengl-renderer3d?
Returns backend counters plus geometry-cache and framebuffer-cache information.

procedure

(opengl-renderer3d-reset-statistics! renderer) → void?

  renderer : opengl-renderer3d?
Resets measured counters without changing cached immutable geometry.

procedure

(opengl-renderer3d-release! renderer) → void?

  renderer : opengl-renderer3d?
Deletes shader, VAO/VBO/EBO, framebuffer, and context-owner resources. It is idempotent and never changes an authored spatial value.

For final project output, use an explicit declaration:

(render-spec
 #:renderer3d
 (opengl-renderer3d-spec #:samples 4 #:cache-megabytes 512 #:fallback 'error)
 #:workers 1)

An OpenGL project must run in Racket 9.3 gracket; a plain racket process produces an actionable project diagnostic instead of selecting software implicitly. Project preview inherits this declaration and owns the retained renderer for the lifetime of its window. Camera motion changes uniforms and a viewport-size change only reallocates the FBO; neither reuploads immutable geometry.

OpenGL limitations: The backend has one serialized context and therefore requires #:workers 1; it does not create threaded GPU workers. It uses FBO readback rather than direct OpenGL preview-canvas composition. It supports Lambert/Blinn–Phong materials and a packed finite light stream with fixed limits of four directional, eight point, and four spot lights. The OpenGL backend supports directional/spot shadow maps through a context-owned bounded depth-texture cache. There is no GPU picking, general mesh textures, point-light cube shadows, persistent mapped buffers, PBO pipelining, compute/geometry shaders, or order-independent transparency. The software backend remains the portable default and conformance reference. Compare GPU/software pixels by tolerance: opaque interiors, antialiased edges, and transparent regions need different thresholds and must not be expected to be bit-identical.

The reference/retained conformance tests compare projected output at exact endpoints and in nonmonotonic camera-frame order. The canonical probe is "examples/3d/retained-renderer.rkt"; evaluating (retained-renderer-summary) there demonstrates a cache hit without changing the visible scene.

The repository tool "tools/run-3d-probes.rkt" renders spatial visual probes. It writes frame PNGs plus manifest.rktd and a diagnostics.rktd file per probe. The manifest records Animate and Racket versions, renderer ID, output dimensions, sample times, sampled 3D cameras, renderer-fingerprint digests, compiled geometry keys/counts, frame hashes, and compiled stroke/marker/outline counts and requested screen/world width modes. –compare-renderers software,opengl writes side-by-side software and OpenGL trees, per-frame absolute-difference PNGs, and channel-difference metrics in comparison.rktd. Probe images are human review evidence; semantic and small-raster tests remain the correctness oracle. "tools/benchmark-3d.rkt" measures the same ten named workloads through either backend. Its OpenGL run reports first context/shader/allocation work separately from warm frames, plus retained geometry, framebuffer, readback, and renderer counters. It has no CI timing threshold; the acceptance checks are zero geometry uploads for warm camera/object-transform work and zero framebuffer reallocations at an unchanged viewport.

Current limitation: Screen strokes use deterministic software coverage, not analytic antialiasing. Curve centreline detail is limited by authored samples. Hidden-line classification uses opaque and 'depth-only surfaces only: transparent surfaces are not reliable hidden-line occluders. Screen points and arrowheads are camera-facing marks, not lit mesh spheres or cones. Surface topology is a fixed rectangular grid. Solid construction currently supports only simple single contours (no holes or self-intersections), and revolution accepts only nonnegative-radius profiles around a cardinal axis. There is no adaptive tessellation, trimmed domain, texture mapping, arbitrary implicit surface, or cap generation for arbitrary sliced meshes. Transparent intersections are not order-independent: triangle sorting is a useful deterministic approximation, not OIT. Section joining does not repair pathological nonmanifold meshes. Projected labels are crisp 2D overlays; the final compositor now uses overlap-aware candidate selection among direct-mode projected labels (it minimizes overlap but cannot guarantee a disjoint result), but prepared trajectories remain explicit inputs for their sampled frame grid. Leaders and visibility policies are consumed by final composition. Only opaque depth is considered for their hide/fade policy. Billboard image annotations are depth-tested, but do not yet provide source-mapped text or exact picking. Linear and affine map requests do not resample geometry; singular maps use a deterministic authored-normal shading fallback. Pointwise and homotopy maps currently accept only an unwrapped mesh3d, not curves, surfaces, or arbitrary containers. They use the source’s fixed authored vertices without adaptive remeshing, so non-injective maps can create degenerate or self-intersecting triangles. 'drop-triangle leaves open holes and does not cap or repair them; it is deliberately not the default. Turning off normal recomputation preserves source normals and can make nonlinear shading misleading. Spatial ODE fields require finite vec3 results. Vector fields and streamlines have finite explicit author samples; they do not offer adaptive field-line topology, event detection, or adaptive stopping. There is no 3D ODE source inspector. Spatial picking accelerates indexed mesh triangles (including generated tube/surface meshes) with object bounds and a local BVH, and uses the same prepared screen footprints for strokes and markers. It does not yet expose texture UVs, interpolate supplied vertex normals for a pick, support analytic implicit geometry, or perform a GPU-backed selection pass. Preview overlays and selection scratch values are diagnostic-only and are intentionally absent from normal frame/video renders. The retained software backend caches immutable geometry separately from the reference renderer’s camera-space preparations; a camera or viewport change may therefore miss that software preparation cache. The optional OpenGL backend retains immutable geometry separately and uses tolerant, not bit-exact, image comparison.