aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-04-10 19:38:57 +0200
committerraysan5 <raysan5@gmail.com>2016-04-10 19:38:57 +0200
commit284eaf157692469e061782fbf3753e22ee5eb861 (patch)
tree4ba0edfb149f94af1b5608a7df65e24010cc856e /src
parentc1e49d2b13c75da2c532079d454fad32f9ceccd4 (diff)
downloadraylib-284eaf157692469e061782fbf3753e22ee5eb861.tar.gz
raylib-284eaf157692469e061782fbf3753e22ee5eb861.zip
Use Depth Texture on OpenGL 3.3
Diffstat (limited to 'src')
-rw-r--r--src/rlgl.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/rlgl.c b/src/rlgl.c
index f0acf124..b659577a 100644
--- a/src/rlgl.c
+++ b/src/rlgl.c
@@ -1688,7 +1688,7 @@ RenderTexture2D rlglLoadRenderTexture(int width, int height)
target.depth.id = 0;
target.depth.width = width;
target.depth.height = height;
- target.depth.format = 19; //DEPTH_COMPONENT_16BIT
+ target.depth.format = 19; //DEPTH_COMPONENT_24BIT
target.depth.mipmaps = 1;
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
@@ -1701,14 +1701,18 @@ RenderTexture2D rlglLoadRenderTexture(int width, int height)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
-
-#define USE_DEPTH_RENDERBUFFER
+
+#if defined(GRAPHICS_API_OPENGL_33)
+ #define USE_DEPTH_TEXTURE
+#else
+ #define USE_DEPTH_RENDERBUFFER
+#endif
+
#if defined(USE_DEPTH_RENDERBUFFER)
// Create the renderbuffer that will serve as the depth attachment for the framebuffer.
glGenRenderbuffers(1, &target.depth.id);
glBindRenderbuffer(GL_RENDERBUFFER, target.depth.id);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
-
#elif defined(USE_DEPTH_TEXTURE)
// NOTE: We can also use a texture for depth buffer (GL_ARB_depth_texture/GL_OES_depth_texture extension required)
// A renderbuffer is simpler than a texture and could offer better performance on embedded devices
@@ -1718,7 +1722,7 @@ RenderTexture2D rlglLoadRenderTexture(int width, int height)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
#endif