gl
Canonical Import
fennel
(local gl (require :gl))Source Files
src/lua_opengl.cpp
What It Provides
gl exposes the Space runtime's low-level OpenGL and SDL clipboard binding. It is intended for renderer code that already owns an active GL context.
API Summary
- Constants for common GL modes, buffers, textures, framebuffers, formats, and state such as
GL_COLOR_BUFFER_BIT,GL_TRIANGLES,GL_ARRAY_BUFFER,GL_TEXTURE_2D,GL_RGBA, andGL_UNSIGNED_BYTE. - Draw and state helpers:
glClear,glClearColor,glViewport,getViewport,glDrawArrays,glDrawArraysInstanced,glDrawElementsInstanced,glMultiDrawArrays,glEnable,glDisable,glDepthFunc, andglDepthMask. - Object helpers for vertex arrays, buffers, queries, framebuffers, renderbuffers, and textures:
glGen*,glDelete*,glBind*,glTexImage2D,glTexParameteri,glFramebufferTexture2D, andglBlitFramebuffer. - Buffer upload helpers:
glBufferData,glBufferDataUInt,glBufferSubData,bufferDataFromVectorBuffer,bufferSubDataFromVectorBuffer,bufferDataUIntFromVectorBuffer, andbufferSubDataUIntFromVectorBuffer. - Readback helpers:
glReadPixelsandglGetTexImagereturn byte strings forGL_RGBorGL_RGBAwithGL_UNSIGNED_BYTE. - Clipboard helpers:
clipboard-has,clipboard-get, andclipboard-set.
Examples
fennel
(local gl (require :gl))
(gl.glViewport 0 0 1280 720)
(gl.glClearColor 0.05 0.05 0.08 1.0)
(gl.glClear gl.GL_COLOR_BUFFER_BIT)Errors and Platform Notes
The binding raises when accessing undefined keys. glReadPixels and glGetTexImage only support GL_UNSIGNED_BYTE with GL_RGB or GL_RGBA. Clipboard helpers initialize the SDL video subsystem when needed and raise SDL-prefixed errors on failures.
Related Modules
shadersfor shader resource loading and uniform helpers.texturesfor managed texture resources.vector-bufferfor CPU-side float buffers used by GL upload helpers.
Aliases and Search Terms
Search terms: OpenGL, GL, graphics, rendering, framebuffer, texture, vertex buffer, clipboard.
