lens_flare.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef IGL_LENS_FLARE_H
  2. #define IGL_LENS_FLARE_H
  3. #ifndef IGL_NO_OPENGL
  4. #include <igl/OpenGL_convenience.h>
  5. #include <Eigen/Core>
  6. #include <vector>
  7. namespace igl
  8. {
  9. struct Flare{
  10. int type; /* flare texture index, 0..5 */
  11. float scale;
  12. float loc; /* postion on axis */
  13. float color[3];
  14. Flare():
  15. type(-1),
  16. scale(0),
  17. loc(0)
  18. {}
  19. Flare(int type, float location, float scale, const float color[3], float colorScale) :
  20. type(type),
  21. scale(scale),
  22. loc(location)
  23. {
  24. this->color[0] = color[0] * colorScale;
  25. this->color[1] = color[1] * colorScale;
  26. this->color[2] = color[2] * colorScale;
  27. }
  28. };
  29. // Initialize shared data for lens flates
  30. //
  31. // Inputs:
  32. // start_id starting texture id location (should have at least id:id+16 free)
  33. // Outputs:
  34. // shine list of texture ids for shines
  35. // flare list of texture ids for flares
  36. void lens_flare_load_textures(
  37. std::vector<GLuint> & shine_ids,
  38. std::vector<GLuint> & flare_ids);
  39. // Create a set of lens flares
  40. //
  41. // Inputs:
  42. // A primary color
  43. // B secondary color
  44. // C secondary color
  45. // Outputs:
  46. // flares list of flare objects
  47. void lens_flare_create(
  48. const float * A,
  49. const float * B,
  50. const float * C,
  51. std::vector<Flare> & flares);
  52. // Draw lens flares
  53. //
  54. // Inputs:
  55. // flares list of Flare objects
  56. // shine_ids list of shine textures
  57. // flare_ids list of flare texture ids
  58. // light position of light
  59. // near_clip near clipping plane
  60. // shine_tic current "tic" in shine textures
  61. // Outputs:
  62. // shine_tic current "tic" in shine textures
  63. void lens_flare_draw(
  64. const std::vector<Flare> & flares,
  65. const std::vector<GLuint> & shine_ids,
  66. const std::vector<GLuint> & flare_ids,
  67. const Eigen::Vector3f & light,
  68. const float near_clip,
  69. int & shine_tic);
  70. };
  71. #ifdef IGL_HEADER_ONLY
  72. # include "lens_flare.cpp"
  73. #endif
  74. #endif
  75. #endif