revision 113:ce4eb7959d56
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 113:ce4eb7959d56 |
parent | 112:a3008ac0765a |
child | 114:1cc849575bc7 |
author | nkeynes |
date | Thu Mar 16 12:42:39 2006 +0000 (16 years ago) |
Various fixes to make tatest work
1.1 --- a/src/pvr2/render.c Thu Mar 16 12:42:28 2006 +00001.2 +++ b/src/pvr2/render.c Thu Mar 16 12:42:39 2006 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: render.c,v 1.3 2006-03-15 13:16:50 nkeynes Exp $1.6 + * $Id: render.c,v 1.4 2006-03-16 12:42:39 nkeynes Exp $1.7 *1.8 * PVR2 Renderer support. This is where the real work happens.1.9 *1.10 @@ -272,7 +272,6 @@1.11 glBegin( GL_TRIANGLES );1.12 else1.13 glBegin( GL_TRIANGLE_STRIP );1.14 - fprintf( stderr, "Begin %d\n", expect_vertexes );1.15 break;1.16 case PVR2_CMD_VERTEX_LAST:1.17 case PVR2_CMD_VERTEX:1.18 @@ -282,17 +281,13 @@1.19 }1.20 expect_vertexes--;1.21 struct pvr2_vertex_basic *vertex = (struct pvr2_vertex_basic *)cmd_ptr;1.22 - fprintf( stderr, "(%f,%f,%f)", vertex->x, vertex->y, vertex->z );1.23 if( textured ) {1.24 - fprintf( stderr, "{%f,%f}", vertex->s, vertex->t );1.25 glTexCoord2f( vertex->s, vertex->t );1.26 }1.27 - fprintf( stderr, "\n" );1.28 glVertex3f( vertex->x, vertex->y, vertex->z );1.30 if( expect_vertexes == 0 ) {1.31 glEnd();1.32 - fprintf( stderr, "End" );1.33 }1.34 break;1.35 }
2.1 --- a/src/pvr2/texcache.c Thu Mar 16 12:42:28 2006 +00002.2 +++ b/src/pvr2/texcache.c Thu Mar 16 12:42:39 2006 +00002.3 @@ -1,5 +1,5 @@2.4 /**2.5 - * $Id: texcache.c,v 1.3 2006-03-15 13:16:50 nkeynes Exp $2.6 + * $Id: texcache.c,v 1.4 2006-03-16 12:42:39 nkeynes Exp $2.7 *2.8 * Texture cache. Responsible for maintaining a working set of OpenGL2.9 * textures.2.10 @@ -179,6 +179,21 @@2.11 return slot;2.12 }2.14 +static void detwiddle_pal8_to_24(int x1, int y1, int size, int totsize,2.15 + char **in, uint32_t *out, uint32_t *pal) {2.16 + if (size == 1) {2.17 + out[y1 * totsize + x1] = pal[**in];2.18 + (*in)++;2.19 + } else {2.20 + int ns = size>>1;2.21 + detwiddle_pal8_to_24(x1, y1, ns, totsize, in, out, pal);2.22 + detwiddle_pal8_to_24(x1, y1+ns, ns, totsize, in, out, pal);2.23 + detwiddle_pal8_to_24(x1+ns, y1, ns, totsize, in, out, pal);2.24 + detwiddle_pal8_to_24(x1+ns, y1+ns, ns, totsize, in, out, pal);2.25 + }2.26 +}2.27 +2.28 +2.29 /**2.30 * Load texture data from the given address and parameters into the currently2.31 * bound OpenGL texture.2.32 @@ -210,24 +225,29 @@2.33 break;2.34 case 3:2.35 intFormat = GL_RGBA8;2.36 - format = GL_RGBA;2.37 - type = GL_UNSIGNED_INT_8_8_8_8;2.38 + format = GL_BGRA;2.39 + type = GL_UNSIGNED_INT_8_8_8_8_REV;2.40 shift = 2;2.41 break;2.42 }2.44 if( tex_format == PVR2_TEX_FORMAT_IDX8 ) {2.45 + unsigned char data[bytes<<shift];2.46 int bank = (mode >> 25) &0x03;2.47 - unsigned char data[bytes<<shift];2.48 char *palette = mmio_region_PVR2PAL.mem + (bank * (256 << shift));2.49 int i;2.50 - pvr2_vram64_read( &data, texture_addr, bytes );2.51 - for( i=bytes-1; i>=0; i-- ) {2.52 - char ch = data[i];2.53 - if( shift == 2 )2.54 - ((uint32_t *)data)[i] = ((uint32_t *)palette)[ch];2.55 - else2.56 + if( shift == 2 ) {2.57 + char tmp[bytes];2.58 + char *p = tmp;2.59 + pvr2_vram64_read( tmp, texture_addr, bytes );2.60 + detwiddle_pal8_to_24( 0, 0, width, width, &p,2.61 + (uint32_t *)data, (uint32_t *)palette );2.62 + } else {2.63 + pvr2_vram64_read( &data, texture_addr, bytes );2.64 + for( i=bytes-1; i>=0; i-- ) {2.65 + char ch = data[i];2.66 ((uint16_t *)data)[i] = ((uint16_t *)palette)[ch];2.67 + }2.68 }2.69 /* TODO: Detwiddle */2.70 glTexImage2D( GL_TEXTURE_2D, 0, intFormat, width, height, 0, format, type,
.