VISU - PHP Game Framework

GLState
in package

You probably will rise an eyebrow over this one.

OpenGL is a state machine, with a global state. So why pass around a state object with seemingly redundant information? Well reading information back from OpenGL can result in a synchronous call to the GPU, and this is a performance hit. Because this library aims to be a high level wrapper and collection of components we do some sanity checks to avoid redundant calls to OpenGL. To do these checks we need to know the current state, this where this object comes in.

Additionally as this library tries to be a bit more OOP then the OpenGL API having this object makes the dependency on the OpenGL state more clear.

Table of Contents

Properties

$currentDrawFramebuffer  : int
Currently bound DRAW framebuffer object
$currentIndexBuffer  : int
Currently bound index buffer object
$currentProgram  : int
Currently used shader program object.
$currentReadFramebuffer  : int
Currently bound READ framebuffer object
$currentTexture  : int
Currently bound texture object
$currentTextureUnit  : int
Currently bound texture unit
$currentVertexArray  : int
Currently bound vertex array object
$currentVertexArrayBuffer  : int
Currently bound vertex buffer object

Methods

bindIndexBuffer()  : void
State aware bind of a index buffer object.
bindVertexArray()  : void
State aware bind of a vertex array object.
bindVertexArrayBuffer()  : void
State aware bind of a vertex buffer object.
reset()  : void
Resets the state of this object.

Properties

$currentDrawFramebuffer

Currently bound DRAW framebuffer object

public int $currentDrawFramebuffer = 0

Note: You should never manually manipulate this value.

$currentIndexBuffer

Currently bound index buffer object

public int $currentIndexBuffer = 0

Note: You should never manually manipulate this value.

$currentProgram

Currently used shader program object.

public int $currentProgram = 0

Note: You should never manually manipulate this value.

$currentReadFramebuffer

Currently bound READ framebuffer object

public int $currentReadFramebuffer = 0

Note: You should never manually manipulate this value.

$currentTexture

Currently bound texture object

public int $currentTexture = 0

Note: You should never manually manipulate this value.

$currentTextureUnit

Currently bound texture unit

public int $currentTextureUnit = 0

Note: You should never manually manipulate this value.

$currentVertexArray

Currently bound vertex array object

public int $currentVertexArray = 0

Note: You should never manually manipulate this value.

$currentVertexArrayBuffer

Currently bound vertex buffer object

public int $currentVertexArrayBuffer = 0

Note: You should never manually manipulate this value.

Methods

bindIndexBuffer()

State aware bind of a index buffer object.

public bindIndexBuffer(int $ibo) : void

This method will only call glBindBuffer if the passed ibo is not the currently bound one. Use this method instead of glBindBuffer to avoid redundant calls to OpenGL.

This obviously only works if you use this class to manage your GL state. This is more costly then just calling glBindBuffer...

Parameters
$ibo : int

The index buffer object to bind.

bindVertexArray()

State aware bind of a vertex array object.

public bindVertexArray(int $vao) : void

This method will only call glBindVertexArray if the passed vao is not the currently bound one. Use this method instead of glBindVertexArray to avoid redundant calls to OpenGL.

This obviously only works if you use this class to manage your GL state. This is more costly then just calling glBindVertexArray...

Parameters
$vao : int

The vertex array object to bind.

bindVertexArrayBuffer()

State aware bind of a vertex buffer object.

public bindVertexArrayBuffer(int $vbo) : void

This method will only call glBindBuffer if the passed vbo is not the currently bound one. Use this method instead of glBindBuffer to avoid redundant calls to OpenGL.

This obviously only works if you use this class to manage your GL state. This is more costly then just calling glBindBuffer...

Parameters
$vbo : int

The vertex buffer object to bind.

reset()

Resets the state of this object.

public reset() : void

        
On this page

Search results