Day 25 done.

This commit is contained in:
2026-03-25 14:33:23 -07:00
parent 64ccae4637
commit 4be3d0df80
5 changed files with 182 additions and 64 deletions
+39 -7
View File
@@ -63,17 +63,39 @@ static void RenderWeirdGradient(game_offscreen_buffer *Buffer, S32 XOffset,
}
}
void UpdateAndRender(game_memory *Memory, game_input *Input,
game_offscreen_buffer *Buffer,
static void RenderRectangle(game_offscreen_buffer *Buffer, S32 MouseX,
S32 MouseY)
{
U8 *Row;
U32 *Pixel;
S32 X, Y;
for(Y = MouseY; Y < MouseY+10; Y++) {
if(Y >= Buffer->Height)
break;
Row = (U8 *)Buffer->Memory + (Buffer->Pitch * Y);
for(X = MouseX; X < MouseX+10; X++) {
if(X >= Buffer->Width)
break;
Pixel = (U32 *)Row + X;
*Pixel = 0xFFFFFF;
}
}
}
void UpdateAndRender(thread_context *Thread, game_memory *Memory,
game_input *Input, game_offscreen_buffer *Buffer,
game_sound_output_buffer *SoundBuffer)
{
game_state *GameState;
U32 ControllerIndex;
Assert((&Input->Controllers[0].u.buttons.Terminator -
ASSERT((&Input->Controllers[0].u.buttons.Terminator -
&Input->Controllers[0].u.Buttons[0]) ==
ARRAY_SIZE(Input->Controllers[0].u.Buttons));
Assert(sizeof(game_state) <= Memory->PermanentStorageSize);
ASSERT(sizeof(game_state) <= Memory->PermanentStorageSize);
GameState = (game_state *)Memory->PermanentStorage;
if(!Memory->IsInitialized) {
@@ -82,12 +104,13 @@ void UpdateAndRender(game_memory *Memory, game_input *Input,
debug_read_file_result BitmapMemory;
FileName = "/home/igor/Developer/handmade/sdl_handmade.cpp";
BitmapMemory = Memory->DEBUGPlatformReadEntireFile(FileName);
BitmapMemory = Memory->DEBUGPlatformReadEntireFile(Thread, FileName);
if(BitmapMemory.Contents) {
Memory->DEBUGPlatformWriteEntireFile("test.out",
Memory->DEBUGPlatformWriteEntireFile(Thread, "test.out",
BitmapMemory.ContentsSize,
BitmapMemory.Contents);
Memory->DEBUGPlatformFreeFileMemory(BitmapMemory.Contents);
Memory->DEBUGPlatformFreeFileMemory(Thread,
BitmapMemory.Contents);
}
#endif
@@ -133,4 +156,13 @@ void UpdateAndRender(game_memory *Memory, game_input *Input,
GameOutputSound(GameState, SoundBuffer, GameState->ToneHz);
RenderWeirdGradient(Buffer, GameState->BlueOffset,
GameState->GreenOffset);
{
S32 i;
for(i = 0; i < (S32)ARRAY_SIZE(Input->MouseButtons); i++) {
if(Input->MouseButtons[i].EndedDown)
RenderRectangle(Buffer, 10 + 20 * i, 10);
}
}
RenderRectangle(Buffer, Input->MouseX, Input->MouseY);
}