From 49f76c732d2c4ba2f7f772656831f1855521417c Mon Sep 17 00:00:00 2001 From: hgn Date: Thu, 6 Apr 2023 03:13:47 +0100 Subject: [PATCH] test for variable render scale --- common.h | 3 +++ skaterift.c | 9 ++++++++- world_water.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common.h b/common.h index 9eda6f6..24c7815 100644 --- a/common.h +++ b/common.h @@ -120,6 +120,9 @@ VG_STATIC int k_debug_light_indices = 0, k_debug_light_complexity = 0, k_light_preview = 0; +VG_STATIC int g_render_x = 1, + g_render_y = 1; + VG_STATIC int freecam = 0; VG_STATIC int walk_grid_iterations = 1; VG_STATIC float fc_speed = 10.0f; diff --git a/skaterift.c b/skaterift.c index 1db6db5..00dbb11 100644 --- a/skaterift.c +++ b/skaterift.c @@ -250,6 +250,7 @@ VG_STATIC void vg_load(void) /* 'systems' are completely loaded now */ /* load home world */ + //world_load( &world_global.worlds[0], "maps/mp_gridmap.mdl" ); world_load( &world_global.worlds[0], "maps/mp_mtzero.mdl" ); #if 0 @@ -485,6 +486,7 @@ VG_STATIC void render_player_transparent(void) VG_STATIC void render_scene(void) { render_fb_bind( gpipeline.fb_main ); + glViewport( 0,0, g_render_x, g_render_y ); glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT ); @@ -504,6 +506,7 @@ VG_STATIC void render_scene(void) render_water_texture( view_world, &main_camera, 0 ); render_fb_bind( gpipeline.fb_main ); + glViewport( 0,0, g_render_x, g_render_y ); render_water_surface( view_world, &main_camera ); int depth = 1; @@ -585,7 +588,11 @@ VG_STATIC void vg_render(void) { glBindFramebuffer( GL_FRAMEBUFFER, 0 ); - glViewport( 0,0, vg.window_x, vg.window_y ); + float scale = (sin(vg.time)*0.5f+0.5f)*0.75f+0.25f; + g_render_x = VG_MAX((float)vg.window_x * scale,64), + g_render_y = VG_MAX((float)vg.window_y * scale,64); + + glViewport( 0,0, g_render_x, g_render_y ); glDisable( GL_DEPTH_TEST ); glClearColor( 1.0f, 0.0f, 0.0f, 0.0f ); diff --git a/world_water.h b/world_water.h index 5dd1b91..7d67b13 100644 --- a/world_water.h +++ b/world_water.h @@ -121,7 +121,7 @@ VG_STATIC void render_water_texture( world_instance *world, camera *cam, glEnable( GL_DEPTH_TEST ); glDisable( GL_BLEND ); render_world_depth( world, &beneath_cam ); - glViewport( 0, 0, vg.window_x, vg.window_y ); + glViewport( 0,0, g_render_x, g_render_y ); } VG_STATIC void render_water_surface( world_instance *world, camera *cam ) -- 2.25.1