diff options
| author | aura <nw@moneybot.cc> | 2026-03-10 01:35:50 +0100 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-03-10 01:35:50 +0100 |
| commit | 8329d42d3e592f4cd42cdfa586e2325ddc76c898 (patch) | |
| tree | dec7e2a733bfc6b6384936c1f3ed067a42b59bb9 /src/render/gl.cpp | |
| parent | 8ae8c85e9d3806cdb726e07f37e1b49484c5c48e (diff) | |
perf profiler, simplify 2d render, string struct, many small things
Diffstat (limited to 'src/render/gl.cpp')
| -rw-r--r-- | src/render/gl.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/render/gl.cpp b/src/render/gl.cpp index 4e9ed9d..c1b6d19 100644 --- a/src/render/gl.cpp +++ b/src/render/gl.cpp @@ -19,11 +19,11 @@ GL_DATA* gl_instance() { return gl_inst; } -static void gl_apply_canvas_size( GL_DATA* gl, I32 width, I32 height ); -static void gl_handle_window_size_change( GL_DATA* gl, I32 width, I32 height ); -static void gl_update_screen_ratio_uniforms( GL_DATA* gl, I32 width, I32 height ); +void gl_apply_canvas_size( GL_DATA* gl, I32 width, I32 height ); +void gl_handle_window_size_change( GL_DATA* gl, I32 width, I32 height ); +void gl_update_screen_ratio_uniforms( GL_DATA* gl, I32 width, I32 height ); -static void gl_query_canvas_size( GL_DATA* gl, I32* width, I32* height ) { +void gl_query_canvas_size( GL_DATA* gl, I32* width, I32* height ) { I32 w = 0; I32 h = 0; if( gl && gl->window ) { @@ -36,7 +36,7 @@ static void gl_query_canvas_size( GL_DATA* gl, I32* width, I32* height ) { if( height ) *height = max( 1, h ); } -static void gl_constrain_window_size( I32* width, I32* height ) { +void gl_constrain_window_size( I32* width, I32* height ) { if( !width || !height ) return; @@ -61,7 +61,7 @@ static void gl_constrain_window_size( I32* width, I32* height ) { } } -static void gl_handle_window_size_change( GL_DATA* gl, I32 width, I32 height ) { +void gl_handle_window_size_change( GL_DATA* gl, I32 width, I32 height ) { if( !gl || !gl->window ) return; @@ -85,7 +85,7 @@ static void gl_handle_window_size_change( GL_DATA* gl, I32 width, I32 height ) { gl_apply_canvas_size( gl, draw_w, draw_h ); } -static I32 SDLCALL gl_event_filter( void* userdata, SDL_Event* e ) { +I32 SDLCALL gl_event_filter( void* userdata, SDL_Event* e ) { GL_DATA* gl = (GL_DATA*)userdata; if( !gl || !e ) return 1; @@ -106,7 +106,7 @@ static I32 SDLCALL gl_event_filter( void* userdata, SDL_Event* e ) { return 1; } -static void gl_apply_canvas_size( GL_DATA* gl, I32 width, I32 height ) { +void gl_apply_canvas_size( GL_DATA* gl, I32 width, I32 height ) { width = max( 1, width ); height = max( 1, height ); @@ -126,7 +126,7 @@ static void gl_apply_canvas_size( GL_DATA* gl, I32 width, I32 height ) { glUseProgram( 0 ); } -static void gl_update_screen_ratio_uniforms( GL_DATA* gl, I32 width, I32 height ) { +void gl_update_screen_ratio_uniforms( GL_DATA* gl, I32 width, I32 height ) { F32 screen_ratio[] = { 2.f / (F32)max( 1, width ), 2.f / (F32)max( 1, height ), @@ -486,13 +486,14 @@ STAT gl_endframe( GL_DATA* gl ) { // 1000 fps max be real while( true ) { U64 diff = u_tick() - gl->last_tick; - if( diff < 10 ) + if( diff < TICK_RESOLUTION / 1000 ) usleep( 10 ); else break; } - gl->frametime = (F32)(u_tick() - gl->last_tick) / 10000.0f; - gl->fps = 1.0f / gl->frametime; + F64 delta = (F64)(u_tick() - gl->last_tick) / TICK_RESOLUTION; + gl->frametime = (F32)delta; + gl->fps = 1.f / delta; input_frame_end(); return STAT_OK; |
