|
|
|
@ -37,10 +37,6 @@ |
|
|
|
* 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 |
|
|
|
* |
|
|
|
@ -196,10 +192,6 @@ |
|
|
|
#define GRAPHICS_API_OPENGL_ES2 |
|
|
|
#endif |
|
|
|
|
|
|
|
// Support framebuffer objects by default |
|
|
|
// NOTE: Some driver implementation do not support it, despite they should |
|
|
|
#define RLGL_RENDER_TEXTURES_HINT |
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
// Defines and Macros |
|
|
|
//---------------------------------------------------------------------------------- |
|
|
|
@ -1863,7 +1855,7 @@ void rlDisableShader(void) |
|
|
|
// Enable rendering to texture (fbo) |
|
|
|
void rlEnableFramebuffer(unsigned int id) |
|
|
|
{ |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, id); |
|
|
|
#endif |
|
|
|
} |
|
|
|
@ -1872,7 +1864,7 @@ void rlEnableFramebuffer(unsigned int id) |
|
|
|
unsigned int rlGetActiveFramebuffer(void) |
|
|
|
{ |
|
|
|
GLint fboId = 0; |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) |
|
|
|
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &fboId); |
|
|
|
#endif |
|
|
|
return fboId; |
|
|
|
@ -1881,7 +1873,7 @@ unsigned int rlGetActiveFramebuffer(void) |
|
|
|
// Disable rendering to texture |
|
|
|
void rlDisableFramebuffer(void) |
|
|
|
{ |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
|
|
#endif |
|
|
|
} |
|
|
|
@ -1889,7 +1881,7 @@ void rlDisableFramebuffer(void) |
|
|
|
// Blit active framebuffer to main framebuffer |
|
|
|
void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int bufferMask) |
|
|
|
{ |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) |
|
|
|
glBlitFramebuffer(srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight, bufferMask, GL_NEAREST); |
|
|
|
#endif |
|
|
|
} |
|
|
|
@ -1897,7 +1889,7 @@ void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX |
|
|
|
// Bind framebuffer object (fbo) |
|
|
|
void rlBindFramebuffer(unsigned int target, unsigned int framebuffer) |
|
|
|
{ |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
|
|
glBindFramebuffer(target, framebuffer); |
|
|
|
#endif |
|
|
|
} |
|
|
|
@ -1906,7 +1898,7 @@ void rlBindFramebuffer(unsigned int target, unsigned int framebuffer) |
|
|
|
// NOTE: One color buffer is always active by default |
|
|
|
void rlActiveDrawBuffers(int count) |
|
|
|
{ |
|
|
|
#if ((defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) && defined(RLGL_RENDER_TEXTURES_HINT)) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) |
|
|
|
// NOTE: Maximum number of draw buffers supported is implementation dependant, |
|
|
|
// it can be queried with glGet*() but it must be at least 8 |
|
|
|
//GLint maxDrawBuffers = 0; |
|
|
|
@ -3826,7 +3818,7 @@ unsigned int rlLoadFramebuffer(void) |
|
|
|
unsigned int fboId = 0; |
|
|
|
if (!isGpuReady) { TRACELOG(RL_LOG_WARNING, "GL: GPU is not ready to load data, trying to load before InitWindow()?"); return fboId; } |
|
|
|
|
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
|
|
glGenFramebuffers(1, &fboId); // Create the framebuffer object |
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind any framebuffer |
|
|
|
#endif |
|
|
|
@ -3838,7 +3830,7 @@ unsigned int rlLoadFramebuffer(void) |
|
|
|
// NOTE: Attach type: 0-Color, 1-Depth renderbuffer, 2-Depth texture |
|
|
|
void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel) |
|
|
|
{ |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, fboId); |
|
|
|
|
|
|
|
switch (attachType) |
|
|
|
@ -3878,7 +3870,7 @@ bool rlFramebufferComplete(unsigned int id) |
|
|
|
{ |
|
|
|
bool result = false; |
|
|
|
|
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, id); |
|
|
|
|
|
|
|
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); |
|
|
|
@ -3909,7 +3901,7 @@ bool rlFramebufferComplete(unsigned int id) |
|
|
|
// NOTE: All attached textures/cubemaps/renderbuffers are also deleted |
|
|
|
void rlUnloadFramebuffer(unsigned int id) |
|
|
|
{ |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) |
|
|
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) |
|
|
|
// Query depth attachment to automatically delete texture/renderbuffer |
|
|
|
int depthType = 0, depthId = 0; |
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, id); // Bind framebuffer to query depth texture type |
|
|
|
|