選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

79 行
3.2 KiB

11年前
11年前
11年前
11年前
11年前
11年前
11年前
11年前
11年前
  1. /*******************************************************************************************
  2. *
  3. * raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...)
  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(void)
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. const int screenWidth = 800;
  17. const int screenHeight = 450;
  18. InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
  19. // Define the camera to look into our 3d world
  20. Camera camera = { 0 };
  21. camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
  22. camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
  23. camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
  24. camera.fovy = 45.0f;
  25. camera.type = CAMERA_PERSPECTIVE;
  26. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  27. //--------------------------------------------------------------------------------------
  28. // Main game loop
  29. while (!WindowShouldClose()) // Detect window close button or ESC key
  30. {
  31. // Update
  32. //----------------------------------------------------------------------------------
  33. // TODO: Update your variables here
  34. //----------------------------------------------------------------------------------
  35. // Draw
  36. //----------------------------------------------------------------------------------
  37. BeginDrawing();
  38. ClearBackground(RAYWHITE);
  39. BeginMode3D(camera);
  40. DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED);
  41. DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD);
  42. DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON);
  43. DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN);
  44. DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME);
  45. DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE);
  46. DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE);
  47. DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN);
  48. DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD);
  49. DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK);
  50. DrawGrid(10, 1.0f); // Draw a grid
  51. EndMode3D();
  52. DrawFPS(10, 10);
  53. EndDrawing();
  54. //----------------------------------------------------------------------------------
  55. }
  56. // De-Initialization
  57. //--------------------------------------------------------------------------------------
  58. CloseWindow(); // Close window and OpenGL context
  59. //--------------------------------------------------------------------------------------
  60. return 0;
  61. }