|
RLAPI void | rlMatrixMode (int mode) |
|
RLAPI void | rlPushMatrix (void) |
|
RLAPI void | rlPopMatrix (void) |
|
RLAPI void | rlLoadIdentity (void) |
|
RLAPI void | rlTranslatef (float x, float y, float z) |
|
RLAPI void | rlRotatef (float angle, float x, float y, float z) |
|
RLAPI void | rlScalef (float x, float y, float z) |
|
RLAPI void | rlMultMatrixf (float *matf) |
|
RLAPI void | rlFrustum (double left, double right, double bottom, double top, double znear, double zfar) |
|
RLAPI void | rlOrtho (double left, double right, double bottom, double top, double znear, double zfar) |
|
RLAPI void | rlViewport (int x, int y, int width, int height) |
|
RLAPI void | rlBegin (int mode) |
|
RLAPI void | rlEnd (void) |
|
RLAPI void | rlVertex2i (int x, int y) |
|
RLAPI void | rlVertex2f (float x, float y) |
|
RLAPI void | rlVertex3f (float x, float y, float z) |
|
RLAPI void | rlTexCoord2f (float x, float y) |
|
RLAPI void | rlNormal3f (float x, float y, float z) |
|
RLAPI void | rlColor4ub (unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
|
RLAPI void | rlColor3f (float x, float y, float z) |
|
RLAPI void | rlColor4f (float x, float y, float z, float w) |
|
RLAPI bool | rlEnableVertexArray (unsigned int vaoId) |
|
RLAPI void | rlDisableVertexArray (void) |
|
RLAPI void | rlEnableVertexBuffer (unsigned int id) |
|
RLAPI void | rlDisableVertexBuffer (void) |
|
RLAPI void | rlEnableVertexBufferElement (unsigned int id) |
|
RLAPI void | rlDisableVertexBufferElement (void) |
|
RLAPI void | rlEnableVertexAttribute (unsigned int index) |
|
RLAPI void | rlDisableVertexAttribute (unsigned int index) |
|
RLAPI void | rlActiveTextureSlot (int slot) |
|
RLAPI void | rlEnableTexture (unsigned int id) |
|
RLAPI void | rlDisableTexture (void) |
|
RLAPI void | rlEnableTextureCubemap (unsigned int id) |
|
RLAPI void | rlDisableTextureCubemap (void) |
|
RLAPI void | rlTextureParameters (unsigned int id, int param, int value) |
|
RLAPI void | rlEnableShader (unsigned int id) |
|
RLAPI void | rlDisableShader (void) |
|
RLAPI void | rlEnableFramebuffer (unsigned int id) |
|
RLAPI void | rlDisableFramebuffer (void) |
|
RLAPI void | rlActiveDrawBuffers (int count) |
|
RLAPI void | rlEnableColorBlend (void) |
|
RLAPI void | rlDisableColorBlend (void) |
|
RLAPI void | rlEnableDepthTest (void) |
|
RLAPI void | rlDisableDepthTest (void) |
|
RLAPI void | rlEnableDepthMask (void) |
|
RLAPI void | rlDisableDepthMask (void) |
|
RLAPI void | rlEnableBackfaceCulling (void) |
|
RLAPI void | rlDisableBackfaceCulling (void) |
|
RLAPI void | rlEnableScissorTest (void) |
|
RLAPI void | rlDisableScissorTest (void) |
|
RLAPI void | rlScissor (int x, int y, int width, int height) |
|
RLAPI void | rlEnableWireMode (void) |
|
RLAPI void | rlDisableWireMode (void) |
|
RLAPI void | rlSetLineWidth (float width) |
|
RLAPI float | rlGetLineWidth (void) |
|
RLAPI void | rlEnableSmoothLines (void) |
|
RLAPI void | rlDisableSmoothLines (void) |
|
RLAPI void | rlEnableStereoRender (void) |
|
RLAPI void | rlDisableStereoRender (void) |
|
RLAPI bool | rlIsStereoRenderEnabled (void) |
|
RLAPI void | rlClearColor (unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
|
RLAPI void | rlClearScreenBuffers (void) |
|
RLAPI void | rlCheckErrors (void) |
|
RLAPI void | rlSetBlendMode (int mode) |
|
RLAPI void | rlSetBlendFactors (int glSrcFactor, int glDstFactor, int glEquation) |
|
RLAPI void | rlglInit (int width, int height) |
|
RLAPI void | rlglClose (void) |
|
RLAPI void | rlLoadExtensions (void *loader) |
|
RLAPI int | rlGetVersion (void) |
|
RLAPI void | rlSetFramebufferWidth (int width) |
|
RLAPI int | rlGetFramebufferWidth (void) |
|
RLAPI void | rlSetFramebufferHeight (int height) |
|
RLAPI int | rlGetFramebufferHeight (void) |
|
RLAPI unsigned int | rlGetTextureIdDefault (void) |
|
RLAPI unsigned int | rlGetShaderIdDefault (void) |
|
RLAPI int * | rlGetShaderLocsDefault (void) |
|
RLAPI rlRenderBatch | rlLoadRenderBatch (int numBuffers, int bufferElements) |
|
RLAPI void | rlUnloadRenderBatch (rlRenderBatch batch) |
|
RLAPI void | rlDrawRenderBatch (rlRenderBatch *batch) |
|
RLAPI void | rlSetRenderBatchActive (rlRenderBatch *batch) |
|
RLAPI void | rlDrawRenderBatchActive (void) |
|
RLAPI bool | rlCheckRenderBatchLimit (int vCount) |
|
RLAPI void | rlSetTexture (unsigned int id) |
|
RLAPI unsigned int | rlLoadVertexArray (void) |
|
RLAPI unsigned int | rlLoadVertexBuffer (const void *buffer, int size, bool dynamic) |
|
RLAPI unsigned int | rlLoadVertexBufferElement (const void *buffer, int size, bool dynamic) |
|
RLAPI void | rlUpdateVertexBuffer (unsigned int bufferId, const void *data, int dataSize, int offset) |
|
RLAPI void | rlUpdateVertexBufferElements (unsigned int id, const void *data, int dataSize, int offset) |
|
RLAPI void | rlUnloadVertexArray (unsigned int vaoId) |
|
RLAPI void | rlUnloadVertexBuffer (unsigned int vboId) |
|
RLAPI void | rlSetVertexAttribute (unsigned int index, int compSize, int type, bool normalized, int stride, const void *pointer) |
|
RLAPI void | rlSetVertexAttributeDivisor (unsigned int index, int divisor) |
|
RLAPI void | rlSetVertexAttributeDefault (int locIndex, const void *value, int attribType, int count) |
|
RLAPI void | rlDrawVertexArray (int offset, int count) |
|
RLAPI void | rlDrawVertexArrayElements (int offset, int count, const void *buffer) |
|
RLAPI void | rlDrawVertexArrayInstanced (int offset, int count, int instances) |
|
RLAPI void | rlDrawVertexArrayElementsInstanced (int offset, int count, const void *buffer, int instances) |
|
RLAPI unsigned int | rlLoadTexture (const void *data, int width, int height, int format, int mipmapCount) |
|
RLAPI unsigned int | rlLoadTextureDepth (int width, int height, bool useRenderBuffer) |
|
RLAPI unsigned int | rlLoadTextureCubemap (const void *data, int size, int format) |
|
RLAPI void | rlUpdateTexture (unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data) |
|
RLAPI void | rlGetGlTextureFormats (int format, int *glInternalFormat, int *glFormat, int *glType) |
|
RLAPI const char * | rlGetPixelFormatName (unsigned int format) |
|
RLAPI void | rlUnloadTexture (unsigned int id) |
|
RLAPI void | rlGenTextureMipmaps (unsigned int id, int width, int height, int format, int *mipmaps) |
|
RLAPI void * | rlReadTexturePixels (unsigned int id, int width, int height, int format) |
|
RLAPI unsigned char * | rlReadScreenPixels (int width, int height) |
|
RLAPI unsigned int | rlLoadFramebuffer (int width, int height) |
|
RLAPI void | rlFramebufferAttach (unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel) |
|
RLAPI bool | rlFramebufferComplete (unsigned int id) |
|
RLAPI void | rlUnloadFramebuffer (unsigned int id) |
|
RLAPI unsigned int | rlLoadShaderCode (const char *vsCode, const char *fsCode) |
|
RLAPI unsigned int | rlCompileShader (const char *shaderCode, int type) |
|
RLAPI unsigned int | rlLoadShaderProgram (unsigned int vShaderId, unsigned int fShaderId) |
|
RLAPI void | rlUnloadShaderProgram (unsigned int id) |
|
RLAPI int | rlGetLocationUniform (unsigned int shaderId, const char *uniformName) |
|
RLAPI int | rlGetLocationAttrib (unsigned int shaderId, const char *attribName) |
|
RLAPI void | rlSetUniform (int locIndex, const void *value, int uniformType, int count) |
|
RLAPI void | rlSetUniformMatrix (int locIndex, Matrix mat) |
|
RLAPI void | rlSetUniformSampler (int locIndex, unsigned int textureId) |
|
RLAPI void | rlSetShader (unsigned int id, int *locs) |
|
RLAPI unsigned int | rlLoadComputeShaderProgram (unsigned int shaderId) |
|
RLAPI void | rlComputeShaderDispatch (unsigned int groupX, unsigned int groupY, unsigned int groupZ) |
|
RLAPI unsigned int | rlLoadShaderBuffer (unsigned long long size, const void *data, int usageHint) |
|
RLAPI void | rlUnloadShaderBuffer (unsigned int ssboId) |
|
RLAPI void | rlUpdateShaderBufferElements (unsigned int id, const void *data, unsigned long long dataSize, unsigned long long offset) |
|
RLAPI unsigned long long | rlGetShaderBufferSize (unsigned int id) |
|
RLAPI void | rlReadShaderBufferElements (unsigned int id, void *dest, unsigned long long count, unsigned long long offset) |
|
RLAPI void | rlBindShaderBuffer (unsigned int id, unsigned int index) |
|
RLAPI void | rlCopyBuffersElements (unsigned int destId, unsigned int srcId, unsigned long long destOffset, unsigned long long srcOffset, unsigned long long count) |
|
RLAPI void | rlBindImageTexture (unsigned int id, unsigned int index, unsigned int format, int readonly) |
|
RLAPI Matrix | rlGetMatrixModelview (void) |
|
RLAPI Matrix | rlGetMatrixProjection (void) |
|
RLAPI Matrix | rlGetMatrixTransform (void) |
|
RLAPI Matrix | rlGetMatrixProjectionStereo (int eye) |
|
RLAPI Matrix | rlGetMatrixViewOffsetStereo (int eye) |
|
RLAPI void | rlSetMatrixProjection (Matrix proj) |
|
RLAPI void | rlSetMatrixModelview (Matrix view) |
|
RLAPI void | rlSetMatrixProjectionStereo (Matrix right, Matrix left) |
|
RLAPI void | rlSetMatrixViewOffsetStereo (Matrix right, Matrix left) |
|
RLAPI void | rlLoadDrawCube (void) |
|
RLAPI void | rlLoadDrawQuad (void) |
|
#define RLGL_VERSION "4.0" |
rlgl v4.0 - A multi-OpenGL abstraction layer with an immediate-mode style API
An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0) that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
When chosing an OpenGL backend different than OpenGL 1.1, some internal buffer are initialized on rlglInit() to accumulate vertex data.
When an internal state change is required all the stored vertex data is renderer in batch, additioanlly, rlDrawRenderBatchActive() could be called to force flushing of the batch.
Some additional resources are also loaded for convenience, here the complete list:
- Default batch (RLGL.defaultBatch): RenderBatch system to accumulate vertex data
- Default texture (RLGL.defaultTextureId): 1x1 white pixel R8G8B8A8
- Default shader (RLGL.State.defaultShaderId, RLGL.State.defaultShaderLocs)
Internal buffer (and additional resources) must be manually unloaded calling rlglClose().
CONFIGURATION:
#define GRAPHICS_API_OPENGL_11 #define GRAPHICS_API_OPENGL_21 #define GRAPHICS_API_OPENGL_33 #define GRAPHICS_API_OPENGL_43 #define GRAPHICS_API_OPENGL_ES2 Use selected OpenGL graphics backend, should be supported by platform Those preprocessor defines are only used on rlgl module, if OpenGL version is required by any other module, use rlGetVersion() to check it
#define RLGL_IMPLEMENTATION Generates the implementation of the library into the included file. If not defined, the library is in header only mode and can be included in other headers or source files without problems. But only ONE file should hold the implementation.
#define RLGL_RENDER_TEXTURES_HINT Enable framebuffer objects (fbo) support (enabled by default) Some GPUs could not support them despite the OpenGL version
#define RLGL_SHOW_GL_DETAILS_INFO Show OpenGL extensions and capabilities detailed logs on init
#define RLGL_ENABLE_OPENGL_DEBUG_CONTEXT Enable debug context (only available on OpenGL 4.3)
rlgl capabilities could be customized just defining some internal values before library inclusion (default values listed):
#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 8192 // Default internal render batch elements limits #define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) #define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) #define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported #define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance #define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance
When loading a shader, the following vertex attribute and uniform location names are tried to be set automatically:
#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Binded by default to shader location: 0 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Binded by default to shader location: 1 #define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Binded by default to shader location: 2 #define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Binded by default to shader location: 3 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Binded by default to shader location: 4 #define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Binded by default to shader location: 5 #define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix #define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix #define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix #define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix #define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)) #define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) #define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2)
DEPENDENCIES:
- OpenGL libraries (depending on platform and OpenGL version selected)
- GLAD OpenGL extensions loading library (only for OpenGL 3.3 Core, 4.3 Core)
LICENSE: zlib/libpng
Copyright (c) 2014-2022 Ramon Santamaria (@raysan5)
This software is provided "as-is", without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
- The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
- Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
- This notice may not be removed or altered from any source distribution.
Definition at line 110 of file rlgl.h.