aboutsummaryrefslogtreecommitdiff
path: root/examples/models_obj_loading.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/models_obj_loading.c')
-rw-r--r--examples/models_obj_loading.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/examples/models_obj_loading.c b/examples/models_obj_loading.c
index 90bccf8a..3c2da62f 100644
--- a/examples/models_obj_loading.c
+++ b/examples/models_obj_loading.c
@@ -1,11 +1,11 @@
/*******************************************************************************************
*
-* raylib example 07c - Load and draw a 3d model (OBJ)
+* raylib [models] example - Load and draw a 3d model (OBJ)
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
-* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
********************************************************************************************/
@@ -18,18 +18,17 @@ int main()
int screenWidth = 800;
int screenHeight = 450;
- Vector3 position = { 0.0, 0.0, 0.0 };
-
+ InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
+
// Define the camera to look into our 3d world
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
-
- InitWindow(screenWidth, screenHeight, "raylib example 07c - 3d models");
-
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
-
- Texture2D texture = LoadTexture("resources/catsham.png");
- Model cat = LoadModel("resources/cat.obj");
- SetModelTexture(&cat, texture); // Link texture to model
+
+ Texture2D texture = LoadTexture("resources/catsham.png"); // Load model texture
+ Model cat = LoadModel("resources/cat.obj"); // Load OBJ model
+ SetModelTexture(&cat, texture); // Bind texture to model
+ Vector3 catPosition = { 0.0, 0.0, 0.0 }; // Set model position
+
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -37,10 +36,10 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
- if (IsKeyDown(KEY_LEFT)) position.x -= 0.2;
- if (IsKeyDown(KEY_RIGHT)) position.x += 0.2;
- if (IsKeyDown(KEY_UP)) position.z -= 0.2;
- if (IsKeyDown(KEY_DOWN)) position.z += 0.2;
+ if (IsKeyDown(KEY_LEFT)) catPosition.x -= 0.2;
+ if (IsKeyDown(KEY_RIGHT)) catPosition.x += 0.2;
+ if (IsKeyDown(KEY_UP)) catPosition.z -= 0.2;
+ if (IsKeyDown(KEY_DOWN)) catPosition.z += 0.2;
//----------------------------------------------------------------------------------
// Draw
@@ -51,11 +50,11 @@ int main()
Begin3dMode(camera);
- DrawModel(cat, position, 0.1f, WHITE); // Draw 3d model with texture
+ DrawModel(cat, catPosition, 0.1f, WHITE); // Draw 3d model with texture
DrawGrid(10.0, 1.0); // Draw a grid
- DrawGizmo(position);
+ DrawGizmo(catPosition); // Draw gizmo
End3dMode();
@@ -74,4 +73,4 @@ int main()
//--------------------------------------------------------------------------------------
return 0;
-}
+} \ No newline at end of file