From 324c4240d7fbf988725c036d461e54cdaa5317e5 Mon Sep 17 00:00:00 2001 From: Jason Hilder Date: Wed, 9 Sep 2026 07:18:31 +0200 Subject: [PATCH] Added offscreen rendering. --- src/game.odin | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/game.odin b/src/game.odin index 6e07d78..0de74e5 100644 --- a/src/game.odin +++ b/src/game.odin @@ -2,22 +2,19 @@ package game import rl "vendor:raylib" -WINDOW_TITLE :: "Pong" - -// good 16:9 baseline res, scales up to 1080 or 4k clean. +// good 16:9 internal res, window scales up to 1080/4k clean. VIEWPORT_WIDTH :: 1280 VIEWPORT_HEIGHT :: 720 -// Window size is what the viewport scales to -//WINDOW_WIDTH :: 2560 -// WINDOW_HEIGHT :: 1440 -WINDOW_WIDTH :: 1280 -WINDOW_HEIGHT :: 720 +WINDOW_WIDTH :: 2560 +WINDOW_HEIGHT :: 1440 +WINDOW_TITLE :: "Pong" Game :: struct { - current_scene: Scene, - is_paused: bool, - score_player: int, - score_enemy: int, + viewport: rl.RenderTexture2D, + scene: Scene, + paused: bool, + score_player: int, + score_enemy: int, } // ------------------------------------------------------------------------------ @@ -32,10 +29,11 @@ game_init :: proc(game: ^Game) { // initial state game.score_player = 0 game.score_enemy = 0 - game.is_paused = false + game.paused = false + game.viewport = rl.LoadRenderTexture(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) // initial scene (should be menu when setup) - game.current_scene = init_gameplay_scene() + game.scene = init_gameplay_scene() // init any systems/managers // game.input_manager = .... @@ -49,10 +47,10 @@ game_init :: proc(game: ^Game) { // ------------------------------------------------------------------------------ game_update :: proc(game: ^Game) { dt := rl.GetFrameTime() - // TODO: Get an input manager here + input := poll_input() // Update the current scene - scene_update(game, dt) + scene_update(game, input, dt) } // ------------------------------------------------------------------------------