Moved program icon drawing into handmade layer.

This commit is contained in:
2026-05-29 15:24:46 -07:00
parent 94e20cdff5
commit 1ba8acfe51
5 changed files with 48 additions and 169 deletions
+16 -3
View File
@@ -123,7 +123,7 @@ static void DrawBitmap(game_offscreen_buffer *Buffer, loaded_bitmap *Bitmap, F32
U32 *Dest = (U32 *)DestRow;
U32 *Source = SourceRow;
for(S32 X = MinX; X < MaxX; X++) {
F32 A = (F32)((*Source >> 24) & 0xFF) / 255.0f;
F32 SA = (F32)((*Source >> 24) & 0xFF);
F32 SR = (F32)((*Source >> 16) & 0xFF);
F32 SG = (F32)((*Source >> 8) & 0xFF);
F32 SB = (F32)((*Source >> 0) & 0xFF);
@@ -132,12 +132,14 @@ static void DrawBitmap(game_offscreen_buffer *Buffer, loaded_bitmap *Bitmap, F32
F32 DG = (F32)((*Dest >> 8) & 0xFF);
F32 DB = (F32)((*Dest >> 0) & 0xFF);
F32 A = SA / 255.0f;
// TODO: This should be replaced by premultiplied alpha.
F32 R = (1.0f-A)*DR + A*SR;
F32 G = (1.0f-A)*DG + A*SG;
F32 B = (1.0f-A)*DB + A*SB;
*Dest = (((U32)RoundF32toS32(R) << 16) | ((U32)RoundF32toS32(G) << 8) | ((U32)RoundF32toS32(B) << 0));
*Dest = (((U32)RoundF32toS32(SA) << 24) | ((U32)RoundF32toS32(R) << 16) | ((U32)RoundF32toS32(G) << 8) | ((U32)RoundF32toS32(B) << 0));
Dest++;
Source++;
@@ -234,7 +236,18 @@ void UpdateAndRender(thread_context *Thread, game_memory *Memory, game_input *In
GameState = (game_state *)Memory->PermanentStorage;
if(!Memory->IsInitialized) {
GameState->Backdrop = DEBUGLoadBMP(Thread, Memory->DEBUGPlatformReadEntireFile, "data/test_background.bmp");
GameState->ProgramIcon.Width = 256;
GameState->ProgramIcon.Height = 256;
GameState->ProgramIcon.BytesPerPixel = 4;
GameState->ProgramIcon.Pitch = GameState->ProgramIcon.BytesPerPixel * GameState->ProgramIcon.Width;
GameState->ProgramIcon.Memory = malloc(GameState->ProgramIcon.BytesPerPixel * GameState->ProgramIcon.Width * GameState->ProgramIcon.Height);
memset(GameState->ProgramIcon.Memory, 0, GameState->ProgramIcon.BytesPerPixel * GameState->ProgramIcon.Width * GameState->ProgramIcon.Height);
GameState->ProgramIconBMP = DEBUGLoadBMP(Thread, Memory->DEBUGPlatformReadEntireFile, "data/program_icon.bmp");
DrawBitmap(&GameState->ProgramIcon, &GameState->ProgramIconBMP, 0.0f, 0.0f, 0, 0);
Memory->SetProgramIcon(&GameState->ProgramIcon);
GameState->Backdrop = DEBUGLoadBMP(Thread, Memory->DEBUGPlatformReadEntireFile, "data/test_background.bmp");
hero_bitmaps *Bitmap;