Package-level declarations

Types

Link copied to clipboard

Scene. Blend equation passed to glBlendEquation.

Link copied to clipboard

Scene. Blend factor passed to glBlendFunc.

Link copied to clipboard

Scene. Faces passed to glCullFace. Off leaves culling disabled.

Link copied to clipboard
class GlAttrib(val name: String, val size: Int, val offset: Int)

Scene. One float attribute: size floats at offset floats into each vertex.

Link copied to clipboard

GLES uniform writer for one ShaderProgram rendered by GlSurface.

Link copied to clipboard
class GlFrame

Per-frame GLES context passed to GlSurface render callbacks.

Link copied to clipboard
sealed interface GlLinkState

Link lifecycle for a GlController attached to GlSurface or GlCompute.

Link copied to clipboard
class GlMesh(vertices: FloatArray, val stride: Int, val attribs: List<GlAttrib>, val mode: Int = GLES30.GL_TRIANGLES, val patchVertices: Int = 0, val depth: Boolean = false, val clearR: Float = 0.02f, val clearG: Float = 0.025f, val clearB: Float = 0.045f, indices: IntArray? = null)

Vertex layout uploaded on the GL thread when a GlSurface is created.

Link copied to clipboard
class GlPipeline(val blend: Boolean = false, val srcFactor: BlendFactor = BlendFactor.One, val dstFactor: BlendFactor = BlendFactor.Zero, val equation: BlendEquation = BlendEquation.Add, val scissor: Boolean = false, val x: Int = 0, val y: Int = 0, val width: Int = 0, val height: Int = 0, val writeRed: Boolean = true, val writeGreen: Boolean = true, val writeBlue: Boolean = true, val writeAlpha: Boolean = true, val depthMask: Boolean = true, val cullFace: CullFace = CullFace.Off)

Scene. Extra pass state on top of the depth test.

Link copied to clipboard
data class GlSurfaceConfig(val depth: Boolean = false, val strictUniformLocations: Boolean = false, val strictErrors: Boolean = false)

EGL and runtime options for GlSurface.

Properties

Link copied to clipboard

Shown when link fails and no other detail is available.

Link copied to clipboard
const val MESH_NORMAL: String
Link copied to clipboard

Triangle meshes that share one vertex layout.

Link copied to clipboard
const val MESH_STRIDE: Int
Link copied to clipboard
const val MESH_UV: String
Link copied to clipboard

Instance attribute spelled by attributeVec4("model0"). Divisor is one.

Link copied to clipboard

Instance attribute spelled by attributeVec4("model1"). Divisor is one.

Link copied to clipboard

Instance attribute spelled by attributeVec4("model2"). Divisor is one.

Link copied to clipboard

Instance attribute spelled by attributeVec4("model3"). Divisor is one.

Link copied to clipboard
const val MODEL_MATRIX_FLOATS: Int = 16

Floats in one column-major model matrix used as an instance attribute.

Functions

Link copied to clipboard
fun GlController.bindFloat(param: Uniform<Flt<High>>, value: Float)

Binds a scalar float uniform after successful recomposition (queued to the GL thread).

Link copied to clipboard
fun GlController.bindInt(param: Uniform<IntS>, value: Int)

Binds an int uniform after successful recomposition (queued to the GL thread).

Link copied to clipboard
fun GlController.bindTime(param: Uniform<Flt<High>>, isPlaying: Boolean = true, offsetSeconds: Float = 0.0f)

Drives param with elapsed time in seconds, similar to ru.redbyte.redbytefx.compose.FxController.bindTime.

Link copied to clipboard
fun box(centerX: Float, centerY: Float, centerZ: Float, halfX: Float, halfY: Float, halfZ: Float): GlMesh

Scene. Adapts a CPU box to a GlMesh with the same indices.

Link copied to clipboard
fun disc(radius: Float, halfZ: Float, segments: Int = 48): GlMesh

Scene. Filled disc in XY with a short rim.

Link copied to clipboard
fun extrudePolygon(outline: List<Pair<Float, Float>>, halfZ: Float): GlMesh

Scene. Prism along Z from a closed XY outline.

