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 1210:79bbd30363f4
prev1166:f405d42a9786
next1222:a4545699a82b
author nkeynes
date Tue Feb 07 14:27:13 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Add wrangling for some of the core vs EXT/ARB versions of functions + macros
file annotate diff log raw
1.1 --- a/src/drivers/gl_fbo.c Fri Jan 28 16:14:57 2011 +1000
1.2 +++ b/src/drivers/gl_fbo.c Tue Feb 07 14:27:13 2012 +1000
1.3 @@ -30,7 +30,7 @@
1.4 #include "drivers/video_gl.h"
1.5 #include "pvr2/glutil.h"
1.6
1.7 -#ifdef HAVE_OPENGL_FBO
1.8 +#if defined(HAVE_OPENGL_FBO) || defined(HAVE_OPENGL_FBO_EXT)
1.9
1.10 #define MAX_FRAMEBUFFERS 2
1.11 #define MAX_TEXTURES_PER_FB 16
1.12 @@ -62,7 +62,7 @@
1.13 static gboolean gl_fbo_have_packed_stencil = FALSE;
1.14 static struct gl_fbo_info fbo[MAX_FRAMEBUFFERS];
1.15
1.16 -#define ATTACHMENT_POINT(n) (GL_COLOR_ATTACHMENT0_EXT+(n))
1.17 +#define ATTACHMENT_POINT(n) (GL_COLOR_ATTACHMENT0+(n))
1.18 static int last_used_fbo;
1.19
1.20 gboolean gl_fbo_is_supported()
1.21 @@ -80,9 +80,9 @@
1.22 GLuint fbids[MAX_FRAMEBUFFERS];
1.23 GLuint rbids[MAX_FRAMEBUFFERS*2]; /* depth buffer, stencil buffer per fb */
1.24
1.25 - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &gl_fbo_max_attachments);
1.26 - glGenFramebuffersEXT( MAX_FRAMEBUFFERS, &fbids[0] );
1.27 - glGenRenderbuffersEXT( MAX_FRAMEBUFFERS*2, &rbids[0] );
1.28 + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &gl_fbo_max_attachments);
1.29 + glGenFramebuffers( MAX_FRAMEBUFFERS, &fbids[0] );
1.30 + glGenRenderbuffers( MAX_FRAMEBUFFERS*2, &rbids[0] );
1.31 for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {
1.32 fbo[i].fb_id = fbids[i];
1.33 fbo[i].depth_id = rbids[i*2];
1.34 @@ -114,28 +114,28 @@
1.35 driver->read_render_buffer = gl_fbo_read_render_buffer;
1.36
1.37 gl_fbo_test_framebuffer();
1.38 - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
1.39 + glBindFramebuffer(GL_FRAMEBUFFER, 0);
1.40 }
1.41
1.42 void gl_fbo_shutdown()
1.43 {
1.44 int i;
1.45 - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
1.46 + glBindFramebuffer( GL_FRAMEBUFFER, 0 );
1.47 for( i=0; i<MAX_FRAMEBUFFERS; i++ ) {
1.48 - glDeleteFramebuffersEXT( 1, &fbo[i].fb_id );
1.49 - glDeleteRenderbuffersEXT( 2, &fbo[i].depth_id );
1.50 + glDeleteFramebuffers( 1, &fbo[i].fb_id );
1.51 + glDeleteRenderbuffers( 2, &fbo[i].depth_id );
1.52 }
1.53 }
1.54
1.55 static void gl_fbo_setup_framebuffer( int bufno, int width, int height )
1.56 {
1.57 int i;
1.58 - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo[bufno].fb_id);
1.59 + glBindFramebuffer(GL_FRAMEBUFFER, fbo[bufno].fb_id);
1.60
1.61 /* Clear out any existing texture attachments */
1.62 for( i=0; i<gl_fbo_max_attachments; i++ ) {
1.63 if( fbo[bufno].tex_ids[i] != -1 ) {
1.64 - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINT(i),
1.65 + glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(i),
1.66 GL_TEXTURE_RECTANGLE_ARB, 0, 0);
1.67 fbo[bufno].tex_ids[i] = -1;
1.68 }
1.69 @@ -143,17 +143,17 @@
1.70
1.71 /* Setup the renderbuffers */
1.72 if( gl_fbo_have_packed_stencil ) {
1.73 - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.74 - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height);
1.75 - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
1.76 - GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.77 - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
1.78 - GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.79 + glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);
1.80 + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_EXT, width, height);
1.81 + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
1.82 + GL_RENDERBUFFER, fbo[bufno].depth_id);
1.83 + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
1.84 + GL_RENDERBUFFER, fbo[bufno].depth_id);
1.85 } else {
1.86 - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.87 - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);
1.88 - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
1.89 - GL_RENDERBUFFER_EXT, fbo[bufno].depth_id);
1.90 + glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);
1.91 + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
1.92 + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
1.93 + GL_RENDERBUFFER, fbo[bufno].depth_id);
1.94 /* In theory you could attach a separate stencil buffer. In practice this
1.95 * isn't actually supported by any hardware I've had access to, so we're
1.96 * stencil-less.
1.97 @@ -183,7 +183,7 @@
1.98 last_used_fbo = bufno;
1.99 }
1.100 if( fbo[bufno].width == width && fbo[bufno].height == height ) {
1.101 - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fbo[bufno].fb_id );
1.102 + glBindFramebuffer( GL_FRAMEBUFFER, fbo[bufno].fb_id );
1.103 } else {
1.104 gl_fbo_setup_framebuffer( bufno, width, height );
1.105 }
1.106 @@ -210,7 +210,7 @@
1.107 }
1.108 fbo[fbo_no].tex_ids[attach] = tex_id;
1.109 glBindTexture( GL_TEXTURE_RECTANGLE_ARB, 0 ); // Ensure the output texture is unbound
1.110 - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINT(attach),
1.111 + glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(attach),
1.112 GL_TEXTURE_RECTANGLE_ARB, tex_id, 0 );
1.113 /* Set draw/read buffers by default */
1.114 glDrawBuffer(ATTACHMENT_POINT(attach));
1.115 @@ -226,8 +226,8 @@
1.116 render_buffer_t buffer = gl_fbo_create_render_buffer( 640, 480, 0 );
1.117 gl_fbo_set_render_target(buffer);
1.118
1.119 - GLint status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
1.120 - if( status != GL_FRAMEBUFFER_COMPLETE_EXT ) {
1.121 + GLint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
1.122 + if( status != GL_FRAMEBUFFER_COMPLETE ) {
1.123 ERROR( "Framebuffer failure: %x", status );
1.124 result = FALSE;
1.125 }
1.126 @@ -274,8 +274,8 @@
1.127 if( fbo[i].width == buffer->width && fbo[i].height == buffer->height ) {
1.128 for( j=0; j<gl_fbo_max_attachments; j++ ) {
1.129 if( fbo[i].tex_ids[j] == buffer->buf_id ) {
1.130 - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo[i].fb_id);
1.131 - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ATTACHMENT_POINT(j),
1.132 + glBindFramebuffer(GL_FRAMEBUFFER, fbo[i].fb_id);
1.133 + glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(j),
1.134 GL_TEXTURE_RECTANGLE_ARB, GL_NONE, 0 );
1.135 fbo[i].tex_ids[j] = -1;
1.136 return;
1.137 @@ -343,7 +343,7 @@
1.138
1.139 void gl_fbo_detach()
1.140 {
1.141 - glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
1.142 + glBindFramebuffer( GL_FRAMEBUFFER, 0 );
1.143 /* Make sure texture attachment is not a current draw/read buffer */
1.144 glDrawBuffer( GL_FRONT );
1.145 glReadBuffer( GL_FRONT );
.