Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

82 linhas
2.7 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [core] example - Basic 3d example
  4. *
  5. * Welcome to raylib!
  6. *
  7. * To compile example, just press F5.
  8. * Note that compiled executable is placed in the same folder as .c file
  9. *
  10. * You can find all basic examples on C:\raylib\raylib\examples folder or
  11. * raylib official webpage: www.raylib.com
  12. *
  13. * Enjoy using raylib. :)
  14. *
  15. * This example has been created using raylib 1.0 (www.raylib.com)
  16. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  17. *
  18. * Copyright (c) 2013-2019 Ramon Santamaria (@raysan5)
  19. *
  20. ********************************************************************************************/
  21. #include "raylib.h"
  22. int main()
  23. {
  24. // Initialization
  25. //--------------------------------------------------------------------------------------
  26. const int screenWidth = 800;
  27. const int screenHeight = 450;
  28. InitWindow(screenWidth, screenHeight, "raylib");
  29. Camera camera = { 0 };
  30. camera.position = (Vector3){ 10.0f, 10.0f, 8.0f };
  31. camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
  32. camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
  33. camera.fovy = 60.0f;
  34. camera.type = CAMERA_PERSPECTIVE;
  35. SetCameraMode(camera, CAMERA_ORBITAL);
  36. Vector3 cubePosition = { 0.0f };
  37. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  38. //--------------------------------------------------------------------------------------
  39. // Main game loop
  40. while (!WindowShouldClose()) // Detect window close button or ESC key
  41. {
  42. // Update
  43. //----------------------------------------------------------------------------------
  44. UpdateCamera(&camera);
  45. //----------------------------------------------------------------------------------
  46. // Draw
  47. //----------------------------------------------------------------------------------
  48. BeginDrawing();
  49. ClearBackground(RAYWHITE);
  50. BeginMode3D(camera);
  51. DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
  52. DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
  53. DrawGrid(10, 1.0f);
  54. EndMode3D();
  55. DrawText("This is a raylib example", 10, 40, 20, DARKGRAY);
  56. DrawFPS(10, 10);
  57. EndDrawing();
  58. //----------------------------------------------------------------------------------
  59. }
  60. // De-Initialization
  61. //--------------------------------------------------------------------------------------
  62. CloseWindow(); // Close window and OpenGL context
  63. //--------------------------------------------------------------------------------------
  64. return 0;
  65. }