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 1240:190df8a791ca
prev1239:be3121267597
next1244:6b54ef5ed413
author nkeynes
date Tue Feb 28 17:25:26 2012 +1000 (11 years ago)
permissions -rw-r--r--
last change Implement display output for the GLES2 case (no fixed function
rendering)
file annotate diff log raw
1.1 --- a/src/drivers/video_gl.c Sat Feb 25 21:30:49 2012 +1000
1.2 +++ b/src/drivers/video_gl.c Tue Feb 28 17:25:26 2012 +1000
1.3 @@ -21,6 +21,7 @@
1.4 #include "display.h"
1.5 #include "pvr2/pvr2.h"
1.6 #include "pvr2/glutil.h"
1.7 +#include "pvr2/shaders.h"
1.8 #include "drivers/video_gl.h"
1.9
1.10 /* FIXME: Need to actually handle this case */
1.11 @@ -32,7 +33,7 @@
1.12 struct video_vertex {
1.13 float x,y;
1.14 float u,v;
1.15 - float r,g,b;
1.16 + float r,g,b,a;
1.17 };
1.18
1.19 static struct video_box_t {
1.20 @@ -98,7 +99,7 @@
1.21 /**
1.22 * Setup the gl context for writes to the display output.
1.23 */
1.24 -void gl_framebuffer_setup()
1.25 +static void gl_framebuffer_setup()
1.26 {
1.27 glViewport( 0, 0, video_width, video_height );
1.28 glLoadMatrixf(video_box.viewMatrix);
1.29 @@ -112,10 +113,28 @@
1.30 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1.31 }
1.32
1.33 +static void gl_framebuffer_cleanup()
1.34 +{
1.35 + glDisableClientState( GL_VERTEX_ARRAY );
1.36 + glDisableClientState( GL_COLOR_ARRAY );
1.37 + glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1.38 +}
1.39 #else
1.40 -void gl_framebuffer_setup()
1.41 +static void gl_framebuffer_setup()
1.42 {
1.43 - /* TODO */
1.44 + glViewport( 0, 0, video_width, video_height );
1.45 + glBlendFunc( GL_ONE, GL_ZERO );
1.46 + glsl_use_basic_shader();
1.47 + glsl_set_basic_shader_view_matrix(video_box.viewMatrix);
1.48 + glsl_set_basic_shader_in_vertex_pointer(&video_box.gap1[0].x, sizeof(struct video_vertex));
1.49 + glsl_set_basic_shader_in_colour_pointer(&video_box.gap1[0].r, sizeof(struct video_vertex));
1.50 + glsl_set_basic_shader_in_texcoord_pointer(&video_box.gap1[0].u, sizeof(struct video_vertex));
1.51 + glsl_set_basic_shader_primary_texture(0);
1.52 +}
1.53 +
1.54 +static void gl_framebuffer_cleanup()
1.55 +{
1.56 + glsl_clear_shader();
1.57 }
1.58 #endif
1.59
1.60 @@ -154,6 +173,9 @@
1.61
1.62 void gl_texture_window( int width, int height, int tex_id, gboolean inverted )
1.63 {
1.64 + /* Set video box tex alpha to 1 */
1.65 + video_box.video_view[0].a = video_box.video_view[1].a = video_box.video_view[2].a = video_box.video_view[3].a = 1;
1.66 +
1.67 /* Reset display parameters */
1.68 gl_framebuffer_setup();
1.69 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
1.70 @@ -165,6 +187,7 @@
1.71 glDrawArrays(GL_TRIANGLE_STRIP, inverted ? 12 : 8, 4);
1.72 glDisable(GL_TEXTURE_2D);
1.73 glFlush();
1.74 + gl_framebuffer_cleanup();
1.75 }
1.76
1.77 gboolean gl_load_frame_buffer( frame_buffer_t frame, int tex_id )
1.78 @@ -188,6 +211,7 @@
1.79 video_box.video_view[0].r = ((float)(((colour >> 16) & 0xFF) + 1)) / 256.0;
1.80 video_box.video_view[0].g = ((float)(((colour >> 8) & 0xFF) + 1)) / 256.0;
1.81 video_box.video_view[0].b = ((float)((colour & 0xFF) + 1)) / 256.0;
1.82 + video_box.video_view[0].a = 0;
1.83 memcpy( &video_box.video_view[1].r, &video_box.video_view[0].r, sizeof(float)*3 );
1.84 memcpy( &video_box.video_view[2].r, &video_box.video_view[0].r, sizeof(float)*3 );
1.85 memcpy( &video_box.video_view[3].r, &video_box.video_view[0].r, sizeof(float)*3 );
1.86 @@ -198,6 +222,7 @@
1.87 glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
1.88 glDrawArrays(GL_TRIANGLE_STRIP, 8, 4);
1.89 glFlush();
1.90 + gl_framebuffer_cleanup();
1.91 }
1.92
1.93 /**
.