Search
lxdream.org :: lxdream :: r444:74c38d57eb11
lxdream 0.9.1
released Jun 29
Download Now
changeset444:74c38d57eb11
parent443:1163eb5c0590
child445:75c668cdfdc0
authornkeynes
dateSun Oct 14 09:30:16 2007 +0000 (12 years ago)
Maintain aspect ratio when resizing (draw black-bars to the sides when needed)
src/drivers/gl_common.c
1.1 --- a/src/drivers/gl_common.c Sat Oct 13 04:01:02 2007 +0000
1.2 +++ b/src/drivers/gl_common.c Sun Oct 14 09:30:16 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gl_common.c,v 1.4 2007-10-13 04:01:02 nkeynes Exp $
1.6 + * $Id: gl_common.c,v 1.5 2007-10-14 09:30:16 nkeynes Exp $
1.7 *
1.8 * Common GL code that doesn't depend on a specific implementation
1.9 *
1.10 @@ -116,6 +116,42 @@
1.11 glDisable( GL_DEPTH_TEST );
1.12 glDisable( GL_SCISSOR_TEST );
1.13 glDisable( GL_CULL_FACE );
1.14 + glColor3f( 0,0,0 );
1.15 +
1.16 +
1.17 + int x1=0,y1=0,x2=video_width,y2=video_height;
1.18 +
1.19 + int ah = video_width * 0.75;
1.20 +
1.21 + if( ah > video_height ) {
1.22 + int w = (video_height/0.75);
1.23 + x1 = (video_width - w)/2;
1.24 + x2 -= x1;
1.25 +
1.26 + glBegin( GL_QUADS );
1.27 + glVertex2f( 0, 0 );
1.28 + glVertex2f( x1, 0 );
1.29 + glVertex2f( x1, video_height );
1.30 + glVertex2f( 0, video_height);
1.31 + glVertex2f( x2, 0 );
1.32 + glVertex2f( video_width, 0 );
1.33 + glVertex2f( video_width, video_height );
1.34 + glVertex2f( x2, video_height);
1.35 + glEnd();
1.36 + } else if( ah < video_height ) {
1.37 + y1 = (video_height - ah)/2;
1.38 + y2 -= y1;
1.39 + glBegin( GL_QUADS );
1.40 + glVertex2f( 0, 0 );
1.41 + glVertex2f( video_width, 0 );
1.42 + glVertex2f( video_width, y1 );
1.43 + glVertex2f( 0, y1 );
1.44 + glVertex2f( 0, y2 );
1.45 + glVertex2f( video_width, y2 );
1.46 + glVertex2f( video_width, video_height );
1.47 + glVertex2f( 0, video_height );
1.48 + glEnd();
1.49 + }
1.50
1.51 /* Render the textured rectangle */
1.52 glEnable( GL_TEXTURE_RECTANGLE_ARB );
1.53 @@ -127,13 +163,13 @@
1.54 glBlendFunc( GL_ONE, GL_ZERO );
1.55 glBegin( GL_QUADS );
1.56 glTexCoord2f( 0.5, top );
1.57 - glVertex2f( 0.0, 0.0 );
1.58 + glVertex2f( x1, y1 );
1.59 glTexCoord2f( ((float)tex_width)-0.5, top );
1.60 - glVertex2f( video_width, 0.0 );
1.61 + glVertex2f( x2, y1 );
1.62 glTexCoord2f( ((float)tex_width)-0.5, bottom );
1.63 - glVertex2f( video_width, video_height );
1.64 + glVertex2f( x2, y2 );
1.65 glTexCoord2f( 0.5, bottom );
1.66 - glVertex2f( 0.0, video_height );
1.67 + glVertex2f( x1, y2 );
1.68 glEnd();
1.69 glDisable( GL_TEXTURE_RECTANGLE_ARB );
1.70 glFlush();
.