2
0

test_billboard.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*******************************************************************************************
  2. *
  3. * raylib test - Testing DrawBillboard() and DrawBillboardRec()
  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. // Define the camera to look into our 3d world
  20. Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
  21. InitWindow(screenWidth, screenHeight, "raylib test - Billboards");
  22. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  23. Texture2D texture = LoadTexture("resources/raylib_logo.png");
  24. Texture2D lena = LoadTexture("resources/lena.png");
  25. Rectangle eyesRec = { 225, 240, 155, 50 };
  26. //--------------------------------------------------------------------------------------
  27. // Main game loop
  28. while (!WindowShouldClose()) // Detect window close button or ESC key
  29. {
  30. // Update
  31. //----------------------------------------------------------------------------------
  32. if (IsKeyDown(KEY_LEFT)) camera.position.x -= 0.2;
  33. if (IsKeyDown(KEY_RIGHT)) camera.position.x += 0.2;
  34. if (IsKeyDown(KEY_UP)) camera.position.y -= 0.2;
  35. if (IsKeyDown(KEY_DOWN)) camera.position.y += 0.2;
  36. //----------------------------------------------------------------------------------
  37. // Draw
  38. //----------------------------------------------------------------------------------
  39. BeginDrawing();
  40. ClearBackground(RAYWHITE);
  41. Begin3dMode(camera);
  42. //DrawBillboard(camera, texture, position, 2.0, WHITE);
  43. DrawBillboardRec(camera, lena, eyesRec, position, 4.0, WHITE);
  44. DrawGrid(10.0, 1.0); // Draw a grid
  45. End3dMode();
  46. DrawFPS(10, 10);
  47. EndDrawing();
  48. //----------------------------------------------------------------------------------
  49. }
  50. // De-Initialization
  51. //--------------------------------------------------------------------------------------
  52. UnloadTexture(texture); // Unload texture
  53. UnloadTexture(lena); // Unload texture
  54. CloseWindow(); // Close window and OpenGL context
  55. //--------------------------------------------------------------------------------------
  56. return 0;
  57. }