summaryrefslogtreecommitdiff
path: root/cogl/driver/gles/cogl-gles.c
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2012-05-23 18:19:29 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2012-07-12 17:13:51 +0100
commit5bc56e9f30cdf8cfd62a975c3d20c9463aad76fe (patch)
tree7b2defa496dc92a9957c4070a31cd85c0ad31c57 /cogl/driver/gles/cogl-gles.c
parentff3707e3c065812960680b80a6bc1963d14b3a94 (diff)
downloadcogl-5bc56e9f30cdf8cfd62a975c3d20c9463aad76fe.tar.gz
Support retrieving depth textures from framebufferswip/depth-texture
This commit introduces two new funtions on framebuffers to be able to retrieve the depth buffer as a texture for further usage, say, to implement shadow mapping. The proposed API works as follow: * Before the framebuffer is allocated, you can request that a depth texture is created with cogl_framebuffer_enable_depth_texture() * cogl_framebuffer_get_depth_texture() can then be used to grab a CoglTexture
Diffstat (limited to 'cogl/driver/gles/cogl-gles.c')
-rw-r--r--cogl/driver/gles/cogl-gles.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/cogl/driver/gles/cogl-gles.c b/cogl/driver/gles/cogl-gles.c
index 9e46d12d..8f1e91db 100644
--- a/cogl/driver/gles/cogl-gles.c
+++ b/cogl/driver/gles/cogl-gles.c
@@ -33,6 +33,13 @@
#include "cogl-renderer-private.h"
#include "cogl-private.h"
+#ifndef GL_UNSIGNED_INT_24_8
+#define GL_UNSIGNED_INT_24_8 0x84FA
+#endif
+#ifndef GL_DEPTH_STENCIL
+#define GL_DEPTH_STENCIL 0x84F9
+#endif
+
static CoglBool
_cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
GLenum gl_int_format,
@@ -137,6 +144,35 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
gltype = GL_UNSIGNED_SHORT_5_5_5_1;
break;
+ case COGL_PIXEL_FORMAT_DEPTH_ANY:
+ glintformat = GL_DEPTH_COMPONENT;
+ glformat = GL_DEPTH_COMPONENT;
+ gltype = GL_UNSIGNED_BYTE;
+ break;
+ case COGL_PIXEL_FORMAT_DEPTH_16:
+ glintformat = GL_DEPTH_COMPONENT;
+ glformat = GL_DEPTH_COMPONENT;
+ gltype = GL_UNSIGNED_SHORT;
+ break;
+ case COGL_PIXEL_FORMAT_DEPTH_24:
+ glintformat = GL_DEPTH_COMPONENT;
+ glformat = GL_DEPTH_COMPONENT;
+ gltype = GL_UNSIGNED_INT;
+ break;
+ case COGL_PIXEL_FORMAT_DEPTH_32:
+ glintformat = GL_DEPTH_COMPONENT;
+ glformat = GL_DEPTH_COMPONENT;
+ gltype = GL_UNSIGNED_INT;
+ break;
+
+ case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:
+ /* GLES only supports GL_DEPTH_STENCIL (not GL_DEPTH24_STENCIL8)
+ * as the internal format */
+ glintformat = GL_DEPTH_STENCIL;
+ glformat = GL_DEPTH_STENCIL;
+ gltype = GL_UNSIGNED_INT_24_8;
+ break;
+
case COGL_PIXEL_FORMAT_ANY:
case COGL_PIXEL_FORMAT_YUV:
g_assert_not_reached ();
@@ -247,6 +283,12 @@ _cogl_driver_update_features (CoglContext *context,
COGL_FEATURE_ID_UNSIGNED_INT_INDICES, TRUE);
}
+ if (_cogl_check_extension ("GL_OES_depth_texture", gl_extensions))
+ {
+ flags |= COGL_FEATURE_DEPTH_TEXTURE;
+ COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_DEPTH_TEXTURE, TRUE);
+ }
+
if (_cogl_check_extension ("GL_OES_texture_npot", gl_extensions))
{
flags |= (COGL_FEATURE_TEXTURE_NPOT |