--- gstgldisplay.c	2010-03-02 10:47:24.861025000 +0100
+++ /home/pierre/gst-plugins-gl/gst-libs/gst/gl/gstgldisplay.c	2010-03-08 11:07:05.281165910 +0100
@@ -1189,13 +1189,9 @@ gst_gl_display_thread_init_download (Gst
         glGenRenderbuffersEXT (1, &display->download_depth_buffer);
         glBindRenderbufferEXT (GL_RENDERBUFFER_EXT,
             display->download_depth_buffer);
-#ifndef OPENGL_ES2
-        glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
-            display->download_width, display->download_height);
-#else
-        glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
-            display->download_width, display->download_height);
-#endif
+	glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
+	    display->download_width, display->download_height);
+	
 
         //setup a first texture to render to
         glGenTextures (1, &display->download_texture);
@@ -1279,6 +1275,10 @@ gst_gl_display_thread_init_download (Gst
         glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
             GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT,
             display->download_depth_buffer);
+        glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
+            GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT,
+            display->download_depth_buffer);
+
 
         gst_gl_display_check_framebuffer_status ();
 
@@ -1558,13 +1558,8 @@ gst_gl_display_thread_gen_fbo (GstGLDisp
   //setup the render buffer for depth
   glGenRenderbuffersEXT (1, &display->generated_depth_buffer);
   glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, display->generated_depth_buffer);
-#ifndef OPENGL_ES2
-  glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
-      display->gen_fbo_width, display->gen_fbo_height);
-#else
-  glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
-      display->gen_fbo_width, display->gen_fbo_height);
-#endif
+  glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
+     display->download_width, display->download_height);
 
   //setup a texture to render to
   glGenTextures (1, &fake_texture);
@@ -1586,6 +1581,8 @@ gst_gl_display_thread_gen_fbo (GstGLDisp
   //attach the depth render buffer to the FBO
   glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
       GL_RENDERBUFFER_EXT, display->generated_depth_buffer);
+  glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
+      GL_RENDERBUFFER_EXT, display->generated_depth_buffer);
 
   g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
       GL_FRAMEBUFFER_COMPLETE_EXT);
@@ -2543,13 +2540,8 @@ gst_gl_display_thread_init_upload_fbo (G
     //setup the render buffer for depth
     glGenRenderbuffersEXT (1, &display->upload_depth_buffer);
     glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, display->upload_depth_buffer);
-#ifndef OPENGL_ES2
-    glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
-        display->upload_width, display->upload_height);
-#else
-    glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
-        display->upload_width, display->upload_height);
-#endif
+    glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
+       display->download_width, display->download_height);
 
     //a fake texture is attached to the upload FBO (cannot init without it)
     glGenTextures (1, &fake_texture);
@@ -2574,6 +2566,9 @@ gst_gl_display_thread_init_upload_fbo (G
     glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
         GL_RENDERBUFFER_EXT, display->upload_depth_buffer);
 
+    glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
+        GL_RENDERBUFFER_EXT, display->upload_depth_buffer);
+
     gst_gl_display_check_framebuffer_status ();
 
     g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
