PolyGLSLProgram.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * PolyGLSLProgram.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 9/20/08.
  6. * Copyright 2008 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package Materials
  10. #pragma once
  11. #include "Polycode.h"
  12. #include "PolyGlobals.h"
  13. #include "PolyLogger.h"
  14. #include "PolyResource.h"
  15. #include "PolyVector3.h"
  16. #include "PolyUtil.h"
  17. #include <vector>
  18. #if defined(__APPLE__) && defined(__MACH__)
  19. #include <OpenGL/gl.h>
  20. #include <OpenGL/glext.h>
  21. #include <OpenGL/glu.h>
  22. #else
  23. #include <GL/gl.h>
  24. #include <GL/glu.h>
  25. #include <GL/glext.h>
  26. #endif
  27. using std::vector;
  28. namespace Polycode {
  29. class _PolyExport GLSLProgramParam {
  30. public:
  31. String name;
  32. bool isAuto;
  33. int autoID;
  34. void *defaultData;
  35. int paramType;
  36. static void *createParamData(int *retType, String type, String value);
  37. static const int TAU_MODELVIEWPROJ_MATRIX = 0;
  38. static const int TAU_MODELVIEW_MATRIX = 2;
  39. static const int TAU_MODELVIEW_INVERSE_MATRIX = 3;
  40. static const int TAU_EXPOSURE_LEVEL = 7;
  41. static const int TAU_CLEARCOLOR = 10;
  42. static const int TAU_AMBIENTCOLOR = 11;
  43. static const int TAU_AREA_LIGHT_POSITION_0 = 12;
  44. static const int TAU_AREA_LIGHT_COLOR_0 = 13;
  45. static const int TAU_AREA_LIGHT_POSITION_1 = 14;
  46. static const int TAU_AREA_LIGHT_COLOR_1 = 15;
  47. static const int TAU_AREA_LIGHT_POSITION_2 = 16;
  48. static const int TAU_AREA_LIGHT_COLOR_2 = 17;
  49. static const int TAU_AREA_LIGHT_POSITION_3 = 18;
  50. static const int TAU_AREA_LIGHT_COLOR_3 = 19;
  51. static const int TAU_AREA_LIGHT_POSITION_4 = 20;
  52. static const int TAU_AREA_LIGHT_COLOR_4 = 21;
  53. static const int TAU_AREA_LIGHT_POSITION_5 = 22;
  54. static const int TAU_AREA_LIGHT_COLOR_5 = 23;
  55. static const int TAU_AREA_LIGHT_POSITION_6 = 24;
  56. static const int TAU_AREA_LIGHT_COLOR_6 = 25;
  57. static const int TAU_AREA_LIGHT_POSITION_7 = 26;
  58. static const int TAU_AREA_LIGHT_COLOR_7 = 27;
  59. static const int TAU_SPOT_LIGHT_POSITION_0 = 30;
  60. static const int TAU_SPOT_LIGHT_COLOR_0 = 31;
  61. static const int TAU_SPOT_LIGHT_DIRECTION_0 = 32;
  62. static const int TAU_SPOT_LIGHT_POSITION_1 = 33;
  63. static const int TAU_SPOT_LIGHT_COLOR_1 = 34;
  64. static const int TAU_SPOT_LIGHT_DIRECTION_1 = 35;
  65. static const int TAU_SPOT_LIGHT_POSITION_2 = 36;
  66. static const int TAU_SPOT_LIGHT_COLOR_2 = 37;
  67. static const int TAU_SPOT_LIGHT_DIRECTION_2 = 38;
  68. static const int TAU_SPOT_LIGHT_POSITION_3 = 39;
  69. static const int TAU_SPOT_LIGHT_COLOR_3 = 40;
  70. static const int TAU_SPOT_LIGHT_DIRECTION_3 = 41;
  71. static const int TAU_SPOT_LIGHT_TEXTUREMATRIX_0 = 42;
  72. static const int TAU_SPOT_LIGHT_TEXTUREMATRIX_1 = 43;
  73. static const int TAU_SPOT_LIGHT_TEXTUREMATRIX_2 = 44;
  74. static const int TAU_SPOT_LIGHT_TEXTUREMATRIX_3 = 45;
  75. static const int PARAM_UNKNOWN = 0;
  76. static const int PARAM_FLOAT = 1;
  77. static const int PARAM_FLOAT3 = 2;
  78. static const int PARAM_FLOAT4 = 3;
  79. };
  80. class _PolyExport GLSLProgram : public Resource {
  81. public:
  82. GLSLProgram(int type);
  83. ~GLSLProgram();
  84. void addParam(String name, bool isAuto, int autoID, int paramType, void *defaultData);
  85. unsigned int program;
  86. // GLSLparameter modelViewProjection;
  87. static const int TYPE_VERT = 0;
  88. static const int TYPE_FRAG = 1;
  89. int type;
  90. vector<GLSLProgramParam> params;
  91. };
  92. }