molecular
|
Interface to OpenGL. More...
#include <GlCommandSink.h>
Classes | |
class | IndexBuffer |
Buffer storing index data. More... | |
class | Program |
Compiled shader program. More... | |
class | RenderTarget |
Allows for rendering to textures. More... | |
class | Texture |
Texture object. More... | |
class | TransformFeedback |
class | VertexBuffer |
Buffer storing vertex data. More... | |
Public Types | |
enum | BlendFactor { kOne = GL_ONE, kSrcAlpha = GL_SRC_ALPHA, kOneMinusSrcAlpha = GL_ONE_MINUS_SRC_ALPHA } |
enum | CompareOp { kNever = GL_NEVER, kLess = GL_LESS, kEqual = GL_EQUAL, kLessOrEqual = GL_LEQUAL, kGreater = GL_GREATER, kNotEqual = GL_NOTEQUAL, kGreaterOrEqual = GL_GEQUAL, kAlways = GL_ALWAYS } |
enum | CullMode { kFront = GL_FRONT, kBack = GL_BACK } |
Public Member Functions | |
void | Init () |
Initialise. More... | |
VertexBuffer * | CreateVertexBuffer () |
void | DestroyVertexBuffer (VertexBuffer *buffer) |
IndexBuffer * | CreateIndexBuffer () |
Create IndexBuffer. More... | |
void | DestroyIndexBuffer (IndexBuffer *buffer) |
Texture * | CreateTexture () |
void | DestroyTexture (Texture *texture) |
Program * | CreateProgram () |
Create shader program. More... | |
void | DestroyProgram (Program *program) |
Destroy shader program. More... | |
void | UseProgram (Program *program) |
Make program current. More... | |
RenderTarget * | CreateRenderTarget () |
void | DestroyRenderTarget (RenderTarget *target) |
void | SetTarget (RenderTarget *target) |
Set render target. More... | |
RenderTarget * | GetTarget () |
void | SetBaseTarget (const IntVector4 &viewport, int renderTarget) |
TransformFeedback * | CreateTransformFeedback () |
void | DestroyTransformFeedback (TransformFeedback *feedback) |
void | SetBackgroundColor (float r, float g, float b, float a=1.0f) |
void | Clear (bool color=true, bool depth=true) |
Clear current render target. More... | |
void | Draw (IndexBuffer *buffer, const IndexBufferInfo &info) |
Draw indices. More... | |
void | Draw (TransformFeedback *transformFeedback, IndexBufferInfo::Mode mode) |
void | Draw (IndexBufferInfo::Mode mode, unsigned int count) |
Draw vertices without indices. More... | |
void | ReadPixels (int x, int y, int width, int height, PixelFormat format, void *data) |
void | SetBlending (bool enable, BlendFactor sourceFactor=kSrcAlpha, BlendFactor destFactor=kOneMinusSrcAlpha) |
void | SetDepthState (bool depthTest, bool depthWrite, CompareOp compareOp=kLess) |
void | SetScissor (bool enable, int x=0, int y=0, int width=0, int height=0) |
void | SetRasterizationState (bool rasterizerDiscard, CullMode cullMode=kBack) |
Static Public Member Functions | |
static void | CheckError (const char *function, int line, const char *file) |
Static Public Attributes | |
static GlFunctions | gl |
Interface to OpenGL.
The constructor can be called outside the renderer thread. After construction, Init() must be called. Init() can only be called inside the renderer thread.
|
inlinestatic |
void molecular::gfx::GlCommandSink::Clear | ( | bool | color = true , |
bool | depth = true |
||
) |
Clear current render target.
|
inline |
Create IndexBuffer.
GlCommandSink::Program * molecular::gfx::GlCommandSink::CreateProgram | ( | ) |
Create shader program.
Call DestroyProgram after being finished with the program.
GlCommandSink::RenderTarget * molecular::gfx::GlCommandSink::CreateRenderTarget | ( | ) |
GlCommandSink::Texture * molecular::gfx::GlCommandSink::CreateTexture | ( | ) |
GlCommandSink::TransformFeedback * molecular::gfx::GlCommandSink::CreateTransformFeedback | ( | ) |
|
inline |
|
inline |
void molecular::gfx::GlCommandSink::DestroyProgram | ( | Program * | program | ) |
Destroy shader program.
void molecular::gfx::GlCommandSink::DestroyRenderTarget | ( | RenderTarget * | target | ) |
void molecular::gfx::GlCommandSink::DestroyTexture | ( | Texture * | texture | ) |
void molecular::gfx::GlCommandSink::DestroyTransformFeedback | ( | TransformFeedback * | feedback | ) |
|
inline |
void molecular::gfx::GlCommandSink::Draw | ( | IndexBuffer * | buffer, |
const IndexBufferInfo & | info | ||
) |
void molecular::gfx::GlCommandSink::Draw | ( | TransformFeedback * | transformFeedback, |
IndexBufferInfo::Mode | mode | ||
) |
void molecular::gfx::GlCommandSink::Draw | ( | IndexBufferInfo::Mode | mode, |
unsigned int | count | ||
) |
Draw vertices without indices.
Requires active program.
|
inline |
void molecular::gfx::GlCommandSink::Init | ( | ) |
Initialise.
This must be called in the renderer thread.
void molecular::gfx::GlCommandSink::ReadPixels | ( | int | x, |
int | y, | ||
int | width, | ||
int | height, | ||
PixelFormat | format, | ||
void * | data | ||
) |
|
inline |
void molecular::gfx::GlCommandSink::SetBaseTarget | ( | const IntVector4 & | viewport, |
int | renderTarget | ||
) |
Registers the currently bound framebuffer as the base target. In the simplest case this will be 0, which is the screen.
void molecular::gfx::GlCommandSink::SetBlending | ( | bool | enable, |
BlendFactor | sourceFactor = kSrcAlpha , |
||
BlendFactor | destFactor = kOneMinusSrcAlpha |
||
) |
void molecular::gfx::GlCommandSink::SetDepthState | ( | bool | depthTest, |
bool | depthWrite, | ||
CompareOp | compareOp = kLess |
||
) |
void molecular::gfx::GlCommandSink::SetRasterizationState | ( | bool | rasterizerDiscard, |
CullMode | cullMode = kBack |
||
) |
void molecular::gfx::GlCommandSink::SetScissor | ( | bool | enable, |
int | x = 0 , |
||
int | y = 0 , |
||
int | width = 0 , |
||
int | height = 0 |
||
) |
void molecular::gfx::GlCommandSink::SetTarget | ( | RenderTarget * | target | ) |
Set render target.
Pass nullptr to render to the base target. The base target can be specified with SetBaseTarget.
void molecular::gfx::GlCommandSink::UseProgram | ( | Program * | program | ) |
Make program current.
Also call before setting uniforms.
|
static |