Skip to content

Commit 36d5c80

Browse files
committed
correction of input , add window_occlusion_culled
1 parent 8760271 commit 36d5c80

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

grngame/core/app.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static void InitializeAppState(const AppInfo *app_info)
3939
g_app.info = *app_info;
4040
g_app.info.offset_x = 0;
4141
g_app.info.offset_y = 0;
42+
g_app.info.window_occlusion_culled =false;
4243

4344
g_app.window = WindowCreate(&g_app.info);
4445
if (UNLIKELY(!g_app.window))
@@ -120,13 +121,14 @@ static void MainLoop()
120121
fixed_accumulator -= fixed_dt;
121122
}
122123
}
124+
if(!g_app.info.window_occlusion_culled){
125+
RendererClear(&g_app.renderer);
123126

124-
RendererClear(&g_app.renderer);
127+
DaScriptManagerCallOnRender(g_app.da_script);
128+
ApplyBlackStripes();
125129

126-
DaScriptManagerCallOnRender(g_app.da_script);
127-
ApplyBlackStripes();
128-
129-
RendererPresent(&g_app.renderer);
130+
RendererPresent(&g_app.renderer);
131+
}
130132
ClearAll();
131133
uint64 frame_end = SDL_GetTicks();
132134
float64 frame_ms = (float64)(frame_end - frame_start);

grngame/core/app.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef struct
2727
bool window_fullscreen;
2828
bool window_maximised;
2929
bool window_change;
30+
bool window_occlusion_culled;
3031

3132
float32 offset_x;
3233
float32 offset_y;

grngame/input/poll_events.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ static void ResetInputManagerKeys()
2828
im->mouse.right_just_pressed = false;
2929
im->mouse.scroll_x = 0;
3030
im->mouse.scroll_y = 0;
31-
CLEAR_PTR(im->key_just_pressed);
31+
CLEAR(im->key_just_pressed);
3232
for (int i = 0; i < MAX_CONTROLLERS; i++)
33-
CLEAR_PTR(im->controllers[i].just_pressed);
33+
CLEAR(im->controllers[i].just_pressed);
3434
}
3535

3636
static void UpdateMousePosition()
@@ -83,6 +83,14 @@ void PollEvents()
8383
ApplyResizing(&g_app.info, (int16)i.x, (int16)i.y);
8484
break;
8585
}
86+
case SDL_EVENT_WINDOW_MINIMIZED:{
87+
g_app.info.window_occlusion_culled =true;
88+
break;
89+
}
90+
case SDL_EVENT_WINDOW_RESTORED:{
91+
g_app.info.window_occlusion_culled =false;
92+
break;
93+
}
8694
case SDL_EVENT_KEY_DOWN:
8795
if (!event.key.repeat)
8896
{

grngame/utils/clear.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
void ClearAll()
55
{
66
CLEAR(g_app.info.window_change);
7+
78
}

tests/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int main()
1818
app.window_maximised = false;
1919
app.enable_logs = true;
2020
app.log_destination = LOG_TO_CONSOLE;
21-
app.force_universe_scale = false;
21+
app.force_universe_scale = true;
2222
EngineStart(&app);
2323
return 0;
2424
}

0 commit comments

Comments
 (0)