Search
lxdream.org :: lxdream/src/drivers/gl_fbo.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/gl_fbo.c
changeset 863:a5e5310061e2
prev857:3d8944884eaa
next868:c5b4ed31d819
author nkeynes
date Sun Sep 28 01:09:51 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Initial shadow volume implementation for opaque polygons (stencil isn't quite
right, but we get some kind of shadows now)
file annotate diff log raw
1.1 --- a/src/drivers/gl_fbo.c Fri Sep 12 05:36:00 2008 +0000
1.2 +++ b/src/drivers/gl_fbo.c Sun Sep 28 01:09:51 2008 +0000
1.3 @@ -58,6 +58,7 @@
1.4 };
1.5
1.6 static GLint gl_fbo_max_attachments = 0;
1.7 +static gboolean gl_fbo_have_packed_stencil = FALSE;
1.8 static struct gl_fbo_info fbo[MAX_FRAMEBUFFERS];
1.9
1.10 #define ATTACHMENT_POINT(n) (GL_COLOR_ATTACHMENT0_EXT+(n))
1.11 @@ -93,6 +94,15 @@
1.12 }
1.13 last_used_fbo = 0;
1.14
1.15 + if( isGLExtensionSupported("GL_EXT_packed_depth_stencil" ) ) {
1.16 + driver->capabilities.stencil_bits = 8;
1.17 + gl_fbo_have_packed_stencil = TRUE;
1.18 + } else {
1.19 + driver->capabilities.stencil_bits = 0;
1.20 + gl_fbo_have_packed_stencil = FALSE;
1.21 + WARN( "Packed depth stencil not available - disabling shadow volumes" );
1.22 + }
1.23 +
1.24 driver->create_render_buffer = gl_fbo_create_render_buffer;
1.25 driver->destroy_render_buffer = gl_fbo_destroy_render_buffer;
1.26 driver->set_render_target = gl_fbo_set_render_target;
1.27 @@ -117,24 +127,31 @@
1.28 }
1.29 }
1.30
1.31 -void gl_fbo_setup_framebuffer( int bufno, int width, int height )
1.32 +static void gl_fbo_setup_framebuffer( int bufno, int width, int height )
1.33 {
1.34 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo[bufno].fb_id);
1.35 - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.36 - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
1.37 - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
1.38 - GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.39 - /* Stencil doesn't work on ATI, and we're not using it at the moment anyway, so...
1.40 - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].stencil_id);
1.41 - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX, width, height);
1.42 - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
1.43 - GL_RENDERBUFFER_EXT, fbo[bufno].stencil_id);
1.44 - */
1.45 + if( gl_fbo_have_packed_stencil ) {
1.46 + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.47 + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height);
1.48 + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
1.49 + GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.50 + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
1.51 + GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.52 + } else {
1.53 + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.54 + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
1.55 + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
1.56 + GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.57 + /* In theory you could attach a separate stencil buffer. In practice this
1.58 + * isn't actually supported by any hardware I've had access to, so we're
1.59 + * stencil-less.
1.60 + */
1.61 + }
1.62 fbo[bufno].width = width;
1.63 fbo[bufno].height = height;
1.64 }
1.65
1.66 -int gl_fbo_get_framebuffer( int width, int height )
1.67 +static int gl_fbo_get_framebuffer( int width, int height )
1.68 {
1.69 int bufno = -1, i;
1.70 /* find a compatible framebuffer context */
.