summaryrefslogtreecommitdiffhomepage
path: root/examples/models/models_heightmap.c
diff options
context:
space:
mode:
authorvictorfisac <[email protected]>2017-08-27 12:48:51 +0200
committervictorfisac <[email protected]>2017-08-27 12:48:51 +0200
commit353912b2153b848b270ac15ba97a156b7d336d84 (patch)
tree63fdca2144cd13f6a537e76d6a3f8712ae106ead /examples/models/models_heightmap.c
parenteb7b5e59bbaec0f556c4fde21cd0bf20819a8108 (diff)
parentc074783861994fb9f3bcc618b776a41dc57b50d0 (diff)
downloadraylib-353912b2153b848b270ac15ba97a156b7d336d84.tar.gz
raylib-353912b2153b848b270ac15ba97a156b7d336d84.zip
Merge branch 'master' of https://github.com/raysan5/raylib
Diffstat (limited to 'examples/models/models_heightmap.c')
-rw-r--r--examples/models/models_heightmap.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/models/models_heightmap.c b/examples/models/models_heightmap.c
index 10069e03..e887cea7 100644
--- a/examples/models/models_heightmap.c
+++ b/examples/models/models_heightmap.c
@@ -23,11 +23,14 @@ int main()
// Define our custom camera to look into our 3d world
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
- Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
- Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
- Model map = LoadHeightmap(image, (Vector3){ 16, 8, 16 }); // Load heightmap model with defined size
- map.material.texDiffuse = texture; // Set map diffuse texture
- Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Set model position (depends on model scaling!)
+ Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
+ Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
+
+ Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
+ Model model = LoadModelFromMesh(mesh); // Load model from generated mesh
+
+ model.material.maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
+ Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
@@ -52,8 +55,7 @@ int main()
Begin3dMode(camera);
- // NOTE: Model is scaled to 1/4 of its original size (128x128 units)
- DrawModel(map, mapPosition, 1.0f, RED);
+ DrawModel(model, mapPosition, 1.0f, RED);
DrawGrid(20, 1.0f);
@@ -71,7 +73,7 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture
- UnloadModel(map); // Unload model
+ UnloadModel(model); // Unload model
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------