library / com.otaliastudios.opengl.program / GlProgram

GlProgram

open class GlProgram : GlBindable

Base class for a program that accepts a vertex and a fragment shader in the constructor. The program will be created automatically and released when release is called.

Subclasses are required to do two things - typically, during the onPreDraw callback: 1 Inspect the GlDrawable properties:

The vertex shader should then use the two to compute the gl_Position.

Constructors

<init>

GlProgram(handle: Int)
GlProgram(vertexShader: String, fragmentShader: String)
GlProgram(vararg shaders: GlShader)

Base class for a program that accepts a vertex and a fragment shader in the constructor. The program will be created automatically and released when release is called.

GlProgram(handle: Int, ownsHandle: Boolean, vararg shaders: GlShader)

Properties

handle

val handle: Int

Functions

bind

open fun bind(): Unit

draw

fun draw(drawable: GlDrawable, modelViewProjectionMatrix: FloatArray = drawable.modelMatrix): Unit

getAttribHandle

fun getAttribHandle(name: String): GlProgramLocation

getUniformHandle

fun getUniformHandle(name: String): GlProgramLocation

onDraw

open fun onDraw(drawable: GlDrawable): Unit

onPostDraw

open fun onPostDraw(drawable: GlDrawable): Unit

onPreDraw

open fun onPreDraw(drawable: GlDrawable, modelViewProjectionMatrix: FloatArray): Unit

release

open fun release(): Unit

unbind

open fun unbind(): Unit

Companion Object Functions

create

fun create(vertexShaderSource: String, fragmentShaderSource: String): Int
fun create(vararg shaders: GlShader): Int

Extension Functions

use

fun GlBindable.use(block: () -> Unit): Unit

Inheritors

GlNativeFlatProgram

An GlProgram that uses basic flat-shading rendering, based on FlatShadedProgram from grafika.

open class GlNativeFlatProgram : GlProgram

GlTextureProgram

Base implementation for a GlProgram that draws textures.

open class GlTextureProgram : GlProgram