@@ -700,9 +700,11 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text
700700
701701 Player *player = rts::getObservedOrLocalPlayer ();
702702
703+ SurfaceClass::SurfaceDescription surfaceDesc;
704+ surface->Get_Description (surfaceDesc);
703705 int pitch;
704706 void *pBits = surface->Lock (&pitch);
705- const unsigned int bytesPerPixel = surface-> Get_Bytes_Per_Pixel ();
707+ const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel (surfaceDesc. Format );
706708
707709 for ( const RadarObject *rObj = listHead; rObj; rObj = rObj->friend_getNext () )
708710 {
@@ -718,7 +720,7 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text
718720 radarPoint.y = pos->y / (m_mapExtent.height () / RADAR_CELL_HEIGHT);
719721
720722 // get the color we're going to draw in
721- Color c = rObj->getColor ();
723+ Color argbColor = rObj->getColor ();
722724
723725 // adjust the alpha for stealth units so they "fade/blink" on the radar for the controller
724726 // if( obj->getRadarPriority() == RADAR_PRIORITY_LOCAL_UNIT_ONLY )
@@ -727,7 +729,7 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text
727729 if ( obj->testStatus ( OBJECT_STATUS_STEALTHED ) )
728730 {
729731 UnsignedByte r, g, b, a;
730- GameGetColorComponents ( c , &r, &g, &b, &a );
732+ GameGetColorComponents ( argbColor , &r, &g, &b, &a );
731733
732734 const UnsignedInt framesForTransition = LOGICFRAMES_PER_SECOND;
733735 const UnsignedByte minAlpha = 32 ;
@@ -737,25 +739,27 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text
737739 a = REAL_TO_UNSIGNEDBYTE ( ((alphaScale - 1 .0f ) * (255 .0f - minAlpha)) + minAlpha );
738740 else
739741 a = REAL_TO_UNSIGNEDBYTE ( (alphaScale * (255 .0f - minAlpha)) + minAlpha );
740- c = GameMakeColor ( r, g, b, a );
742+ argbColor = GameMakeColor ( r, g, b, a );
741743
742744 }
743745
746+ const unsigned int pixelColor = ARGB_Color_To_WW3D_Color (surfaceDesc.Format , argbColor);
747+
744748 // draw the blip, but make sure the points are legal
745749 if ( legalRadarPoint ( radarPoint.x , radarPoint.y ) )
746- surface->Draw_Pixel ( radarPoint.x , radarPoint.y , c , bytesPerPixel, pBits, pitch );
750+ surface->Draw_Pixel ( radarPoint.x , radarPoint.y , pixelColor , bytesPerPixel, pBits, pitch );
747751
748752 radarPoint.y ++;
749753 if ( legalRadarPoint ( radarPoint.x , radarPoint.y ) )
750- surface->Draw_Pixel ( radarPoint.x , radarPoint.y , c , bytesPerPixel, pBits, pitch );
754+ surface->Draw_Pixel ( radarPoint.x , radarPoint.y , pixelColor , bytesPerPixel, pBits, pitch );
751755
752756 radarPoint.x ++;
753757 if ( legalRadarPoint ( radarPoint.x , radarPoint.y ) )
754- surface->Draw_Pixel ( radarPoint.x , radarPoint.y , c , bytesPerPixel, pBits, pitch );
758+ surface->Draw_Pixel ( radarPoint.x , radarPoint.y , pixelColor , bytesPerPixel, pBits, pitch );
755759
756760 radarPoint.y --;
757761 if ( legalRadarPoint ( radarPoint.x , radarPoint.y ) )
758- surface->Draw_Pixel ( radarPoint.x , radarPoint.y , c , bytesPerPixel, pBits, pitch );
762+ surface->Draw_Pixel ( radarPoint.x , radarPoint.y , pixelColor , bytesPerPixel, pBits, pitch );
759763
760764 }
761765
@@ -860,6 +864,7 @@ W3DRadar::W3DRadar( void )
860864 m_shroudSurface = nullptr ;
861865 m_shroudSurfaceBits = nullptr ;
862866 m_shroudSurfacePitch = 0 ;
867+ m_shroudSurfaceFormat = WW3D_FORMAT_UNKNOWN;
863868 m_shroudSurfacePixelSize = 0 ;
864869
865870 m_textureWidth = RADAR_CELL_WIDTH;
@@ -1078,9 +1083,11 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain )
10781083 Coord3D worldPoint;
10791084 Bridge *bridge;
10801085
1086+ SurfaceClass::SurfaceDescription surfaceDesc;
1087+ surface->Get_Description (surfaceDesc);
10811088 int pitch;
10821089 void *pBits = surface->Lock (&pitch);
1083- const unsigned int bytesPerPixel = surface-> Get_Bytes_Per_Pixel ();
1090+ const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel (surfaceDesc. Format );
10841091
10851092 for ( y = 0 ; y < m_textureHeight; y++ )
10861093 {
@@ -1269,7 +1276,8 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain )
12691276
12701277 // draw the pixel for the terrain at this point, note that because of the orientation
12711278 // of our world we draw it with positive y in the "up" direction
1272- Color pixelColor = GameMakeColor ( color.red * 255 , color.green * 255 , color.blue * 255 , 255 );
1279+ const Color argbColor = GameMakeColor ( color.red * 255 , color.green * 255 , color.blue * 255 , 255 );
1280+ const unsigned int pixelColor = ARGB_Color_To_WW3D_Color (surfaceDesc.Format , argbColor);
12731281 surface->Draw_Pixel ( x, y, pixelColor, bytesPerPixel, pBits, pitch );
12741282
12751283 }
@@ -1364,16 +1372,19 @@ void W3DRadar::setShroudLevel(Int shroudX, Int shroudY, CellShroudStatus setting
13641372 // This is expensive.
13651373 SurfaceClass* surface = m_shroudTexture->Get_Surface_Level ();
13661374 DEBUG_ASSERTCRASH ( surface, (" W3DRadar: Can't get surface for Shroud texture" ) );
1375+ SurfaceClass::SurfaceDescription surfaceDesc;
1376+ surface->Get_Description (surfaceDesc);
13671377 int pitch;
13681378 void *pBits = surface->Lock (&pitch);
1369- const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel ();
1370- const Color color = GameMakeColor ( 0 , 0 , 0 , alpha );
1379+ const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel (surfaceDesc.Format );
1380+ const Color argbColor = GameMakeColor ( 0 , 0 , 0 , alpha );
1381+ const unsigned int pixelColor = ARGB_Color_To_WW3D_Color (surfaceDesc.Format , argbColor);
13711382
13721383 for ( Int y = radarMinY; y <= radarMaxY; ++y )
13731384 {
13741385 for ( Int x = radarMinX; x <= radarMaxX; ++x )
13751386 {
1376- surface->Draw_Pixel ( x, y, color , bytesPerPixel, pBits, pitch );
1387+ surface->Draw_Pixel ( x, y, pixelColor , bytesPerPixel, pBits, pitch );
13771388 }
13781389 }
13791390
@@ -1384,14 +1395,16 @@ void W3DRadar::setShroudLevel(Int shroudX, Int shroudY, CellShroudStatus setting
13841395 {
13851396 // This is cheap.
13861397 DEBUG_ASSERTCRASH (m_shroudSurfaceBits != nullptr , (" W3DRadar::setShroudLevel: m_shroudSurfaceBits is not expected null" ));
1398+ DEBUG_ASSERTCRASH (m_shroudSurfaceFormat != WW3D_FORMAT_UNKNOWN, (" W3DRadar::setShroudLevel: m_shroudSurfaceFormat is not expected UNKNOWN" ));
13871399 DEBUG_ASSERTCRASH (m_shroudSurfacePixelSize != 0 , (" W3DRadar::setShroudLevel: m_shroudSurfacePixelSize is not expected 0" ));
1388- const Color color = GameMakeColor ( 0 , 0 , 0 , alpha );
1400+ const Color argbColor = GameMakeColor ( 0 , 0 , 0 , alpha );
1401+ const unsigned int pixelColor = ARGB_Color_To_WW3D_Color (m_shroudSurfaceFormat, argbColor);
13891402
13901403 for ( Int y = radarMinY; y <= radarMaxY; ++y )
13911404 {
13921405 for ( Int x = radarMinX; x <= radarMaxX; ++x )
13931406 {
1394- m_shroudSurface->Draw_Pixel ( x, y, color , m_shroudSurfacePixelSize, m_shroudSurfaceBits, m_shroudSurfacePitch );
1407+ m_shroudSurface->Draw_Pixel ( x, y, pixelColor , m_shroudSurfacePixelSize, m_shroudSurfaceBits, m_shroudSurfacePitch );
13951408 }
13961409 }
13971410 }
@@ -1403,10 +1416,11 @@ void W3DRadar::beginSetShroudLevel()
14031416 m_shroudSurface = m_shroudTexture->Get_Surface_Level ();
14041417 DEBUG_ASSERTCRASH ( m_shroudSurface != nullptr , (" W3DRadar::beginSetShroudLevel: Can't get surface for Shroud texture" ) );
14051418
1406- SurfaceClass::SurfaceDescription sd ;
1407- m_shroudSurface->Get_Description (sd );
1419+ SurfaceClass::SurfaceDescription surfaceDesc ;
1420+ m_shroudSurface->Get_Description (surfaceDesc );
14081421 m_shroudSurfaceBits = m_shroudSurface->Lock (&m_shroudSurfacePitch);
1409- m_shroudSurfacePixelSize = Get_Bytes_Per_Pixel (sd.Format );
1422+ m_shroudSurfaceFormat = surfaceDesc.Format ;
1423+ m_shroudSurfacePixelSize = Get_Bytes_Per_Pixel (surfaceDesc.Format );
14101424}
14111425
14121426void W3DRadar::endSetShroudLevel ()
@@ -1417,6 +1431,7 @@ void W3DRadar::endSetShroudLevel()
14171431 m_shroudSurface->Unlock ();
14181432 m_shroudSurfaceBits = nullptr ;
14191433 m_shroudSurfacePitch = 0 ;
1434+ m_shroudSurfaceFormat = WW3D_FORMAT_UNKNOWN;
14201435 m_shroudSurfacePixelSize = 0 ;
14211436 }
14221437 REF_PTR_RELEASE (m_shroudSurface);
0 commit comments