Find a better mechanism to avoid FBO on OpenGL 2.1 if required #1290
This commit is contained in:
parent
feedf332a8
commit
6ec847a93f
1 changed files with 8 additions and 6 deletions
14
src/rlgl.h
14
src/rlgl.h
|
@ -125,6 +125,8 @@
|
||||||
#define GRAPHICS_API_OPENGL_33
|
#define GRAPHICS_API_OPENGL_33
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SUPPORT_RENDER_TEXTURES_HINT
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Defines and Macros
|
// Defines and Macros
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -1379,7 +1381,7 @@ void rlTextureParameters(unsigned int id, int param, int value)
|
||||||
// Enable rendering to texture (fbo)
|
// Enable rendering to texture (fbo)
|
||||||
void rlEnableRenderTexture(unsigned int id)
|
void rlEnableRenderTexture(unsigned int id)
|
||||||
{
|
{
|
||||||
#if !defined(GRAPHICS_API_OPENGL_21) && (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, id);
|
glBindFramebuffer(GL_FRAMEBUFFER, id);
|
||||||
|
|
||||||
//glDisable(GL_CULL_FACE); // Allow double side drawing for texture flipping
|
//glDisable(GL_CULL_FACE); // Allow double side drawing for texture flipping
|
||||||
|
@ -1390,7 +1392,7 @@ void rlEnableRenderTexture(unsigned int id)
|
||||||
// Disable rendering to texture
|
// Disable rendering to texture
|
||||||
void rlDisableRenderTexture(void)
|
void rlDisableRenderTexture(void)
|
||||||
{
|
{
|
||||||
#if !defined(GRAPHICS_API_OPENGL_21) && (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
//glEnable(GL_CULL_FACE);
|
//glEnable(GL_CULL_FACE);
|
||||||
|
@ -1446,7 +1448,7 @@ void rlDeleteTextures(unsigned int id)
|
||||||
// Unload render texture from GPU memory
|
// Unload render texture from GPU memory
|
||||||
void rlDeleteRenderTextures(RenderTexture2D target)
|
void rlDeleteRenderTextures(RenderTexture2D target)
|
||||||
{
|
{
|
||||||
#if !defined(GRAPHICS_API_OPENGL_21) && (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||||
if (target.texture.id > 0) glDeleteTextures(1, &target.texture.id);
|
if (target.texture.id > 0) glDeleteTextures(1, &target.texture.id);
|
||||||
if (target.depth.id > 0)
|
if (target.depth.id > 0)
|
||||||
{
|
{
|
||||||
|
@ -2224,7 +2226,7 @@ RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depth
|
||||||
{
|
{
|
||||||
RenderTexture2D target = { 0 };
|
RenderTexture2D target = { 0 };
|
||||||
|
|
||||||
#if !defined(GRAPHICS_API_OPENGL_21) && (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||||
if (useDepthTexture && RLGL.ExtSupported.texDepth) target.depthTexture = true;
|
if (useDepthTexture && RLGL.ExtSupported.texDepth) target.depthTexture = true;
|
||||||
|
|
||||||
// Create the framebuffer object
|
// Create the framebuffer object
|
||||||
|
@ -2277,7 +2279,7 @@ RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depth
|
||||||
// NOTE: Attach type: 0-Color, 1-Depth renderbuffer, 2-Depth texture
|
// NOTE: Attach type: 0-Color, 1-Depth renderbuffer, 2-Depth texture
|
||||||
void rlRenderTextureAttach(RenderTexture2D target, unsigned int id, int attachType)
|
void rlRenderTextureAttach(RenderTexture2D target, unsigned int id, int attachType)
|
||||||
{
|
{
|
||||||
#if !defined(GRAPHICS_API_OPENGL_21) && (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, target.id);
|
glBindFramebuffer(GL_FRAMEBUFFER, target.id);
|
||||||
|
|
||||||
if (attachType == 0) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id, 0);
|
if (attachType == 0) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, id, 0);
|
||||||
|
@ -2296,7 +2298,7 @@ bool rlRenderTextureComplete(RenderTexture target)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
#if !defined(GRAPHICS_API_OPENGL_21) && (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2))
|
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(SUPPORT_RENDER_TEXTURES_HINT)
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, target.id);
|
glBindFramebuffer(GL_FRAMEBUFFER, target.id);
|
||||||
|
|
||||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue