diff options
| author | raysan5 <[email protected]> | 2020-12-23 20:30:00 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-12-23 20:30:00 +0100 |
| commit | d9a9bacb480ce173ffd3cb0e382fca5f0ddcf10f (patch) | |
| tree | 830e4ec974d305819fdc805f0b24d2aab373ca16 /examples/core | |
| parent | 10a57f297e991f3e54bc29d87705c5aef7c2511f (diff) | |
| download | raylib-d9a9bacb480ce173ffd3cb0e382fca5f0ddcf10f.tar.gz raylib-d9a9bacb480ce173ffd3cb0e382fca5f0ddcf10f.zip | |
Review formatting
Diffstat (limited to 'examples/core')
| -rw-r--r-- | examples/core/core_quat_conversion.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/examples/core/core_quat_conversion.c b/examples/core/core_quat_conversion.c index 85231a89..cd7777e6 100644 --- a/examples/core/core_quat_conversion.c +++ b/examples/core/core_quat_conversion.c @@ -34,16 +34,17 @@ int main(void) camera.fovy = 45.0f; // Camera field-of-view Y camera.type = CAMERA_PERSPECTIVE; // Camera mode type - Mesh msh = GenMeshCylinder(.2, 1, 32); - Model mod = LoadModelFromMesh(msh); + Mesh mesh = GenMeshCylinder(0.2f, 1.0f, 32); + Model model = LoadModelFromMesh(mesh); + + // Some required variables + Quaternion q1 = { 0 }; + Matrix m1 = { 0 }, m2 = { 0 }, m3 = { 0 }, m4 = { 0 }; + Vector3 v1 = { 0 }, v2 = { 0 }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- - - Quaternion q1; - Matrix m1,m2,m3,m4; - Vector3 v1,v2; - + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { @@ -51,11 +52,11 @@ int main(void) //-------------------------------------------------------------------------------------- if (!IsKeyDown(KEY_SPACE)) { - v1.x += 0.01; - v1.y += 0.03; - v1.z += 0.05; + v1.x += 0.01f; + v1.y += 0.03f; + v1.z += 0.05f; } - + if (v1.x > PI*2) v1.x -= PI*2; if (v1.y > PI*2) v1.y -= PI*2; if (v1.z > PI*2) v1.z -= PI*2; @@ -70,7 +71,7 @@ int main(void) v2 = QuaternionToEuler(q1); v2.x *= DEG2RAD; v2.y *= DEG2RAD; - v2.z *=DEG2RAD; + v2.z *= DEG2RAD; m4 = MatrixRotateZYX(v2); //-------------------------------------------------------------------------------------- @@ -80,16 +81,17 @@ int main(void) BeginDrawing(); ClearBackground(RAYWHITE); + BeginMode3D(camera); - mod.transform = m1; - DrawModel(mod, (Vector3){-1,0,0},1.0,RED); - mod.transform = m2; - DrawModel(mod, (Vector3){1,0,0},1.0,RED); - mod.transform = m3; - DrawModel(mod, (Vector3){0,0,0},1.0,RED); - mod.transform = m4; - DrawModel(mod, (Vector3){0,0,-1},1.0,RED); + model.transform = m1; + DrawModel(model, (Vector3){ -1, 0, 0 }, 1.0f, RED); + model.transform = m2; + DrawModel(model, (Vector3){ 1, 0, 0 }, 1.0f, RED); + model.transform = m3; + DrawModel(model, (Vector3){ 0, 0, 0 }, 1.0f, RED); + model.transform = m4; + DrawModel(model, (Vector3){ 0, 0, -1 }, 1.0f, RED); DrawGrid(10, 1.0f); @@ -105,13 +107,13 @@ int main(void) if (v1.y == v2.y) cy = GREEN; if (v1.z == v2.z) cz = GREEN; - DrawText(TextFormat("%2.3f",v1.x),20,20,20,cx); - DrawText(TextFormat("%2.3f",v1.y),20,40,20,cy); - DrawText(TextFormat("%2.3f",v1.z),20,60,20,cz); + DrawText(TextFormat("%2.3f", v1.x), 20, 20, 20, cx); + DrawText(TextFormat("%2.3f", v1.y), 20, 40, 20, cy); + DrawText(TextFormat("%2.3f", v1.z), 20, 60, 20, cz); - DrawText(TextFormat("%2.3f",v2.x),200,20,20,cx); - DrawText(TextFormat("%2.3f",v2.y),200,40,20,cy); - DrawText(TextFormat("%2.3f",v2.z),200,60,20,cz); + DrawText(TextFormat("%2.3f", v2.x), 200, 20, 20, cx); + DrawText(TextFormat("%2.3f", v2.y), 200, 40, 20, cy); + DrawText(TextFormat("%2.3f", v2.z), 200, 60, 20, cz); EndDrawing(); //---------------------------------------------------------------------------------- @@ -119,6 +121,8 @@ int main(void) // De-Initialization //-------------------------------------------------------------------------------------- + UnloadModel(model); // Unload model data (mesh and materials) + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- |
