00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifdef GLSL
00018 #include "GL/glew.h"
00019 #endif
00020 #ifndef __APPLE__
00021 #include "GL/gl.h"
00022 #include "GL/glu.h"
00023 #include "GL/glut.h"
00024 #else
00025 #include "OpenGL/gl.h"
00026 #include "OpenGL/glu.h"
00027 #include "GLUT/glut.h"
00028 #endif
00029 #include <string>
00030 #include <vector>
00031 #include "dada.h"
00032 
00033 #ifndef FLUXUS_GLSL_SHADER
00034 #define FLUXUS_GLSL_SHADER
00035 
00036 using namespace std;
00037 
00038 namespace Fluxus
00039 {
00040 
00043 class GLSLShader
00044 {
00045 public:
00047     GLSLShader(const string &vertexfilename, const string &fragmentfilename);
00048     ~GLSLShader();
00049 
00053     static void Init();
00054     void Apply();
00055     static void Unapply();
00057     
00061     void SetInt(const string &name, int s);
00062     void SetFloat(const string &name, float s);
00063     void SetVector(const string &name, dVector s);
00064     void SetColour(const string &name, dColour s);
00066     
00070     void SetFloatArray(const string &name, const vector<float> &s);
00071     void SetVectorArray(const string &name, const vector<dVector> &s);
00072     void SetColourArray(const string &name, const vector<dColour> &s);
00074     
00075 private:
00077     bool Load(const string &vertexfilename, const string &fragmentfilename);
00078 
00079     unsigned int LoadShader(string filename, unsigned int type);
00080     unsigned int m_Program;
00081     static bool m_Enabled;
00082 };
00083 
00084 }
00085 
00086 #endif