You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.8 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [models] example - Drawing billboards
  4. *
  5. * This example has been created using raylib 1.3 (www.raylib.com)
  6. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. *
  8. * Copyright (c) 2015 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 [models] example - drawing billboards");
  19. // Define the camera to look into our 3d world
  20. Camera camera = {{ 5.0f, 4.0f, 5.0f }, { 0.0f, 2.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
  21. Texture2D bill = LoadTexture("resources/billboard.png"); // Our texture billboard
  22. Vector3 billPosition = { 0.0f, 2.0f, 0.0f }; // Position where draw billboard
  23. SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
  24. SetCameraPosition(camera.position); // Set internal camera position to match our camera position
  25. SetCameraTarget(camera.target); // Set internal camera target to match our camera target
  26. SetCameraFovy(camera.fovy); // Set internal camera field-of-view Y
  27. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  28. //--------------------------------------------------------------------------------------
  29. // Main game loop
  30. while (!WindowShouldClose()) // Detect window close button or ESC key
  31. {
  32. // Update
  33. //----------------------------------------------------------------------------------
  34. UpdateCamera(&camera); // Update internal camera and our camera
  35. //----------------------------------------------------------------------------------
  36. // Draw
  37. //----------------------------------------------------------------------------------
  38. BeginDrawing();
  39. ClearBackground(RAYWHITE);
  40. Begin3dMode(camera);
  41. DrawBillboard(camera, bill, billPosition, 2.0f, WHITE);
  42. DrawGrid(10, 1.0f); // Draw a grid
  43. End3dMode();
  44. DrawFPS(10, 10);
  45. EndDrawing();
  46. //----------------------------------------------------------------------------------
  47. }
  48. // De-Initialization
  49. //--------------------------------------------------------------------------------------
  50. UnloadTexture(bill); // Unload texture
  51. CloseWindow(); // Close window and OpenGL context
  52. //--------------------------------------------------------------------------------------
  53. return 0;
  54. }