Game Development Community

GBitmap GetColor bug

by Jeremiah Fulbright · in Torque Game Engine Advanced · 12/23/2006 (2:21 pm) · 0 replies

I had noticed this before and changed it in our codebase, but hadn't posted/asked about it.

In GBitmap.cpp - GBitmap::getColor:

case GFXFormatR8G8B8:
     case GFXFormatR8G8B8X8:
      rColor.set( pLoc[0], pLoc[1], pLoc[2], 255 );
      break;

     case GFXFormatR8G8B8A8:
      rColor.set( pLoc[0], pLoc[1], pLoc[2], pLoc[3] );
      break;

That is the current code, but when I checked rColor while Debugging, the color values being returned seemed to be in the wrong order, since RGBA isn't stored that way in DirectX.

The changes I made were:

case GFXFormatR8G8B8:
     case GFXFormatR8G8B8X8:
	  rColor.set( pLoc[2], pLoc[1], pLoc[0], 255 ); // this seems to be proper - byte
      break;

     case GFXFormatR8G8B8A8:
	  rColor.set( pLoc[2], pLoc[1], pLoc[0], pLoc[3] ); // this is correct - byte
      break;

This could be totally wrong, but based on what rColor was getting set to, it seems to be backwards/improper