Link copied to clipboard
fun GlCompute(controller: GlController, modifier: Modifier = Modifier, requirement: String? = controller.program.glLinkRequirementHint(), overlay: @Composable (GlLinkState) -> Unit = { state -> if (state is GlLinkState.Failed) { GlLinkErrorOverlay(state.message) } })

Scene. Hosts a GLES 3.1 compute program. There is no mesh and the frame does not rasterize.

Link copied to clipboard

User-visible hint when GLES 3.0 link fails.

Link copied to clipboard

User-visible hint when a GLES 3.1 compute program fails to link.

Link copied to clipboard

User-visible hint when GLES 3.2 link fails.

Link copied to clipboard
fun GlLinkErrorOverlay(message: String, modifier: Modifier = Modifier)
Link copied to clipboard
fun ShaderProgram.glLinkRequirementHint(): String?

Picks a link-failure hint from program's target.

Link copied to clipboard

Maps pointer position to normalized device coordinates (-1..1) and invokes onPointer on the UI thread.

Link copied to clipboard
fun GlSurface(controller: GlController, mesh: GlMesh, modifier: Modifier = Modifier, requirement: String? = controller.program.glLinkRequirementHint(), present: ShaderProgram? = null, renderToTexture: Boolean = false, onFrame: (GlFrame) -> Unit, overlay: @Composable (GlLinkState) -> Unit = { state -> if (state is GlLinkState.Failed) { GlLinkErrorOverlay(state.message) } })

Embeds a GLSurfaceView that links and draws controller.program.

Link copied to clipboard
fun merge(parts: List<GlMesh>): GlMesh

Scene. Concatenates indexed triangle meshes that share MESH_STRIDE.

Link copied to clipboard

Attribute list for MESH_POSITION, MESH_NORMAL, and MESH_UV.

Link copied to clipboard
fun quad(width: Float = 1.0f, height: Float = 1.0f): GlMesh

Scene. Adapts a CPU quad to a GlMesh with the same indices.

Link copied to clipboard
fun redbyteFx(controller: GlController, modifier: Modifier = Modifier, onFrame: (GlFrame) -> Unit = {})

GLES effect host. Same short path as AGSL ru.redbyte.redbytefx.compose.redbyteFx: fragment-only shader(ShaderTarget.Gles30) { fragment { … } }, rememberGlController, then this composable. It draws a fullscreen triangle (screenMesh) and writes resolution from the view size. Unlike the AGSL modifier, it does not sample Compose content (sample() / sampleUv() stay AGSL-only). The two redbyteFx symbols live in different packages; import one per file.

Link copied to clipboard
fun rememberGlController(program: ShaderProgram, config: GlSurfaceConfig = GlSurfaceConfig()): GlController

Remembers a GlController for program.

Link copied to clipboard
fun screenMesh(clearR: Float = 0.02f, clearG: Float = 0.025f, clearB: Float = 0.045f): GlMesh

Full-screen triangle for fragment-style GLES scenes.

Link copied to clipboard
fun GlProgramRuntime.setLitModel(lit: LitMesh, model: FloatArray)

Uploads model and the matching LitMesh.normalMatrix for litTexturedMesh.

Link copied to clipboard
fun sphere(radius: Float, stacks: Int = 16, slices: Int = 24): GlMesh

Scene. Adapts a CPU sphere to a GlMesh with the same indices.

Link copied to clipboard
fun tagUv(mesh: GlMesh, u: Float, v: Float? = null): GlMesh

Scene. Writes u (and optional v) into every vertex UV.

Link copied to clipboard
fun torus(major: Float, minor: Float, majorSegments: Int = 32, minorSegments: Int = 16): GlMesh

Scene. Adapts a CPU torus to a GlMesh with the same indices.

Link copied to clipboard
fun transform(mesh: GlMesh, matrix: FloatArray): GlMesh

Scene. Moves mesh by a column-major matrix.

Link copied to clipboard
fun triangle(ax: Float, ay: Float, az: Float, bx: Float, by: Float, bz: Float, cx: Float, cy: Float, cz: Float): GlMesh

Scene. Adapts a CPU triangle to a GlMesh with the same indices.

Link copied to clipboard
fun tubeAlong(path: List<Pair<Float, Float>>, radius: Float, rings: Int = 8, z: Float = 0.0f): GlMesh

Scene. Tube along a closed XY path.