--- /home/pierre/gstgldisplay.c	2010-03-02 10:47:24.861025000 +0100
+++ /home/pierre/gst-plugins-gl/gst-libs/gst/gl/gstgldisplay.c	2010-03-09 08:36:36.953000344 +0100
@@ -1193,7 +1193,7 @@ gst_gl_display_thread_init_download (Gst
         glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
             display->download_width, display->download_height);
 #else
-        glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
+	glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
             display->download_width, display->download_height);
 #endif
 
@@ -1279,6 +1279,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 ();
 
@@ -1562,7 +1566,7 @@ gst_gl_display_thread_gen_fbo (GstGLDisp
   glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
       display->gen_fbo_width, display->gen_fbo_height);
 #else
-  glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
+  glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
       display->gen_fbo_width, display->gen_fbo_height);
 #endif
 
@@ -1586,6 +1590,10 @@ 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);
@@ -2547,7 +2555,7 @@ gst_gl_display_thread_init_upload_fbo (G
     glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
         display->upload_width, display->upload_height);
 #else
-    glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
+    glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT,
         display->upload_width, display->upload_height);
 #endif
 
@@ -2573,6 +2581,10 @@ gst_gl_display_thread_init_upload_fbo (G
     //attach the depth render buffer to the FBO
     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 ();
 
