source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h @ 3025

Revision 3025, 1.7 KB checked in by mattausch, 16 years ago (diff)

worked on cg shader wrapper class

Line 
1#ifndef _SHADERPROGRAM_H__
2#define _SHADERPROGRAM_H__
3
4#include "common.h"
5#include "glInterface.h"
6
7#include <Cg/cg.h>
8#include <Cg/cgGL.h>
9#include <string>
10#include <map>
11
12
13namespace CHCDemoEngine
14{
15
16class FrameBufferObject;
17class Vector3;
18class Camera;
19class Matrix4x4;
20class ShadowMap;
21class DirectionalLight;
22
23typedef std::map<std::string, CGparameter> CGParameterMap;
24typedef std::vector<CGparameter> CGParameterArray;
25
26
27class ShaderProgram
28{
29public:
30
31        ShaderProgram(CGprogram program): mProgram(program) {}
32
33        ShaderProgram(CGcontext context,
34                          const std::string &filename,
35                                  CGprofile profile,
36                                  const std::string &functionName);
37
38        ~ShaderProgram() { if (mProgram != NULL) cgDestroyProgram(mProgram); }
39
40        void SetValue1f(const std::string &name, float value);
41        void SetValue2f(const std::string &name, float val1, float val2);
42        void SetValue3f(const std::string &name, float val1, float val, float val3);
43
44        void SetArray1f(const std::string &name, float *vals, int numElements);
45        void SetArray2f(const std::string &name, float *vals, int numElements);
46        void SetArray3f(const std::string &name, float *vals, int numElements);
47
48        void SetMatrix(const std::string &name, const Matrix4x4 &mat);
49
50        void SetTexture(const std::string &name,  unsigned int tex);
51
52        void Release();
53
54        void Bind();
55
56        inline bool IsValid() { return mProgram != NULL; }
57
58
59protected:
60
61        CGparameter GetOrCreateParameter(const std::string &name);
62
63        CGParameterMap mParamHash;
64        //CGParameterArray mParameters;
65
66        CGParameterArray mTextureParams;
67
68        CGprogram mProgram;
69};
70
71
72typedef  std::vector<ShaderProgram *> ShaderContainer;
73
74} // namespace
75
76#endif // _ShaderProgram_H__
Note: See TracBrowser for help on using the repository browser.