Search
lxdream.org :: lxdream/src/pvr2/glrender.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glrender.c
changeset 1236:d93175c36387
prev1233:06923d1020de
next1238:91bcb2dec4ef
author nkeynes
date Fri Feb 24 21:17:47 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Factor video_width/video_height out into video_gl.c
Convert immediate-mode bits in video_gl.c into a structure for glDrawArray
Move setOrtho into defineOrthoMatrix in glutil.c
Rearrange various GL settings to keep a consistent state
file annotate diff log raw
1.1 --- a/src/pvr2/glrender.c Thu Feb 23 22:40:50 2012 +1000
1.2 +++ b/src/pvr2/glrender.c Fri Feb 24 21:17:47 2012 +1000
1.3 @@ -124,9 +124,11 @@
1.4 CGL_MACRO_CONTEXT = CGLGetCurrentContext();
1.5 #endif
1.6 texcache_gl_init(have_shaders); // Allocate texture IDs
1.7 +
1.8 + /* Global settings */
1.9 glDisable( GL_CULL_FACE );
1.10 glEnable( GL_BLEND );
1.11 - glEnable( GL_DEPTH_TEST );
1.12 + glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1.13
1.14 #ifdef HAVE_OPENGL_CLAMP_COLOR
1.15 if( isGLExtensionSupported("GL_ARB_color_buffer_float") ) {
1.16 @@ -135,7 +137,14 @@
1.17 }
1.18 #endif
1.19
1.20 - glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1.21 +#ifdef HAVE_OPENGL_FIXEDFUNC
1.22 + /* Setup defaults for perspective correction + matrices */
1.23 + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1.24 + glMatrixMode(GL_MODELVIEW);
1.25 + glLoadIdentity();
1.26 + glMatrixMode(GL_PROJECTION);
1.27 +#endif
1.28 +
1.29
1.30 #ifdef HAVE_OPENGL_CLEAR_DEPTHF
1.31 glClearDepthf(0);
1.32 @@ -383,43 +392,12 @@
1.33 }
1.34 }
1.35
1.36 -/**
1.37 - * Define an orthographic projection matrix
1.38 - * Note: row-major order
1.39 - */
1.40 -static void setOrtho( GLfloat *matrix, GLfloat width, GLfloat height, GLfloat znear, GLfloat zfar )
1.41 -{
1.42 - matrix[0] = 2/width;
1.43 - matrix[1] = 0;
1.44 - matrix[2] = 0;
1.45 - matrix[3] = 0;
1.46 -
1.47 - matrix[4] = 0;
1.48 - matrix[5] = -2/height;
1.49 - matrix[6] = 0;
1.50 - matrix[7] = 0;
1.51 -
1.52 - matrix[8] = 0;
1.53 - matrix[9] = 0;
1.54 - matrix[10]= -2/(zfar-znear);
1.55 - matrix[11]= 0;
1.56 -
1.57 - matrix[12]= -1;
1.58 - matrix[13]= 1;
1.59 - matrix[14]= -(zfar+znear)/(zfar-znear);
1.60 - matrix[15]= 1;
1.61 -}
1.62
1.63 #ifdef HAVE_OPENGL_FIXEDFUNC
1.64 void pvr2_scene_setup_fixed( GLfloat *viewMatrix )
1.65 {
1.66 - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1.67 -
1.68 - glMatrixMode(GL_MODELVIEW);
1.69 - glLoadIdentity();
1.70 - glMatrixMode(GL_PROJECTION);
1.71 - glLoadIdentity();
1.72 glLoadMatrixf(viewMatrix);
1.73 + glEnable( GL_DEPTH_TEST );
1.74
1.75 glEnable( GL_FOG );
1.76 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
1.77 @@ -456,12 +434,14 @@
1.78 glDisable( GL_COLOR_SUM );
1.79 glDisable( GL_FOG );
1.80 glDisable( GL_ALPHA_TEST );
1.81 + glDisable( GL_DEPTH_TEST );
1.82
1.83 glDisableClientState( GL_VERTEX_ARRAY );
1.84 glDisableClientState( GL_COLOR_ARRAY );
1.85 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1.86 glDisableClientState( GL_SECONDARY_COLOR_ARRAY );
1.87 glDisableClientState( GL_FOG_COORDINATE_ARRAY_EXT );
1.88 +
1.89 }
1.90 #else
1.91 void pvr2_scene_setup_fixed( GLfloat *viewMatrix, float alphaRef )
1.92 @@ -477,6 +457,8 @@
1.93
1.94 void pvr2_scene_setup_shader( GLfloat *viewMatrix )
1.95 {
1.96 + glEnable( GL_DEPTH_TEST );
1.97 +
1.98 glsl_use_pvr2_shader();
1.99 glsl_set_pvr2_shader_view_matrix(viewMatrix);
1.100 glsl_set_pvr2_shader_fog_colour1(pvr2_scene.fog_vert_colour);
1.101 @@ -493,6 +475,8 @@
1.102 void pvr2_scene_cleanup_shader( )
1.103 {
1.104 glsl_clear_shader();
1.105 +
1.106 + glDisable( GL_DEPTH_TEST );
1.107 }
1.108
1.109 void pvr2_scene_set_alpha_shader( float alphaRef )
1.110 @@ -535,7 +519,7 @@
1.111 clip_bounds[i] = (uint32_t)pvr2_scene.bounds[i];
1.112 }
1.113
1.114 - setOrtho(viewMatrix, pvr2_scene.buffer_width, pvr2_scene.buffer_height, -farz, -nearz);
1.115 + defineOrthoMatrix(viewMatrix, pvr2_scene.buffer_width, pvr2_scene.buffer_height, -farz, -nearz);
1.116
1.117 if( have_shaders ) {
1.118 pvr2_scene_setup_shader(viewMatrix);
1.119 @@ -589,7 +573,6 @@
1.120 glStencilMask( 0x01 );
1.121 glDepthFunc( GL_LEQUAL );
1.122 glDepthMask( GL_FALSE );
1.123 - glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
1.124 FOREACH_SEGMENT(segment)
1.125 if( IS_NONEMPTY_TILE_LIST(segment->opaquemod_ptr) ) {
1.126 CLIP_TO_SEGMENT();
1.127 @@ -609,6 +592,7 @@
1.128 CLIP_TO_SEGMENT();
1.129 gl_render_tilelist(segment->opaque_ptr,TRUE);
1.130 END_FOREACH_SEGMENT()
1.131 + glDisable( GL_STENCIL_TEST );
1.132
1.133 /* Render the punch-out polygons */
1.134 if( have_shaders )
.