Search
lxdream.org :: lxdream/src/pvr2/glrender.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glrender.c
changeset 1140:7dc1c71ece76
prev1139:9af81878480b
next1145:45674791c6ad
author nkeynes
date Tue Oct 26 08:39:02 2010 +1000 (12 years ago)
permissions -rw-r--r--
last change Implement fragment shader to support palette textures 'directly', and
therefore avoid having to reload all palette textures whenever the palette
changes.
file annotate diff log raw
1.1 --- a/src/pvr2/glrender.c Sun Oct 24 15:22:59 2010 +1000
1.2 +++ b/src/pvr2/glrender.c Tue Oct 26 08:39:02 2010 +1000
1.3 @@ -44,6 +44,8 @@
1.4 GL_MODULATE
1.5 };
1.6
1.7 +static gboolean have_shaders = FALSE;
1.8 +
1.9 /**
1.10 * Clip the tile bounds to the clipping plane.
1.11 * @return TRUE if the tile was not clipped completely.
1.12 @@ -83,16 +85,17 @@
1.13 }
1.14
1.15
1.16 -
1.17 /**
1.18 * Once-off call to setup the OpenGL context.
1.19 */
1.20 void pvr2_setup_gl_context()
1.21 {
1.22
1.23 - if( glsl_is_supported() ) {
1.24 + if( glsl_is_supported() && isGLMultitextureSupported() ) {
1.25 if( !glsl_load_shaders( ) ) {
1.26 WARN( "Unable to load GL shaders" );
1.27 + } else {
1.28 + have_shaders = TRUE;
1.29 }
1.30 }
1.31
1.32 @@ -125,6 +128,13 @@
1.33 glFogi(GL_FOG_MODE, GL_LINEAR);
1.34 glFogf(GL_FOG_START, 0.0);
1.35 glFogf(GL_FOG_END, 1.0);
1.36 +
1.37 + if( have_shaders ) {
1.38 + glsl_set_shader(DEFAULT_PROGRAM);
1.39 + glsl_set_uniform_int(DEFAULT_PROGRAM, "primary_texture", 0);
1.40 + glsl_set_uniform_int(DEFAULT_PROGRAM, "palette_texture", 1);
1.41 + glsl_clear_shader();
1.42 + }
1.43 }
1.44
1.45 /**
1.46 @@ -146,11 +156,13 @@
1.47 void render_set_tsp_context( uint32_t poly1, uint32_t poly2 )
1.48 {
1.49 glShadeModel( POLY1_SHADE_MODEL(poly1) );
1.50 - if( POLY1_TEXTURED(poly1) ) {
1.51 +
1.52 + if( POLY1_TEXTURED(poly1) && !have_shaders ) {
1.53 if( POLY2_TEX_BLEND(poly2) == 2 )
1.54 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
1.55 else
1.56 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1.57 +
1.58 }
1.59
1.60 switch( POLY2_FOG_MODE(poly2) ) {
1.61 @@ -482,7 +494,7 @@
1.62 /* Setup vertex array pointers */
1.63 glVertexPointer(3, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].x);
1.64 glColorPointer(4, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].rgba[0]);
1.65 - glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].u);
1.66 + glTexCoordPointer(4, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].u);
1.67 glSecondaryColorPointerEXT(3, GL_FLOAT, sizeof(struct vertex_struct), pvr2_scene.vertex_array[0].offset_rgba );
1.68 glFogCoordPointerEXT(GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].offset_rgba[3] );
1.69 /* Turn on the shaders (if available) */
.