fog.c 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "./common.h"
  2. /* === Resources === */
  3. static R3D_Model sponza = { 0 };
  4. static Camera3D camera = { 0 };
  5. /* === Example === */
  6. const char* Init(void)
  7. {
  8. R3D_Init(GetScreenWidth(), GetScreenHeight(), 0);
  9. SetTargetFPS(60);
  10. sponza = R3D_LoadModel(RESOURCES_PATH "sponza.glb");
  11. R3D_SetFogMode(R3D_FOG_EXP);
  12. R3D_Light light = R3D_CreateLight(R3D_LIGHT_DIR);
  13. R3D_SetLightDirection(light, (Vector3) { 0, -1, 0 });
  14. R3D_SetLightActive(light, true);
  15. camera = (Camera3D){
  16. .position = (Vector3) { 0, 0, 0 },
  17. .target = (Vector3) { 0, 0, -1 },
  18. .up = (Vector3) { 0, 1, 0 },
  19. .fovy = 60,
  20. };
  21. DisableCursor();
  22. return "[r3d] - Fog example";
  23. }
  24. void Update(float delta)
  25. {
  26. UpdateCamera(&camera, CAMERA_FREE);
  27. }
  28. void Draw(void)
  29. {
  30. R3D_Begin(camera);
  31. R3D_DrawModel(&sponza, (Vector3) { 0 }, 1.0f);
  32. R3D_End();
  33. DrawFPS(10, 10);
  34. }
  35. void Close(void)
  36. {
  37. R3D_UnloadModel(&sponza, true);
  38. R3D_Close();
  39. }