Search
lxdream.org :: lxdream/src/drivers/video_gl.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_gl.c
changeset 1259:8a69f4d0b31d
prev1258:f8a9c0fd2abb
next1260:8207695d908c
author nkeynes
date Mon Mar 05 15:00:14 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Revert to using GL_QUADS when available, fallback to fan-strip when it's not
(GLES)
file annotate diff log raw
1.1 --- a/src/drivers/video_gl.c Mon Mar 05 11:41:03 2012 +1000
1.2 +++ b/src/drivers/video_gl.c Mon Mar 05 15:00:14 2012 +1000
1.3 @@ -65,34 +65,34 @@
1.4 x2 -= x1;
1.5 video_box.gap1[0].x = 0; video_box.gap1[0].y = 0;
1.6 video_box.gap1[1].x = x1; video_box.gap1[1].y = 0;
1.7 - video_box.gap1[2].x = 0; video_box.gap1[2].y = video_height;
1.8 - video_box.gap1[3].x = x2; video_box.gap1[3].y = video_height;
1.9 + video_box.gap1[2].x = x2; video_box.gap1[2].y = video_height;
1.10 + video_box.gap1[3].x = 0; video_box.gap1[3].y = video_height;
1.11 video_box.gap2[0].x = x2; video_box.gap2[0].y = 0;
1.12 video_box.gap2[1].x = video_width; video_box.gap2[1].y = 0;
1.13 - video_box.gap2[2].x = x2; video_box.gap2[2].y = video_height;
1.14 - video_box.gap2[3].x = video_width; video_box.gap2[3].y = video_height;
1.15 + video_box.gap2[2].x = video_width; video_box.gap2[2].y = video_height;
1.16 + video_box.gap2[3].x = x2; video_box.gap2[3].y = video_height;
1.17 } else if( ah < video_height ) {
1.18 y1 = (video_height - ah)/2;
1.19 y2 -= y1;
1.20
1.21 video_box.gap1[0].x = 0; video_box.gap1[0].y = 0;
1.22 video_box.gap1[1].x = video_width; video_box.gap1[1].y = 0;
1.23 - video_box.gap1[2].x = 0; video_box.gap1[2].y = y1;
1.24 - video_box.gap1[3].x = video_width; video_box.gap1[3].y = y1;
1.25 + video_box.gap1[2].x = video_width; video_box.gap1[2].y = y1;
1.26 + video_box.gap1[3].x = 0; video_box.gap1[3].y = y1;
1.27 video_box.gap2[0].x = 0; video_box.gap2[0].y = y2;
1.28 video_box.gap2[1].x = video_width; video_box.gap2[1].y = y2;
1.29 - video_box.gap2[2].x = 0; video_box.gap2[2].y = video_height;
1.30 - video_box.gap2[3].x = video_width; video_box.gap2[3].y = video_height;
1.31 + video_box.gap2[2].x = video_width; video_box.gap2[2].y = video_height;
1.32 + video_box.gap2[3].x = 0; video_box.gap2[3].y = video_height;
1.33 }
1.34
1.35 video_box.video_view[0].x = x1; video_box.video_view[0].y = y1;
1.36 - video_box.video_view[0].u = top; video_box.video_view[0].v = top;
1.37 + video_box.video_view[0].u = 0; video_box.video_view[0].v = top;
1.38 video_box.video_view[1].x = x2; video_box.video_view[1].y = y1;
1.39 - video_box.video_view[1].u = bottom; video_box.video_view[1].v = top;
1.40 - video_box.video_view[2].x = x1; video_box.video_view[2].y = y2;
1.41 - video_box.video_view[2].u = top; video_box.video_view[2].v = bottom;
1.42 - video_box.video_view[3].x = x2; video_box.video_view[3].y = y2;
1.43 - video_box.video_view[3].u = bottom; video_box.video_view[3].v = bottom;
1.44 + video_box.video_view[1].u = 1; video_box.video_view[1].v = top;
1.45 + video_box.video_view[2].x = x2; video_box.video_view[2].y = y2;
1.46 + video_box.video_view[2].u = 1; video_box.video_view[2].v = bottom;
1.47 + video_box.video_view[3].x = x1; video_box.video_view[3].y = y2;
1.48 + video_box.video_view[3].u = 0; video_box.video_view[3].v = bottom;
1.49
1.50 memcpy( &video_box.invert_view, &video_box.video_view, sizeof(video_box.video_view) );
1.51 video_box.invert_view[0].v = bottom; video_box.invert_view[1].v = bottom;
1.52 @@ -177,6 +177,13 @@
1.53 }
1.54 }
1.55
1.56 +/**
1.57 + * Use quads if we have them, otherwise tri-fans.
1.58 + */
1.59 +#ifndef GL_QUADS
1.60 +#define GL_TRIANGLE_FAN GL_QUADS
1.61 +#endif
1.62 +
1.63 void gl_texture_window( int width, int height, int tex_id, gboolean inverted )
1.64 {
1.65 /* Set video box tex alpha to 1 */
1.66 @@ -185,13 +192,13 @@
1.67
1.68 /* Reset display parameters */
1.69 gl_framebuffer_setup();
1.70 - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
1.71 - glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
1.72 + glDrawArrays(GL_QUADS, 0, 4);
1.73 + glDrawArrays(GL_QUADS, 4, 4);
1.74 glEnable(GL_TEXTURE_2D);
1.75 glBindTexture(GL_TEXTURE_2D,tex_id);
1.76 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1.77 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1.78 - glDrawArrays(GL_TRIANGLE_STRIP, inverted ? 12 : 8, 4);
1.79 + glDrawArrays(GL_QUADS, inverted ? 12 : 8, 4);
1.80 glDisable(GL_TEXTURE_2D);
1.81 gl_framebuffer_cleanup();
1.82 glFlush();
1.83 @@ -225,9 +232,9 @@
1.84
1.85 /* And render */
1.86 gl_framebuffer_setup();
1.87 - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
1.88 - glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
1.89 - glDrawArrays(GL_TRIANGLE_STRIP, 8, 4);
1.90 + glDrawArrays(GL_QUADS, 0, 4);
1.91 + glDrawArrays(GL_QUADS, 4, 4);
1.92 + glDrawArrays(GL_QUADS, 8, 4);
1.93 gl_framebuffer_cleanup();
1.94 glFlush();
1.95 }
.