|
|
@ -8,17 +8,17 @@ |
|
|
|
* |
|
|
|
* ADDITIONAL NOTES: |
|
|
|
* When choosing an OpenGL backend different than OpenGL 1.1, some internal buffer are |
|
|
|
* initialized on rlglInit() to accumulate vertex data. |
|
|
|
* initialized on rlglInit() to accumulate vertex data |
|
|
|
* |
|
|
|
* When an internal state change is required all the stored vertex data is renderer in batch, |
|
|
|
* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch. |
|
|
|
* additionally, rlDrawRenderBatchActive() could be called to force flushing of the batch |
|
|
|
* |
|
|
|
* Some 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 resources) must be manually unloaded calling rlglClose(). |
|
|
|
* Internal buffer (and resources) must be manually unloaded calling rlglClose() |
|
|
|
* |
|
|
|
* CONFIGURATION: |
|
|
|
* #define GRAPHICS_API_OPENGL_11 |
|
|
@ -32,9 +32,9 @@ |
|
|
|
* required by any other module, use rlGetVersion() to check it |
|
|
|
* |
|
|
|
* #define RLGL_IMPLEMENTATION |
|
|
|
* Generates the implementation of the library into the included file. |
|
|
|
* 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. |
|
|
|
* 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) |
|
|
@ -1503,8 +1503,8 @@ void rlVertex3f(float x, float y, float z) |
|
|
|
tz = RLGL.State.transform.m2*x + RLGL.State.transform.m6*y + RLGL.State.transform.m10*z + RLGL.State.transform.m14; |
|
|
|
} |
|
|
|
|
|
|
|
// WARNING: We can't break primitives when launching a new batch. |
|
|
|
// RL_LINES comes in pairs, RL_TRIANGLES come in groups of 3 vertices and RL_QUADS come in groups of 4 vertices. |
|
|
|
// WARNING: We can't break primitives when launching a new batch |
|
|
|
// RL_LINES comes in pairs, RL_TRIANGLES come in groups of 3 vertices and RL_QUADS come in groups of 4 vertices |
|
|
|
// We must check current draw.mode when a new vertex is required and finish the batch only if the draw.mode draw.vertexCount is %2, %3 or %4 |
|
|
|
if (RLGL.State.vertexCounter > (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4)) |
|
|
|
{ |
|
|
@ -2933,11 +2933,11 @@ void rlDrawRenderBatch(rlRenderBatch *batch) |
|
|
|
glBufferSubData(GL_ARRAY_BUFFER, 0, RLGL.State.vertexCounter*4*sizeof(unsigned char), batch->vertexBuffer[batch->currentBuffer].colors); |
|
|
|
//glBufferData(GL_ARRAY_BUFFER, sizeof(float)*4*4*batch->vertexBuffer[batch->currentBuffer].elementCount, batch->vertexBuffer[batch->currentBuffer].colors, GL_DYNAMIC_DRAW); // Update all buffer |
|
|
|
|
|
|
|
// NOTE: glMapBuffer() causes sync issue. |
|
|
|
// If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job. |
|
|
|
// To avoid waiting (idle), you can call first glBufferData() with NULL pointer before glMapBuffer(). |
|
|
|
// NOTE: glMapBuffer() causes sync issue |
|
|
|
// If GPU is working with this buffer, glMapBuffer() will wait(stall) until GPU to finish its job |
|
|
|
// To avoid waiting (idle), you can call first glBufferData() with NULL pointer before glMapBuffer() |
|
|
|
// If you do that, the previous data in PBO will be discarded and glMapBuffer() returns a new |
|
|
|
// allocated pointer immediately even if GPU is still working with the previous data. |
|
|
|
// allocated pointer immediately even if GPU is still working with the previous data |
|
|
|
|
|
|
|
// Another option: map the buffer object into client's memory |
|
|
|
// Probably this code could be moved somewhere else... |
|
|
@ -2990,7 +2990,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch) |
|
|
|
} |
|
|
|
|
|
|
|
// WARNING: For the following setup of the view, model, and normal matrices, it is expected that |
|
|
|
// transformations and rendering occur between rlPushMatrix and rlPopMatrix. |
|
|
|
// transformations and rendering occur between rlPushMatrix() and rlPopMatrix() |
|
|
|
|
|
|
|
if (RLGL.State.currentShaderLocs[RL_SHADER_LOC_MATRIX_VIEW] != -1) |
|
|
|
{ |
|
|
@ -3622,8 +3622,8 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format) |
|
|
|
//glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height); |
|
|
|
//glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format); |
|
|
|
|
|
|
|
// NOTE: Each row written to or read from by OpenGL pixel operations like glGetTexImage are aligned to a 4 byte boundary by default, which may add some padding. |
|
|
|
// Use glPixelStorei to modify padding with the GL_[UN]PACK_ALIGNMENT setting. |
|
|
|
// NOTE: Each row written to or read from by OpenGL pixel operations like glGetTexImage are aligned to a 4 byte boundary by default, which may add some padding |
|
|
|
// Use glPixelStorei to modify padding with the GL_[UN]PACK_ALIGNMENT setting |
|
|
|
// GL_PACK_ALIGNMENT affects operations that read from OpenGL memory (glReadPixels, glGetTexImage, etc.) |
|
|
|
// GL_UNPACK_ALIGNMENT affects operations that write to OpenGL memory (glTexImage, etc.) |
|
|
|
glPixelStorei(GL_PACK_ALIGNMENT, 1); |
|
|
@ -3644,7 +3644,7 @@ void *rlReadTexturePixels(unsigned int id, int width, int height, int format) |
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
// glGetTexImage() is not available on OpenGL ES 2.0 |
|
|
|
// Texture width and height are required on OpenGL ES 2.0. There is no way to get it from texture id. |
|
|
|
// Texture width and height are required on OpenGL ES 2.0, there is no way to get it from texture id |
|
|
|
// Two possible Options: |
|
|
|
// 1 - Bind texture to color fbo attachment and glReadPixels() |
|
|
|
// 2 - Create an fbo, activate it, render quad with texture, glReadPixels() |
|
|
@ -3810,7 +3810,7 @@ void rlUnloadFramebuffer(unsigned int id) |
|
|
|
else if (depthType == GL_TEXTURE) glDeleteTextures(1, &depthIdU); |
|
|
|
|
|
|
|
// NOTE: If a texture object is deleted while its image is attached to the *currently bound* framebuffer, |
|
|
|
// the texture image is automatically detached from the currently bound framebuffer. |
|
|
|
// the texture image is automatically detached from the currently bound framebuffer |
|
|
|
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
|
|
glDeleteFramebuffers(1, &id); |
|
|
@ -4253,7 +4253,7 @@ unsigned int rlLoadShaderProgram(unsigned int vShaderId, unsigned int fShaderId) |
|
|
|
else |
|
|
|
{ |
|
|
|
// Get the size of compiled shader program (not available on OpenGL ES 2.0) |
|
|
|
// NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero. |
|
|
|
// NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero |
|
|
|
//GLint binarySize = 0; |
|
|
|
//glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize); |
|
|
|
|
|
|
@ -4447,7 +4447,7 @@ unsigned int rlLoadComputeShaderProgram(unsigned int shaderId) |
|
|
|
else |
|
|
|
{ |
|
|
|
// Get the size of compiled shader program (not available on OpenGL ES 2.0) |
|
|
|
// NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero. |
|
|
|
// NOTE: If GL_LINK_STATUS is GL_FALSE, program binary length is zero |
|
|
|
//GLint binarySize = 0; |
|
|
|
//glGetProgramiv(id, GL_PROGRAM_BINARY_LENGTH, &binarySize); |
|
|
|
|
|
|
|