summaryrefslogtreecommitdiff
path: root/src/render/gl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/gl.cpp')
-rw-r--r--src/render/gl.cpp25
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;