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 1251:b8ab59d39756
prev1245:01e0020adf88
next1298:d0eb2307b847
author nkeynes
date Sat Mar 03 16:11:28 2012 +1000 (10 years ago)
permissions -rw-r--r--
last change Support depth component 16 as well as 24 (add capability flag for the available bits)
Put remaining TODOs inside HAVE_OPENGL_FIXEDFUNC blocks
Add swap-buffer calls for EGL (does not appear to support rendering directly
to front-buffer)
file annotate diff log raw
1.1 --- a/src/drivers/gl_fbo.c Fri Mar 02 23:49:10 2012 +1000
1.2 +++ b/src/drivers/gl_fbo.c Sat Mar 03 16:11:28 2012 +1000
1.3 @@ -59,6 +59,7 @@
1.4 };
1.5
1.6 static GLint gl_fbo_max_attachments = 0;
1.7 +static GLint gl_fbo_depth_component;
1.8 static gboolean gl_fbo_have_packed_stencil = FALSE;
1.9 static struct gl_fbo_info fbo[MAX_FRAMEBUFFERS];
1.10
1.11 @@ -103,6 +104,11 @@
1.12 gl_fbo_have_packed_stencil = FALSE;
1.13 WARN( "Packed depth stencil not available - disabling shadow volumes" );
1.14 }
1.15 + if( driver->capabilities.depth_bits >= 24 ) {
1.16 + gl_fbo_depth_component = GL_DEPTH_COMPONENT24;
1.17 + } else {
1.18 + gl_fbo_depth_component = GL_DEPTH_COMPONENT16;
1.19 + }
1.20
1.21 driver->create_render_buffer = gl_fbo_create_render_buffer;
1.22 driver->destroy_render_buffer = gl_fbo_destroy_render_buffer;
1.23 @@ -151,7 +157,7 @@
1.24 GL_RENDERBUFFER, fbo[bufno].depth_id);
1.25 } else {
1.26 glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);
1.27 - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
1.28 + glRenderbufferStorage(GL_RENDERBUFFER, gl_fbo_depth_component, width, height);
1.29 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
1.30 GL_RENDERBUFFER, fbo[bufno].depth_id);
1.31 /* In theory you could attach a separate stencil buffer. In practice this
1.32 @@ -331,6 +337,8 @@
1.33 {
1.34 gl_fbo_detach();
1.35 gl_display_render_buffer( buffer );
1.36 + if( display_driver->swap_buffers )
1.37 + display_driver->swap_buffers();
1.38 }
1.39
1.40 static void gl_fbo_load_frame_buffer( frame_buffer_t frame, render_buffer_t buffer )
1.41 @@ -343,6 +351,8 @@
1.42 {
1.43 gl_fbo_detach();
1.44 gl_display_blank( colour );
1.45 + if( display_driver->swap_buffers )
1.46 + display_driver->swap_buffers();
1.47 }
1.48
1.49 void gl_fbo_detach()
1.50 @@ -353,8 +363,6 @@
1.51 glDrawBuffer( GL_FRONT );
1.52 glReadBuffer( GL_FRONT );
1.53 #endif
1.54 - if( display_driver->swap_buffers )
1.55 - display_driver->swap_buffers();
1.56 }
1.57
1.58 static gboolean gl_fbo_read_render_buffer( unsigned char *target, render_buffer_t buffer,
.