aboutsummaryrefslogtreecommitdiffstats
path: root/src/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/game.c b/src/game.c
index f76a0ee..80efe6d 100644
--- a/src/game.c
+++ b/src/game.c
@@ -16,6 +16,27 @@ void initGame(Game* game)
// Assets.
initAssets(&game->assets);
+ // Skybox.
+ game->skybox = LoadModelFromMesh(GenMeshCube(1.0, 1.0, 1.0));
+ game->skybox.materials[0].shader = game->assets.shaders[SKYBOX_SHADER];
+
+ SetShaderValue(
+ game->skybox.materials[0].shader,
+ GetShaderLocation(game->skybox.materials[0].shader, "environmentMap"),
+ (int[1]){ MATERIAL_MAP_CUBEMAP }, SHADER_UNIFORM_INT);
+ SetShaderValue(
+ game->skybox.materials[0].shader,
+ GetShaderLocation(game->skybox.materials[0].shader, "doGamma"),
+ (int[1]){ 0 }, SHADER_UNIFORM_INT);
+ SetShaderValue(
+ game->skybox.materials[0].shader,
+ GetShaderLocation(game->skybox.materials[0].shader, "vflipped"),
+ (int[1]){ 0 }, SHADER_UNIFORM_INT);
+
+ game->skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture =
+ LoadTextureCubemap(game->assets.images[SKYBOX_IMAGE],
+ CUBEMAP_LAYOUT_AUTO_DETECT);
+
// Player.
game->player = createPlayer();
game->player.position = (Vector3){0.0, 30.0, 0.0};
@@ -37,6 +58,13 @@ void updateGameScene(Game* game)
BeginMode3D(game->player.camera);
+ // Render skybox.
+ rlDisableBackfaceCulling();
+ rlDisableDepthMask();
+ DrawModel(game->skybox, Vector3Zero(), 1.0, WHITE);
+ rlEnableBackfaceCulling();
+ rlEnableDepthMask();
+
updatePlayer(&game->player, game);
updateWorld(&game->world, game);
@@ -68,6 +96,8 @@ void updateGame(Game* game)
void closeGame(Game* game)
{
closeAssets(&game->assets);
+ UnloadTexture(game->skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture);
+ UnloadModel(game->skybox);
freeWorld(game->world);
CloseWindow();
}