Karl Lessard wrote:
> 
> Hi everybody,
> 
> this patch fixes some problems in texturing in the mga driver.
> 
> 1) It fixes a texture corruption problem, as the mga driver did not use
> the right texture format in some case
>       ( I've seen that when an application wants to store a texture in
> RGB5_A1, but it is actually stored in ARGB8 by Mesa).
> 

RGB5_A1 isnt handled in mgatexconv.c
i made a patch.

-- 
ralf willenbacher ([EMAIL PROTECTED])
--- mga/mgacontext.h    Tue May  1 21:39:09 2001
+++ mga2/mgacontext.h   Sat Jun 16 01:27:07 2001
@@ -271,6 +271,9 @@
 #define MGAPACKCOLOR4444(r,g,b,a) \
   ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
 
+#define MGAPACKCOLOR1555(r,g,b,a) \
+  ((((a) & 0x80) << 8) | (((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | ((b) >> 3))
+
 
 #define MGA_DEBUG 0
 #ifndef MGA_DEBUG
--- mga/mgatexcnv.c     Tue May  1 21:39:10 2001
+++ mga2/mgatexcnv.c    Sat Jun 16 15:00:38 2001
@@ -98,14 +98,27 @@
       case GL_RGBA:
         src = (GLubyte *)image->Data + ( y * image->Width + x ) * 4;
         stride = (image->Width - width) * 4;
-        for ( i = height ; i ; i-- ) {
-           for ( j = width >> 1  ; j ; j-- ) {
+         if(image->IntFormat == GL_RGB5_A1)
+        {
+          for ( i = height ; i ; i-- ) {
+             for ( j = width >> 1  ; j ; j-- ) {
 
-              *destPtr++ = MGAPACKCOLOR4444(src[0],src[1],src[2],src[3]) |
-                 ( MGAPACKCOLOR4444(src[4],src[5],src[6],src[7]) << 16 );
-              src += 8;
+                *destPtr++ = MGAPACKCOLOR1555(src[0],src[1],src[2],src[3]) |
+                   ( MGAPACKCOLOR1555(src[4],src[5],src[6],src[7]) << 16 );
+                src += 8;
+             }
+             src += stride;
+           }
+        }else {
+          for ( i = height ; i ; i-- ) {
+             for ( j = width >> 1  ; j ; j-- ) {
+
+                *destPtr++ = MGAPACKCOLOR4444(src[0],src[1],src[2],src[3]) |
+                   ( MGAPACKCOLOR4444(src[4],src[5],src[6],src[7]) << 16 );
+                src += 8;
+             }
+             src += stride;
            }
-           src += stride;
         }
         break;
       case GL_LUMINANCE:

Reply via email to