Search
lxdream.org :: lxdream/src/pvr2/glrender.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/glrender.c
changeset 687:6bdc2b7032ea
prev684:95f2068235ef
next736:a02d1475ccfd
author nkeynes
date Sat Jun 14 11:54:15 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Change colour params to float
Convert background processing over to scene structure (fixes some depth issues as well)
Add color unclamp when supported
file annotate diff log raw
1.1 --- a/src/pvr2/glrender.c Sun Jun 01 08:58:46 2008 +0000
1.2 +++ b/src/pvr2/glrender.c Sat Jun 14 11:54:15 2008 +0000
1.3 @@ -101,6 +101,13 @@
1.4 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1.5 glMatrixMode(GL_MODELVIEW);
1.6 glLoadIdentity();
1.7 +
1.8 +#ifdef HAVE_OPENGL_CLAMP_COLOR
1.9 + if( isGLExtensionSupported("GL_ARB_color_buffer_float") ) {
1.10 + glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE );
1.11 + glClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FALSE );
1.12 + }
1.13 +#endif
1.14
1.15 glEnableClientState( GL_COLOR_ARRAY );
1.16 glEnableClientState( GL_VERTEX_ARRAY );
1.17 @@ -197,6 +204,23 @@
1.18 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
1.19 }
1.20
1.21 +
1.22 +static void gl_render_bkgnd( struct polygon_struct *poly )
1.23 +{
1.24 + if( poly->tex_id != -1 ) {
1.25 + glBindTexture(GL_TEXTURE_2D, poly->tex_id);
1.26 + }
1.27 + render_set_context( poly->context, RENDER_NORMAL );
1.28 + glDisable( GL_DEPTH_TEST );
1.29 + glDisable( GL_CULL_FACE );
1.30 + glBlendFunc( GL_ONE, GL_ZERO );
1.31 + glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
1.32 + glEnable( GL_CULL_FACE );
1.33 + glEnable( GL_DEPTH_TEST );
1.34 +}
1.35 +
1.36 +
1.37 +
1.38 void gl_render_tilelist( pvraddr_t tile_entry )
1.39 {
1.40 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
1.41 @@ -255,10 +279,10 @@
1.42 float nearz = pvr2_scene.bounds[4];
1.43 float farz = pvr2_scene.bounds[5];
1.44 if( nearz == farz ) {
1.45 - farz*= 2.0;
1.46 + farz*= 4.0;
1.47 }
1.48 glOrtho( 0, pvr2_scene.buffer_width, pvr2_scene.buffer_height, 0,
1.49 - -farz-1, -nearz );
1.50 + -farz, -nearz );
1.51 float alphaRef = ((float)(MMIO_READ(PVR2, RENDER_ALPHA_REF)&0xFF)+1)/256.0;
1.52 glAlphaFunc( GL_GEQUAL, alphaRef );
1.53
1.54 @@ -268,15 +292,16 @@
1.55 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
1.56
1.57 /* Setup vertex array pointers */
1.58 - glInterleavedArrays(GL_T2F_C4UB_V3F, sizeof(struct vertex_struct), pvr2_scene.vertex_array);
1.59 - glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].offset_rgba );
1.60 + glVertexPointer(3, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].x);
1.61 + glColorPointer(4, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].rgba[0]);
1.62 + glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].u);
1.63 + glSecondaryColorPointerEXT(3, GL_FLOAT, sizeof(struct vertex_struct), pvr2_scene.vertex_array[0].offset_rgba );
1.64
1.65 /* Turn on the shaders (if available) */
1.66 glsl_enable_shaders(TRUE);
1.67
1.68 - uint32_t bgplane_mode = MMIO_READ(PVR2, RENDER_BGPLANE);
1.69 - uint32_t *bgplane = pvr2_scene.pvr2_pbuf + (((bgplane_mode & 0x00FFFFFF)) >> 3) ;
1.70 - render_backplane( bgplane, pvr2_scene.buffer_width, pvr2_scene.buffer_height, bgplane_mode );
1.71 + /* Render the background */
1.72 + gl_render_bkgnd( pvr2_scene.bkgnd_poly );
1.73
1.74 glEnable( GL_SCISSOR_TEST );
1.75
.