ex07a_3d_mode.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*******************************************************************************************
  2. *
  3. * raylib example 07a - Initialize 3d mode
  4. *
  5. * This example has been created using raylib 1.0 (www.raylib.com)
  6. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. *
  8. * Copyright (c) 2013 Ramon Santamaria (Ray San - [email protected])
  9. *
  10. ********************************************************************************************/
  11. #include "raylib.h"
  12. int main()
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. int screenWidth = 800;
  17. int screenHeight = 450;
  18. Vector3 position = { 0.0, 0.0, 0.0 };
  19. Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
  20. InitWindow(screenWidth, screenHeight, "raylib example 07a - 3d mode");
  21. //--------------------------------------------------------------------------------------
  22. // Main game loop
  23. while (!WindowShouldClose()) // Detect window close button or ESC key
  24. {
  25. // Update
  26. //----------------------------------------------------------------------------------
  27. // TODO: Update your variables here
  28. //----------------------------------------------------------------------------------
  29. // Draw
  30. //----------------------------------------------------------------------------------
  31. BeginDrawing();
  32. ClearBackground(WHITE);
  33. Begin3dMode(camera);
  34. DrawCube(position, 2, 2, 2, RED);
  35. DrawGrid(10.0, 1.0);
  36. End3dMode();
  37. DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);
  38. DrawFPS(10, 10);
  39. EndDrawing();
  40. //----------------------------------------------------------------------------------
  41. }
  42. // De-Initialization
  43. //--------------------------------------------------------------------------------------
  44. CloseWindow(); // Close window and OpenGL context
  45. //--------------------------------------------------------------------------------------
  46. return 0;
  47. }