Added offscreen rendering.

This commit is contained in:
2026-09-09 07:18:31 +02:00
parent a98bbd9c93
commit 324c4240d7
+14 -16
View File
@@ -2,22 +2,19 @@ package game
import rl "vendor:raylib" import rl "vendor:raylib"
WINDOW_TITLE :: "Pong" // good 16:9 internal res, window scales up to 1080/4k clean.
// good 16:9 baseline res, scales up to 1080 or 4k clean.
VIEWPORT_WIDTH :: 1280 VIEWPORT_WIDTH :: 1280
VIEWPORT_HEIGHT :: 720 VIEWPORT_HEIGHT :: 720
// Window size is what the viewport scales to WINDOW_WIDTH :: 2560
//WINDOW_WIDTH :: 2560 WINDOW_HEIGHT :: 1440
// WINDOW_HEIGHT :: 1440 WINDOW_TITLE :: "Pong"
WINDOW_WIDTH :: 1280
WINDOW_HEIGHT :: 720
Game :: struct { Game :: struct {
current_scene: Scene, viewport: rl.RenderTexture2D,
is_paused: bool, scene: Scene,
score_player: int, paused: bool,
score_enemy: int, score_player: int,
score_enemy: int,
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
@@ -32,10 +29,11 @@ game_init :: proc(game: ^Game) {
// initial state // initial state
game.score_player = 0 game.score_player = 0
game.score_enemy = 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) // initial scene (should be menu when setup)
game.current_scene = init_gameplay_scene() game.scene = init_gameplay_scene()
// init any systems/managers // init any systems/managers
// game.input_manager = .... // game.input_manager = ....
@@ -49,10 +47,10 @@ game_init :: proc(game: ^Game) {
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
game_update :: proc(game: ^Game) { game_update :: proc(game: ^Game) {
dt := rl.GetFrameTime() dt := rl.GetFrameTime()
// TODO: Get an input manager here input := poll_input()
// Update the current scene // Update the current scene
scene_update(game, dt) scene_update(game, input, dt)
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------