00001
00002
00003 #ifndef GPUPROGRAM_H
00004 #define GPUPROGRAM_H
00005
00006
00007 #include "Renderer.h"
00008 #include "Vector3f.h"
00009 #include "Vector4f.h"
00010
00011 #include <string>
00012
00013
00014 #define MAX_LINE 255
00015
00016
00017 namespace pge {
00018
00019
00020 class GPUProgram {
00021
00022 public:
00023
00024
00025
00026
00027
00028 GPUProgram(const std::string &vertexSourceFile, const std::string &fragmentSourceFile);
00029
00030
00031
00032
00033
00034
00035
00036 virtual ~GPUProgram(void);
00037
00038
00039
00040
00041
00042
00043
00044 void bind(void);
00045 void release(void);
00046 void passUniform1i(char *name, int value);
00047 void passUniform1f(char *name, float value);
00048 void passUniform3f(char *name, float v1, float v2, float v3);
00049 void passUniform3f(char *name, Vector3f value);
00050 void passUniform4f(char *name, float v1, float v2, float v3, float v4);
00051 void passUniform4f(char *name, Vector4f value);
00052 void passUniformMatrix4f(char *name, float *value);
00053
00054
00055 private:
00056
00057
00058
00059
00060
00061 bool createPrograms(void);
00062 std::string loadProgram(const std::string &filename);
00063 void printLog(GLhandleARB handle);
00064
00065
00066
00067
00068
00069
00070
00071 std::string m_vertexSource;
00072 std::string m_fragmentSource;
00073
00074 GLhandleARB m_programObject;
00075 GLhandleARB m_vertexShader;
00076 GLhandleARB m_fragmentShader;
00077 };
00078 };
00079
00080 #endif