00001 #ifndef GLSLSHADER_H_INCLUDED
00002 #define GLSLSHADER_H_INCLUDED
00003
00004 #include <string>
00005 #include <iostream>
00006 #include <fstream>
00007 #include <GL/glew.h>
00008 #include "includeGL.h"
00009 #include "Component.h"
00010
00011 using namespace std;
00012
00016 class GLSLShader:public Component{
00017 public :
00018 static const RTTI TYPE;
00019 virtual const RTTI& getType() const{ return TYPE; }
00020
00021 protected:
00022 GLuint vs_object;
00023 GLuint fs_object;
00024 GLuint prog_object;
00025 std::string ressourceName;
00026
00027 public:
00028 GLSLShader();
00029 GLSLShader(const string& path, const string& vertexShaderPath, const string& fragmentShaderPath);
00030 ~GLSLShader();
00031
00032 void bindShader()const;
00033 GLuint getShaderProgramId()const;
00034 private:
00035
00036 friend class boost::serialization::access;
00037 template<class Archive>
00038 void serialize(Archive& ar, const unsigned int version){
00039
00040 ar & boost::serialization::base_object<Object>(*this);
00041 ar & ressourceName;
00042 }
00043 };
00044
00046 void print_glsl_program_log(GLuint program);
00047
00049 void print_glsl_shader_log(GLuint shader);
00050
00053 const std::string read_glsl_source(const std::string& path, const std::string& file);
00054
00058 GLuint create_glsl_shader(GLuint stype, const std::string& src, bool print_log = true);
00059
00064 GLuint create_glsl_shader(GLuint stype, const std::string& path, const std::string& file);
00065
00066
00067 #endif