1.1 --- a/src/drivers/gl_common.c Wed Nov 21 11:44:30 2007 +0000
1.2 +++ b/src/drivers/gl_common.c Thu Dec 06 10:43:30 2007 +0000
1.4 #include "drivers/gl_common.h"
1.6 extern uint32_t video_width, video_height;
1.7 -static uint32_t frame_colour = 0;
1.9 char *required_extensions[] = { "GL_EXT_framebuffer_object", NULL };
1.15 -void gl_display_render_buffer( render_buffer_t buffer )
1.17 + * Reset the gl state to simple orthographic projection with
1.18 + * texturing, alpha/depth/scissor/cull tests disabled.
1.20 +void gl_reset_state()
1.22 - float top, bottom;
1.23 - if( buffer->inverted ) {
1.24 - top = ((float)buffer->height) - 0.5;
1.28 - bottom = ((float)buffer->height) - 0.5;
1.31 - /* Reset display parameters */
1.32 glViewport( 0, 0, video_width, video_height );
1.33 glMatrixMode(GL_PROJECTION);
1.36 glDisable( GL_DEPTH_TEST );
1.37 glDisable( GL_SCISSOR_TEST );
1.38 glDisable( GL_CULL_FACE );
1.39 - glColor3f( 0,0,0 );
1.41 + glDrawBuffer( GL_FRONT );
1.44 +void gl_display_render_buffer( render_buffer_t buffer )
1.46 + gl_texture_window( buffer->width, buffer->height, buffer->buf_id, buffer->inverted );
1.49 +void gl_texture_window( int width, int height, int tex_id, gboolean inverted )
1.51 + float top, bottom;
1.53 + top = ((float)height) - 0.5;
1.57 + bottom = ((float)height) - 0.5;
1.60 + /* Reset display parameters */
1.62 + glColor3f( 0,0,0 );
1.64 int x1=0,y1=0,x2=video_width,y2=video_height;
1.68 /* Render the textured rectangle */
1.69 glEnable( GL_TEXTURE_RECTANGLE_ARB );
1.70 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, buffer->buf_id );
1.71 + glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
1.72 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
1.73 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1.74 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1.76 glBegin( GL_QUADS );
1.77 glTexCoord2f( 0.5, top );
1.78 glVertex2f( x1, y1 );
1.79 - glTexCoord2f( ((float)buffer->width)-0.5, top );
1.80 + glTexCoord2f( ((float)width)-0.5, top );
1.81 glVertex2f( x2, y1 );
1.82 - glTexCoord2f( ((float)buffer->width)-0.5, bottom );
1.83 + glTexCoord2f( ((float)width)-0.5, bottom );
1.84 glVertex2f( x2, y2 );
1.85 glTexCoord2f( 0.5, bottom );
1.86 glVertex2f( x1, y2 );
1.91 -gboolean gl_load_frame_buffer( frame_buffer_t frame, render_buffer_t render )
1.92 +gboolean gl_load_frame_buffer( frame_buffer_t frame, int tex_id )
1.94 GLenum type = colour_formats[frame->colour_format].type;
1.95 GLenum format = colour_formats[frame->colour_format].format;
1.97 int rowstride = (frame->rowstride / bpp) - frame->width;
1.99 glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );
1.100 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, render->buf_id );
1.101 + glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
1.102 glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0,0,
1.103 frame->width, frame->height, format, type, frame->data );
1.105 @@ -172,29 +185,13 @@
1.107 gboolean gl_display_blank( uint32_t colour )
1.109 - glViewport( 0, 0, video_width, video_height );
1.110 - glMatrixMode( GL_PROJECTION );
1.111 - glLoadIdentity();
1.112 - glOrtho( 0, video_width, video_height, 0, 0, -65535 );
1.113 - glMatrixMode(GL_MODELVIEW);
1.114 - glLoadIdentity();
1.115 - glColor3b( (colour >> 16) & 0xFF, (colour >> 8) & 0xFF, colour & 0xFF );
1.116 + gl_reset_state();
1.117 + glColor3ub( (colour >> 16) & 0xFF, (colour >> 8) & 0xFF, colour & 0xFF );
1.118 glRecti(0,0, video_width, video_height );
1.120 - frame_colour = colour;
1.124 -void gl_redisplay_last()
1.126 - render_buffer_t buffer = pvr2_get_front_buffer();
1.127 - if( buffer == NULL ) {
1.128 - gl_display_blank( frame_colour );
1.130 - gl_display_render_buffer( buffer );
1.135 * Generic GL read_render_buffer. This function assumes that the caller
1.136 * has already set the appropriate glReadBuffer(); in other words, unless