core_3d_mode.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*******************************************************************************************
  2. *
  3. * raylib [core] example - 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) 2014 Ramon Santamaria (@raysan5)
  9. *
  10. ********************************************************************************************/
  11. #include "raylib.h"
  12. int main()
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. int screenWidth = 800;
  17. int screenHeight = 450;
  18. InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");
  19. // Define the camera to look into our 3d world
  20. Camera camera = {{ 0.0, 10.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
  21. Vector3 cubePosition = { 0.0, 0.0, 0.0 };
  22. //SetTargetFPS(60); // Set our game to run at 60 frames-per-second, but not now...
  23. //--------------------------------------------------------------------------------------
  24. // Main game loop
  25. while (!WindowShouldClose()) // Detect window close button or ESC key
  26. {
  27. // Update
  28. //----------------------------------------------------------------------------------
  29. // TODO: Update your variables here
  30. //----------------------------------------------------------------------------------
  31. // Draw
  32. //----------------------------------------------------------------------------------
  33. BeginDrawing();
  34. ClearBackground(WHITE);
  35. Begin3dMode(camera);
  36. DrawCube(cubePosition, 2, 2, 2, RED);
  37. DrawCubeWires(cubePosition, 2, 2, 2, MAROON);
  38. DrawGrid(10.0, 1.0);
  39. End3dMode();
  40. DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);
  41. DrawFPS(10, 10);
  42. EndDrawing();
  43. //----------------------------------------------------------------------------------
  44. }
  45. // De-Initialization
  46. //--------------------------------------------------------------------------------------
  47. CloseWindow(); // Close window and OpenGL context
  48. //--------------------------------------------------------------------------------------
  49. return 0;
  50. }