Search
lxdream.org :: lxdream :: r1222:a4545699a82b
lxdream 0.9.1
released Jun 29
Download Now
changeset1222:a4545699a82b
parent1221:f50407acc682
child1223:61684ca88599
authornkeynes
dateWed Feb 15 17:54:51 2012 +1000 (7 years ago)
Use GL_TEXTURE_2D instead of GL_TEXTURE_RECTANGLE_ARB for frame buffers, for
systems that don't provide the latter (and there's not really much
difference anyway).
Add macro wrangling for GL_DEPTH24_STENCIL8 format
src/drivers/gl_fbo.c
src/drivers/video_gl.c
src/drivers/video_gl.h
src/drivers/video_glx.c
src/pvr2/glutil.h
1.1 --- a/src/drivers/gl_fbo.c Mon Feb 13 22:16:43 2012 +1000
1.2 +++ b/src/drivers/gl_fbo.c Wed Feb 15 17:54:51 2012 +1000
1.3 @@ -136,7 +136,7 @@
1.4 for( i=0; i<gl_fbo_max_attachments; i++ ) {
1.5 if( fbo[bufno].tex_ids[i] != -1 ) {
1.6 glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(i),
1.7 - GL_TEXTURE_RECTANGLE_ARB, 0, 0);
1.8 + GL_TEXTURE_2D, 0, 0);
1.9 fbo[bufno].tex_ids[i] = -1;
1.10 }
1.11 }
1.12 @@ -144,7 +144,7 @@
1.13 /* Setup the renderbuffers */
1.14 if( gl_fbo_have_packed_stencil ) {
1.15 glBindRenderbuffer(GL_RENDERBUFFER, fbo[bufno].depth_id);
1.16 - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_EXT, width, height);
1.17 + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
1.18 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
1.19 GL_RENDERBUFFER, fbo[bufno].depth_id);
1.20 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
1.21 @@ -209,9 +209,9 @@
1.22 attach = 0;
1.23 }
1.24 fbo[fbo_no].tex_ids[attach] = tex_id;
1.25 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, 0 ); // Ensure the output texture is unbound
1.26 + glBindTexture( GL_TEXTURE_2D, 0 ); // Ensure the output texture is unbound
1.27 glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(attach),
1.28 - GL_TEXTURE_RECTANGLE_ARB, tex_id, 0 );
1.29 + GL_TEXTURE_2D, tex_id, 0 );
1.30 /* Set draw/read buffers by default */
1.31 glDrawBuffer(ATTACHMENT_POINT(attach));
1.32 glReadBuffer(ATTACHMENT_POINT(attach));
1.33 @@ -251,14 +251,14 @@
1.34 buffer->buf_id = tex;
1.35 } else {
1.36 buffer->buf_id = tex_id;
1.37 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
1.38 + glBindTexture( GL_TEXTURE_2D, tex_id );
1.39 }
1.40 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, buffer->buf_id );
1.41 - glTexImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
1.42 - glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP );
1.43 - glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP );
1.44 - glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
1.45 - glTexParameteri( GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
1.46 + glBindTexture( GL_TEXTURE_2D, buffer->buf_id );
1.47 + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL );
1.48 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1.49 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1.50 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
1.51 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
1.52 return buffer;
1.53 }
1.54
1.55 @@ -276,7 +276,7 @@
1.56 if( fbo[i].tex_ids[j] == buffer->buf_id ) {
1.57 glBindFramebuffer(GL_FRAMEBUFFER, fbo[i].fb_id);
1.58 glFramebufferTexture2D(GL_FRAMEBUFFER, ATTACHMENT_POINT(j),
1.59 - GL_TEXTURE_RECTANGLE_ARB, GL_NONE, 0 );
1.60 + GL_TEXTURE_2D, GL_NONE, 0 );
1.61 fbo[i].tex_ids[j] = -1;
1.62 return;
1.63 }
2.1 --- a/src/drivers/video_gl.c Mon Feb 13 22:16:43 2012 +1000
2.2 +++ b/src/drivers/video_gl.c Wed Feb 15 17:54:51 2012 +1000
2.3 @@ -38,7 +38,6 @@
2.4 glLoadIdentity();
2.5 glEnable( GL_BLEND );
2.6 glDisable( GL_TEXTURE_2D );
2.7 - glDisable( GL_TEXTURE_RECTANGLE_ARB );
2.8 glDisable( GL_ALPHA_TEST );
2.9 glDisable( GL_DEPTH_TEST );
2.10 glDisable( GL_SCISSOR_TEST );
2.11 @@ -82,11 +81,11 @@
2.12 {
2.13 float top, bottom;
2.14 if( inverted ) {
2.15 - top = ((float)height);
2.16 + top = 1;
2.17 bottom = 0;
2.18 } else {
2.19 top = 0;
2.20 - bottom = ((float)height);
2.21 + bottom = 1;
2.22 }
2.23
2.24 /* Reset display parameters */
2.25 @@ -128,24 +127,24 @@
2.26 }
2.27
2.28 /* Render the textured rectangle */
2.29 - glEnable( GL_TEXTURE_RECTANGLE_ARB );
2.30 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
2.31 + glEnable( GL_TEXTURE_2D );
2.32 + glBindTexture( GL_TEXTURE_2D, tex_id );
2.33 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
2.34 - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
2.35 - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2.36 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
2.37 + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2.38 glEnable( GL_BLEND );
2.39 glBlendFunc( GL_ONE, GL_ZERO );
2.40 glBegin( GL_QUADS );
2.41 glTexCoord2f( 0, top );
2.42 glVertex2f( x1, y1 );
2.43 - glTexCoord2f( ((float)width), top );
2.44 + glTexCoord2f( 1, top );
2.45 glVertex2f( x2, y1 );
2.46 - glTexCoord2f( ((float)width), bottom );
2.47 + glTexCoord2f( 1, bottom );
2.48 glVertex2f( x2, y2 );
2.49 glTexCoord2f( 0, bottom );
2.50 glVertex2f( x1, y2 );
2.51 glEnd();
2.52 - glDisable( GL_TEXTURE_RECTANGLE_ARB );
2.53 + glDisable( GL_TEXTURE_2D );
2.54 glFlush();
2.55 }
2.56
2.57 @@ -157,8 +156,8 @@
2.58 int rowstride = (frame->rowstride / bpp) - frame->width;
2.59
2.60 glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );
2.61 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
2.62 - glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0,0,
2.63 + glBindTexture( GL_TEXTURE_2D, tex_id );
2.64 + glTexSubImage2D( GL_TEXTURE_2D, 0, 0,0,
2.65 frame->width, frame->height, format, type, frame->data );
2.66 return TRUE;
2.67 }
3.1 --- a/src/drivers/video_gl.h Mon Feb 13 22:16:43 2012 +1000
3.2 +++ b/src/drivers/video_gl.h Wed Feb 15 17:54:51 2012 +1000
3.3 @@ -39,12 +39,12 @@
3.4 void gl_display_blank( uint32_t colour );
3.5
3.6 /**
3.7 - * Write a rectangular texture (GL_TEXTURE_RECTANGLE_ARB) to the display frame
3.8 + * Write a rectangular texture (GL_TEXTURE_2D) to the display frame
3.9 */
3.10 void gl_display_render_buffer( render_buffer_t buffer );
3.11
3.12 /**
3.13 - * Write a rectangular texture (GL_TEXTURE_RECTANGLE_ARB) to the display frame
3.14 + * Write a rectangular texture (GL_TEXTURE_2D) to the display frame
3.15 */
3.16 void gl_texture_window( int width, int height, int tex_id, gboolean inverted );
3.17
4.1 --- a/src/drivers/video_glx.c Mon Feb 13 22:16:43 2012 +1000
4.2 +++ b/src/drivers/video_glx.c Wed Feb 15 17:54:51 2012 +1000
4.3 @@ -367,8 +367,8 @@
4.4 if( buffer->tex_id != 0 ) {
4.5 // The pbuffer should already be the current context, but just in case...
4.6 glXMakeContextCurrent( video_x11_display, (GLXPbuffer)buffer->buf_id, (GLXPbuffer)buffer->buf_id, glx_context );
4.7 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, buffer->tex_id );
4.8 - glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, buffer->width, buffer->height, 0 );
4.9 + glBindTexture( GL_TEXTURE_2D, buffer->tex_id );
4.10 + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, buffer->width, buffer->height, 0 );
4.11 }
4.12 }
4.13
4.14 @@ -382,8 +382,8 @@
4.15 glFinish();
4.16 glReadBuffer( GL_FRONT );
4.17 glXMakeContextCurrent( video_x11_display, (GLXPbuffer)buffer->buf_id, (GLXPbuffer)buffer->buf_id, glx_context );
4.18 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, glx_pbuffer_texture );
4.19 - glCopyTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 0, 0, buffer->width, buffer->height, 0 );
4.20 + glBindTexture( GL_TEXTURE_2D, glx_pbuffer_texture );
4.21 + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, buffer->width, buffer->height, 0 );
4.22 video_glx_make_window_current();
4.23 gl_texture_window( buffer->width, buffer->height, glx_pbuffer_texture, buffer->inverted );
4.24 }
5.1 --- a/src/pvr2/glutil.h Mon Feb 13 22:16:43 2012 +1000
5.2 +++ b/src/pvr2/glutil.h Wed Feb 15 17:54:51 2012 +1000
5.3 @@ -89,6 +89,14 @@
5.4 #define GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
5.5 #endif
5.6
5.7 +#ifndef GL_DEPTH24_STENCIL8
5.8 +#if defined(GL_DEPTH24_STENCIL8_EXT)
5.9 +#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
5.10 +#elif defined(GL_DEPTH24_STENCIL8_OES)
5.11 +#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
5.12 +#endif
5.13 +#endif
5.14 +
5.15 #if defined(GL_FRAMEBUFFER_COMPLETE_EXT) && !defined(GL_FRAMEBUFFER_COMPLETE)
5.16 #define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
5.17 #endif
.