-
Notifications
You must be signed in to change notification settings - Fork 151
fix(radar): Fix Radar pixel color format for non A8R8B8G8 surfaces #2170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(radar): Fix Radar pixel color format for non A8R8B8G8 surfaces #2170
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp | Added ARGB_Color_To_WW3D_Color function to convert ARGB colors to various pixel formats |
| Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp | Updated radar rendering to convert ARGB colors to correct pixel format before writing to surface |
Sequence Diagram
sequenceDiagram
participant Radar as W3DRadar
participant Surface as SurfaceClass
participant Format as ARGB_Color_To_WW3D_Color
Note over Radar: renderObjectList() or<br/>buildTerrainTexture() or<br/>setShroudLevel()
Radar->>Surface: Get_Description(surfaceDesc)
Surface-->>Radar: Returns surface format info
Radar->>Radar: Get ARGB color
Note over Radar: argbColor = getColor() or<br/>GameMakeColor(r, g, b, a)
Radar->>Format: ARGB_Color_To_WW3D_Color(format, argbColor)
Note over Format: Convert ARGB to<br/>format-specific pixel value
Format-->>Radar: Returns converted pixel color
Radar->>Surface: Draw_Pixel(x, y, pixelColor, bytesPerPixel, pBits, pitch)
Note over Surface: Writes correctly<br/>formatted pixel to surface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (1)
-
Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp, line 1431 (link)style:
m_shroudSurfaceFormatshould be reset toWW3D_FORMAT_UNKNOWNhere for consistency with other cleanupNote: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
4 files reviewed, 1 comment
|
I've reviewed the implementation and verified the bit manipulation logic mathematically - the RGB565/ARGB4444 conversions are correct, and the luminance calculation properly follows ITU-R BT.601 standard (77R + 150G + 29B = 256). The function is applied consistently across all radar rendering paths (renderObjectList, buildTerrainTexture, setShroudLevel) and handles edge cases safely by returning 0 for unsupported formats. While the code path may rarely execute on modern hardware (which typically uses A8R8G8B8), this is solid defensive programming that ensures correctness for legacy systems and alternative DirectX configurations with zero performance penalty. |
Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp
Outdated
Show resolved
Hide resolved
0ba1ef5 to
64d1bf0
Compare
Skyaero42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good
This change converts ARGB Radar pixel colors into the correct format before writing them into the DirectX surface.
I have not been able to figure out how to get the game to use a non A8R8B8G8 surface on my machine, so I was not able to really confirm that this is a useful change.
But it seems like this is the correct thing to do.
The
ARGB_Color_To_WW3D_Colorfunction was mostly generated by Chad Gippi.