light.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. *** :: Light ::
  3. ***
  4. *** Currently this is so large because
  5. *** it supports all types of light.
  6. ***
  7. *** This means it holds data for shadow
  8. *** mapping etc which may not be relevant
  9. *** for some light types.
  10. ***
  11. **/
  12. #ifndef light_h
  13. #define light_h
  14. #include "cengine.h"
  15. enum {
  16. LIGHT_TYPE_POINT = 0,
  17. LIGHT_TYPE_DIRECTIONAL = 1,
  18. LIGHT_TYPE_SUN = 2,
  19. LIGHT_TYPE_SPOT = 3,
  20. };
  21. typedef struct {
  22. vec3 position;
  23. vec3 target;
  24. vec3 diffuse_color;
  25. vec3 specular_color;
  26. vec3 ambient_color;
  27. float power;
  28. float falloff;
  29. bool enabled;
  30. bool cast_shadows;
  31. int type;
  32. /* Shadow Mapping */
  33. vec3 shadow_color;
  34. int shadow_map_width;
  35. int shadow_map_height;
  36. /* Orthographic Shadow Mapping */
  37. bool orthographic;
  38. float ortho_width;
  39. float ortho_height;
  40. /* Projection Shadow Mapping */
  41. float fov;
  42. float aspect_ratio;
  43. } light;
  44. light* light_new();
  45. light* light_new_position(vec3 position);
  46. /* Builds light using type's default values */
  47. light* light_new_type(vec3 position, int type);
  48. void light_delete(light* l);
  49. void light_set_type(light* l, int type);
  50. vec3 light_direction(light* l);
  51. mat4 light_view_matrix(light* l);
  52. mat4 light_proj_matrix(light* l);
  53. #endif