Search
lxdream.org :: lxdream/src/pvr2/render.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/render.c
changeset 219:dfd3292143f2
prev191:df4441cf3128
next221:cf5c6d326162
author nkeynes
date Tue Aug 29 08:12:13 2006 +0000 (13 years ago)
permissions -rw-r--r--
last change Initial implementation of new background support
file annotate diff log raw
1.1 --- a/src/pvr2/render.c Wed Aug 02 06:24:08 2006 +0000
1.2 +++ b/src/pvr2/render.c Tue Aug 29 08:12:13 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: render.c,v 1.12 2006-08-02 06:24:08 nkeynes Exp $
1.6 + * $Id: render.c,v 1.13 2006-08-29 08:12:13 nkeynes Exp $
1.7 *
1.8 * PVR2 Renderer support. This part is primarily
1.9 *
1.10 @@ -223,43 +223,6 @@
1.11 #define MAX3( a,b,c ) ((a) > (b) ? ( (a) > (c) ? (a) : (c) ) : ((b) > (c) ? (b) : (c)) )
1.12
1.13 /**
1.14 - * Render the background plane as best we can. Unfortunately information
1.15 - * is a little scant, to say the least.
1.16 - */
1.17 -void pvr2_render_draw_backplane( uint32_t mode, uint32_t *poly )
1.18 -{
1.19 -
1.20 - if( (mode >> 24) == 0x01 ) {
1.21 - /* Packed colour. I think */
1.22 - pvr2_bgplane_packed_t bg = (pvr2_bgplane_packed_t)poly;
1.23 - if( bg->colour1 != bg->colour2 || bg->colour2 != bg->colour3 ) {
1.24 - WARN( "Multiple background colours specified. Confused" );
1.25 - fprintf( stderr, "bgplane mode: %08X PBUF: %08X\n", mode,
1.26 - MMIO_READ( PVR2, RENDER_POLYBASE ) );
1.27 - fwrite_dump( poly, 80, stderr );
1.28 - }
1.29 - float x1 = MIN3( bg->x1, bg->x2, bg->x3 );
1.30 - float y1 = MIN3( bg->y1, bg->y2, bg->y3 );
1.31 - float x2 = MAX3( bg->x1, bg->x2, bg->x3 );
1.32 - float y2 = MAX3( bg->y1, bg->y2, bg->y3 );
1.33 - float z = MIN3( bg->z1, bg->z2, bg->z3 );
1.34 - glDisable( GL_TEXTURE_2D );
1.35 - glDisable( GL_DEPTH_TEST );
1.36 - glColor3ub( (uint8_t)(bg->colour1 >> 16), (uint8_t)(bg->colour1 >> 8),
1.37 - (uint8_t)bg->colour1 );
1.38 - glBegin( GL_QUADS );
1.39 - glVertex3f( x1, y1, z );
1.40 - glVertex3f( x2, y1, z );
1.41 - glVertex3f( x2, y2, z );
1.42 - glVertex3f( x1, y2, z );
1.43 - glEnd();
1.44 - } else {
1.45 - WARN( "Unknown bgplane mode: %08X", mode );
1.46 - fwrite_dump( poly, 48, stderr );
1.47 - }
1.48 -}
1.49 -
1.50 -/**
1.51 * Render a complete scene into the OpenGL back buffer.
1.52 * Note: this will probably need to be broken up eventually once timings are
1.53 * determined.
1.54 @@ -305,7 +268,7 @@
1.55 (uint32_t *)mem_get_region(PVR2_RAM_BASE + MMIO_READ( PVR2, RENDER_POLYBASE ));
1.56
1.57 uint32_t *bgplane = display_list + (((bgplane_mode & 0x00FFFFFF)) >> 3) ;
1.58 - pvr2_render_draw_backplane( bgplane_mode, bgplane );
1.59 + render_backplane( bgplane, width, height, bgplane_mode );
1.60
1.61 pvr2_render_tilebuffer( width, height, clip_x, clip_y,
1.62 clip_x + clip_width, clip_y + clip_height );
1.63 @@ -336,32 +299,33 @@
1.64 if( buffer->render_addr == -1 )
1.65 return;
1.66 GLenum type, format = GL_RGBA;
1.67 - int size = buffer->width * buffer->height;
1.68 + int line_size = buffer->width, size;
1.69
1.70 switch( buffer->colour_format ) {
1.71 case COLFMT_RGB565:
1.72 type = GL_UNSIGNED_SHORT_5_6_5;
1.73 format = GL_RGB;
1.74 - size <<= 1;
1.75 + line_size <<= 1;
1.76 break;
1.77 case COLFMT_RGB888:
1.78 type = GL_UNSIGNED_INT;
1.79 format = GL_RGB;
1.80 - size = (size<<1)+size;
1.81 + line_size = (line_size<<1)+line_size;
1.82 break;
1.83 case COLFMT_ARGB1555:
1.84 type = GL_UNSIGNED_SHORT_5_5_5_1;
1.85 - size <<= 1;
1.86 + line_size <<= 1;
1.87 break;
1.88 case COLFMT_ARGB4444:
1.89 type = GL_UNSIGNED_SHORT_4_4_4_4;
1.90 - size <<= 1;
1.91 + line_size <<= 1;
1.92 break;
1.93 case COLFMT_ARGB8888:
1.94 type = GL_UNSIGNED_INT_8_8_8_8;
1.95 - size <<= 2;
1.96 + line_size <<= 2;
1.97 break;
1.98 }
1.99 + size = line_size * buffer->height;
1.100
1.101 if( backBuffer ) {
1.102 glFinish();
1.103 @@ -376,9 +340,10 @@
1.104 glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );
1.105 pvr2_vram64_write( buffer->render_addr, target, size );
1.106 } else {
1.107 - /* Regular buffer - go direct */
1.108 - char *target = mem_get_region( buffer->render_addr );
1.109 + /* Regular buffer */
1.110 + char target[size];
1.111 glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );
1.112 + pvr2_vram_write_invert( buffer->render_addr, target, size, line_size );
1.113 }
1.114 }
1.115
.