Search
lxdream.org :: lxdream/src/drivers/gl_common.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/gl_common.c
changeset 545:fdcdcd8b9fd1
prev540:a3767018a96d
next558:428cf8528699
next586:2a3ba82cf243
author nkeynes
date Thu Dec 06 10:43:30 2007 +0000 (16 years ago)
permissions -rw-r--r--
last change Add support for the MMIO side of the TLB (and LDTLB)
file annotate diff log raw
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.3 @@ -23,7 +23,6 @@
1.4 #include "drivers/gl_common.h"
1.5
1.6 extern uint32_t video_width, video_height;
1.7 -static uint32_t frame_colour = 0;
1.8
1.9 char *required_extensions[] = { "GL_EXT_framebuffer_object", NULL };
1.10
1.11 @@ -74,18 +73,12 @@
1.12 return isOK;
1.13 }
1.14
1.15 -void gl_display_render_buffer( render_buffer_t buffer )
1.16 +/**
1.17 + * Reset the gl state to simple orthographic projection with
1.18 + * texturing, alpha/depth/scissor/cull tests disabled.
1.19 + */
1.20 +void gl_reset_state()
1.21 {
1.22 - float top, bottom;
1.23 - if( buffer->inverted ) {
1.24 - top = ((float)buffer->height) - 0.5;
1.25 - bottom = 0.5;
1.26 - } else {
1.27 - top = 0.5;
1.28 - bottom = ((float)buffer->height) - 0.5;
1.29 - }
1.30 -
1.31 - /* Reset display parameters */
1.32 glViewport( 0, 0, video_width, video_height );
1.33 glMatrixMode(GL_PROJECTION);
1.34 glLoadIdentity();
1.35 @@ -97,8 +90,28 @@
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.40 -
1.41 + glDrawBuffer( GL_FRONT );
1.42 +}
1.43 +
1.44 +void gl_display_render_buffer( render_buffer_t buffer )
1.45 +{
1.46 + gl_texture_window( buffer->width, buffer->height, buffer->buf_id, buffer->inverted );
1.47 +}
1.48 +
1.49 +void gl_texture_window( int width, int height, int tex_id, gboolean inverted )
1.50 +{
1.51 + float top, bottom;
1.52 + if( inverted ) {
1.53 + top = ((float)height) - 0.5;
1.54 + bottom = 0.5;
1.55 + } else {
1.56 + top = 0.5;
1.57 + bottom = ((float)height) - 0.5;
1.58 + }
1.59 +
1.60 + /* Reset display parameters */
1.61 + gl_reset_state();
1.62 + glColor3f( 0,0,0 );
1.63
1.64 int x1=0,y1=0,x2=video_width,y2=video_height;
1.65
1.66 @@ -136,7 +149,7 @@
1.67
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.75 @@ -145,9 +158,9 @@
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.87 @@ -156,7 +169,7 @@
1.88 glFlush();
1.89 }
1.90
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.93 {
1.94 GLenum type = colour_formats[frame->colour_format].type;
1.95 GLenum format = colour_formats[frame->colour_format].format;
1.96 @@ -164,7 +177,7 @@
1.97 int rowstride = (frame->rowstride / bpp) - frame->width;
1.98
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.104 return TRUE;
1.105 @@ -172,29 +185,13 @@
1.106
1.107 gboolean gl_display_blank( uint32_t colour )
1.108 {
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.119 glFlush();
1.120 - frame_colour = colour;
1.121 return TRUE;
1.122 }
1.123
1.124 -void gl_redisplay_last()
1.125 -{
1.126 - render_buffer_t buffer = pvr2_get_front_buffer();
1.127 - if( buffer == NULL ) {
1.128 - gl_display_blank( frame_colour );
1.129 - } else {
1.130 - gl_display_render_buffer( buffer );
1.131 - }
1.132 -}
1.133 -
1.134 /**
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
.