revision 126:988003554ab5
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 126:988003554ab5 |
parent | 125:49bf45f8210a |
child | 127:4ba79389bb6d |
author | nkeynes |
date | Thu Mar 23 13:18:51 2006 +0000 (18 years ago) |
Add correct support for ARGB4444 direct colour
1.1 --- a/src/pvr2/texcache.c Wed Mar 22 14:29:02 2006 +00001.2 +++ b/src/pvr2/texcache.c Thu Mar 23 13:18:51 2006 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: texcache.c,v 1.4 2006-03-16 12:42:39 nkeynes Exp $1.6 + * $Id: texcache.c,v 1.5 2006-03-23 13:18:51 nkeynes Exp $1.7 *1.8 * Texture cache. Responsible for maintaining a working set of OpenGL1.9 * textures.1.10 @@ -193,6 +193,20 @@1.11 }1.12 }1.14 +static void detwiddle_16_to_16(int x1, int y1, int size, int totsize,1.15 + uint16_t **in, uint16_t *out ) {1.16 + if (size == 1) {1.17 + out[y1 * totsize + x1] = **in;1.18 + (*in)++;1.19 + } else {1.20 + int ns = size>>1;1.21 + detwiddle_16_to_16(x1, y1, ns, totsize, in, out);1.22 + detwiddle_16_to_16(x1, y1+ns, ns, totsize, in, out);1.23 + detwiddle_16_to_16(x1+ns, y1, ns, totsize, in, out);1.24 + detwiddle_16_to_16(x1+ns, y1+ns, ns, totsize, in, out);1.25 + }1.26 +}1.27 +1.29 /**1.30 * Load texture data from the given address and parameters into the currently1.31 @@ -248,8 +262,8 @@1.32 char ch = data[i];1.33 ((uint16_t *)data)[i] = ((uint16_t *)palette)[ch];1.34 }1.35 + /* FIXME */1.36 }1.37 - /* TODO: Detwiddle */1.38 glTexImage2D( GL_TEXTURE_2D, 0, intFormat, width, height, 0, format, type,1.39 data );1.41 @@ -271,8 +285,8 @@1.42 case PVR2_TEX_FORMAT_ARGB4444:1.43 bytes <<= 1;1.44 intFormat = GL_RGBA4;1.45 - format = GL_RGBA;1.46 - type = GL_UNSIGNED_SHORT_4_4_4_4;1.47 + format = GL_BGRA;1.48 + type = GL_UNSIGNED_SHORT_4_4_4_4_REV;1.49 break;1.50 case PVR2_TEX_FORMAT_YUV422:1.51 ERROR( "YUV textures not supported" );1.52 @@ -301,9 +315,14 @@1.53 if( PVR2_TEX_IS_COMPRESSED(mode) ) {1.54 ERROR( "VQ Compression not supported" );1.55 } else {1.56 - pvr2_vram64_read( &data, texture_addr, bytes );1.57 if( PVR2_TEX_IS_TWIDDLED(mode) ) {1.58 + char tmp[bytes];1.59 + uint16_t *p = (uint16_t *)tmp;1.60 + pvr2_vram64_read( tmp, texture_addr, bytes );1.61 /* Untwiddle */1.62 + detwiddle_16_to_16( 0, 0, width, width, &p, (uint16_t *)&data );1.63 + } else {1.64 + pvr2_vram64_read( data, texture_addr, bytes );1.65 }1.66 }
.