GLGraphics
A set of helpers to interact with GL stuff. Public API is trying to be a bit agnostic so that other non-GL implementations could be replaced fairly easily.
Static Members
NO_TEXTURE: clay.TextureIdNO_FRAMEBUFFER: GLFramebufferNO_RENDERBUFFER: GLRenderbufferNO_SHADER: GLShaderNO_PROGRAM: GLProgramNO_LOCATION: GLUniformLocationNO_BUFFER: GLBufferClear the current render buffer
| Name | Type | Default | Description |
|---|---|---|---|
r |
Float | red value (between 0 and 1) | |
g |
Float | green value (between 0 and 1) | |
b |
Float | blue value (between 0 and 1) | |
a |
Float | alpha value (between 0 and 1) | |
clearDepth |
Bool | true |
set to true (default) to also clear depth buffer, if applicable |
createTextureId(): clay.TextureIdCreate a new texture and return its identifier
| Returns | Description |
|---|---|
| clay.TextureId | TextureId |
Set active texture slot
| Name | Type | Description |
|---|---|---|
slot |
Int | a slot number. Assigned expression will be GL.TEXTURE0 + slot on GL |
deleteTexture(textureId: clay.TextureId): VoidDelete the texture identified with textureId from the GPU
| Name | Type |
|---|---|
textureId |
clay.TextureId |
Set current viewport delimited with x, y, width and height
| Name | Type | Description |
|---|---|---|
x |
Int | The x value to specify lower left corner of viewport |
y |
Int | The y value to specify lower left corner of viewport |
width |
Int | The width of the viewport |
height |
Int | The height of the viewport |
bindTexture2d(textureId: clay.TextureId): VoidBind the texture identified by textureId to do some work with it
| Name | Type | Description |
|---|---|---|
textureId |
clay.TextureId | a valid texture identifier returned by createTextureId() or NO_TEXTURE to unbind texture |
maxTextureSize(): IntReturn the maximum size of a texture from the hardware
| Returns | Description |
|---|---|
| Int | Int |
needsPreprocessedPremultipliedAlpha(): BoolReturns true if premultiplied textures should have their pixels buffer preprocessed before submit
| Returns | Description |
|---|---|
| Bool | Bool |
submitCompressedTexture2dPixels(level: Int, format: clay.TextureFormat, width: Int, height: Int, pixels: clay.buffers.Uint8Array, premultipliedAlpha: Bool): VoidSubmit compressed texture 2D pixels
| Name | Type | Description |
|---|---|---|
level |
Int | The level of detail. Level 0 is the base image level. Level n is the nth mipmap reduction image. |
format |
clay.TextureFormat | The texture format (RGBA) |
width |
Int | The width of the texture to submit |
height |
Int | The height of the texture to submit |
pixels |
clay.buffers.Uint8Array | The pixels buffer when the data will be written to |
premultipliedAlpha |
Bool | The pixels buffer should be stored as premultiplied alpha |
submitTexture2dPixels(level: Int, format: clay.TextureFormat, width: Int, height: Int, dataType: clay.TextureDataType, pixels: clay.buffers.Uint8Array, premultipliedAlpha: Bool): VoidFetch 2d texture pixels
| Name | Type | Description |
|---|---|---|
level |
Int | The level of detail. Level 0 is the base image level. Level n is the nth mipmap reduction image. |
format |
clay.TextureFormat | The texture format (RGBA) |
width |
Int | The width of the texture to submit |
height |
Int | The height of the texture to submit |
dataType |
clay.TextureDataType | The data type of the pixel data (UNSIGNED_BYTE) |
pixels |
clay.buffers.Uint8Array | The pixels buffer containing data to submit |
premultipliedAlpha |
Bool | The pixels buffer should be stored as premultiplied alpha |
Fetch texture 2d pixels
| Name | Type | Description |
|---|---|---|
into |
clay.buffers.Uint8Array | The pixels buffer when the data will be written to |
x |
Int | The x position of the texture rect to fetch |
y |
Int | The y position of the texture rect to fetch |
w |
Int | The width of the texture rect to fetch |
h |
Int | The height of the texture rect to fetch |
createFramebuffer(): GLFramebufferCreate a new framebuffer
| Returns | Description |
|---|---|
| GLFramebuffer | Framebuffer |
bindFramebuffer(framebuffer: GLFramebuffer): VoidBind a framebuffer to work with it
| Name | Type | Description |
|---|---|---|
framebuffer |
GLFramebuffer | The framebuffer to bind |
createRenderbuffer(): GLRenderbufferCreate a new renderbuffer
| Returns | Description |
|---|---|
| GLRenderbuffer | Renderbuffer |
bindRenderbuffer(renderbuffer: GLRenderbuffer): VoidBind a renderbuffer to work with it
| Name | Type | Description |
|---|---|---|
renderbuffer |
GLRenderbuffer | The renderbuffer to bind |
setTexture2dMinFilter(minFilter: clay.TextureFilter): VoidSet 2d texture minification filter
| Name | Type |
|---|---|
minFilter |
clay.TextureFilter |
setTexture2dMagFilter(magFilter: clay.TextureFilter): VoidSet 2d texture magnification filter
| Name | Type |
|---|---|
magFilter |
clay.TextureFilter |
setTexture2dWrapS(wrapS: clay.TextureWrap): VoidSet 2d texture s (horizontal) clamp type
| Name | Type |
|---|---|
wrapS |
clay.TextureWrap |
setTexture2dWrapT(wrapT: clay.TextureWrap): VoidSet 2d texture t (vertical) clamp type
| Name | Type |
|---|---|
wrapT |
clay.TextureWrap |
configureRenderTargetBuffersStorage(renderTarget: GLGraphics_RenderTarget, textureId: clay.TextureId, width: Int, height: Int, depth: Bool, stencil: Bool, antialiasing: Int): VoidConfigure storage for the given framebuffer and renderbuffer with the given settings. This helper is a bit higher level to make it easier to configure buffers depending on the platform.
| Name | Type | Description |
|---|---|---|
renderTarget |
GLGraphics_RenderTarget | |
textureId |
clay.TextureId | * |
width |
Int | * |
height |
Int | * |
depth |
Bool | |
stencil |
Bool | * |
antialiasing |
Int |
blitRenderTargetBuffers(renderTarget: GLGraphics_RenderTarget, width: Int, height: Int): Void| Name | Type |
|---|---|
renderTarget |
GLGraphics_RenderTarget |
width |
Int |
height |
Int |
createRenderTarget(textureId: clay.TextureId, width: Int, height: Int, depth: Bool, stencil: Bool, antialiasing: Int, level: Int, format: clay.TextureFormat, dataType: clay.TextureDataType): clay.RenderTargetCreate a render target from the given settings
| Name | Type | Description |
|---|---|---|
textureId |
clay.TextureId | * |
width |
Int | * |
height |
Int | * |
depth |
Bool | * |
stencil |
Bool | * |
antialiasing |
Int | * |
level |
Int | The level of detail. Level 0 is the base image level. Level n is the nth mipmap reduction image. |
format |
clay.TextureFormat | The texture format (RGBA) |
dataType |
clay.TextureDataType | The data type of the pixel data (UNSIGNED_BYTE) |
| Returns |
|---|
| clay.RenderTarget |
deleteRenderTarget(renderTarget: GLGraphics_RenderTarget): Void| Name | Type |
|---|---|
renderTarget |
GLGraphics_RenderTarget |
setRenderTarget(renderTarget: GLGraphics_RenderTarget): Void| Name | Type |
|---|---|
renderTarget |
GLGraphics_RenderTarget |
enableBlending(): VoiddisableBlending(): VoidcreateShader(vertSource: String, fragSource: String, ?attributes: Array<String>, ?textures: Array<String>): clay.GpuShader| Name | Type | Default |
|---|---|---|
vertSource |
String | |
fragSource |
String | |
attributes |
Array<String> | (optional) |
textures |
Array<String> | (optional) |
| Returns |
|---|
| clay.GpuShader |
linkShader(shader: GLGraphics_GpuShader, ?attributes: Array<String>): Bool| Name | Type | Default |
|---|---|---|
shader |
GLGraphics_GpuShader | |
attributes |
Array<String> | (optional) |
| Returns |
|---|
| Bool |
configureShaderTextureSlots(shader: GLGraphics_GpuShader, textures: Array<String>): Void| Name | Type |
|---|---|
shader |
GLGraphics_GpuShader |
textures |
Array<String> |
useShader(shader: GLGraphics_GpuShader): Void| Name | Type |
|---|---|
shader |
GLGraphics_GpuShader |
deleteShader(shader: GLGraphics_GpuShader): Void| Name | Type |
|---|---|
shader |
GLGraphics_GpuShader |
| Name | Type |
|---|---|
type |
Int |
source |
String |
| Returns |
|---|
| GLShader |
getUniformLocation(shader: clay.GpuShader, name: String): GLUniformLocation| Name | Type |
|---|---|
shader |
clay.GpuShader |
name |
String |
| Returns |
|---|
| GLUniformLocation |
setIntUniform(shader: clay.GpuShader, location: GLUniformLocation, value: Int): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
value |
Int |
setIntArrayUniform(shader: clay.GpuShader, location: GLUniformLocation, value: clay.buffers.Int32Array): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
value |
clay.buffers.Int32Array |
setFloatUniform(shader: clay.GpuShader, location: GLUniformLocation, value: Float): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
value |
Float |
setFloatArrayUniform(shader: clay.GpuShader, location: GLUniformLocation, value: clay.buffers.Float32Array): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
value |
clay.buffers.Float32Array |
setVector2Uniform(shader: clay.GpuShader, location: GLUniformLocation, x: Float, y: Float): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
x |
Float |
y |
Float |
setVector3Uniform(shader: clay.GpuShader, location: GLUniformLocation, x: Float, y: Float, z: Float): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
x |
Float |
y |
Float |
z |
Float |
setVector4Uniform(shader: clay.GpuShader, location: GLUniformLocation, x: Float, y: Float, z: Float, w: Float): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
x |
Float |
y |
Float |
z |
Float |
w |
Float |
setColorUniform(shader: clay.GpuShader, location: GLUniformLocation, r: Float, g: Float, b: Float, a: Float): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
r |
Float |
g |
Float |
b |
Float |
a |
Float |
setMatrix4Uniform(shader: clay.GpuShader, location: GLUniformLocation, value: clay.buffers.Float32Array): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
value |
clay.buffers.Float32Array |
setTexture2dUniform(shader: clay.GpuShader, location: GLUniformLocation, slot: Int, texture: clay.TextureId): Void| Name | Type |
|---|---|
shader |
clay.GpuShader |
location |
GLUniformLocation |
slot |
Int |
texture |
clay.TextureId |
setBlendFuncSeparate(srcRgb: clay.BlendMode, dstRgb: clay.BlendMode, srcAlpha: clay.BlendMode, dstAlpha: clay.BlendMode): Void| Name | Type |
|---|---|
srcRgb |
clay.BlendMode |
dstRgb |
clay.BlendMode |
srcAlpha |
clay.BlendMode |
dstAlpha |
clay.BlendMode |
ensureNoError(): VoidPrivate Members
DEPTH24_STENCIL8: IntDEPTH_COMPONENT24: IntTEXTURE_2D_MULTISAMPLE: IntREAD_FRAMEBUFFER: IntDRAW_FRAMEBUFFER: IntRGBA8: IntCOLOR: IntclearBufferForBlitValues: clay.buffers.Float32Arraysetup(): Void