raylib/examples/models_geometric_shapes.c

75 lines
3.0 KiB
C
Raw Normal View History

2013-11-24 23:30:05 +04:00
/*******************************************************************************************
*
* raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...)
2013-11-24 23:30:05 +04:00
*
2013-11-29 00:16:31 +04:00
* 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)
2013-11-24 23:30:05 +04:00
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
2013-11-24 23:30:05 +04:00
*
********************************************************************************************/
#include "raylib.h"
int main()
{
2013-11-29 00:16:31 +04:00
// Initialization
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
2013-11-24 23:30:05 +04:00
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
2013-11-24 23:30:05 +04:00
// Define the camera to look into our 3d world
2013-11-29 00:16:31 +04:00
Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
2013-11-29 00:16:31 +04:00
2013-11-24 23:30:05 +04:00
// Main game loop
2013-11-29 00:16:31 +04:00
while (!WindowShouldClose()) // Detect window close button or ESC key
2013-11-24 23:30:05 +04:00
{
2013-11-29 00:16:31 +04:00
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
Begin3dMode(camera);
2013-12-20 16:21:22 +04:00
DrawCube((Vector3){-4, 0, 2}, 2, 5, 2, RED);
DrawCubeWires((Vector3){-4, 0, 2}, 2, 5, 2, GOLD);
DrawCubeWires((Vector3){-4, 0, -2}, 3, 6, 2, MAROON);
DrawSphere((Vector3){-1, 0, -2}, 1, GREEN);
DrawSphereWires((Vector3){1, 0, 2}, 2, 16, 16, LIME);
2013-11-24 23:30:05 +04:00
2013-12-20 16:21:22 +04:00
DrawCylinder((Vector3){4, 0, -2}, 1, 2, 3, 4, SKYBLUE);
DrawCylinderWires((Vector3){4, 0, -2}, 1, 2, 3, 4, DARKBLUE);
DrawCylinderWires((Vector3){4.5, -1, 2}, 1, 1, 2, 6, BROWN);
DrawCylinder((Vector3){1, 0, -4}, 0, 1.5, 3, 8, GOLD);
DrawCylinderWires((Vector3){1, 0, -4}, 0, 1.5, 3, 8, PINK);
2013-11-29 00:16:31 +04:00
DrawGrid(10.0, 1.0); // Draw a grid
End3dMode();
DrawFPS(10, 10);
EndDrawing();
2013-11-29 00:16:31 +04:00
//----------------------------------------------------------------------------------
}
2013-11-29 00:16:31 +04:00
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
2013-11-24 23:30:05 +04:00
return 0;
}