1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#pragma once
#include "opengl.hpp"
#include "storage.hpp"
#include "../defines.hpp"
#include "../../base/matrix.hpp"
#include "../../base/exception.hpp"
#include "../../std/shared_ptr.hpp"
#include "../../std/function.hpp"
#include "../../std/string.hpp"
namespace graphics
{
class VertexDecl;
namespace gl
{
class Shader;
class Program
{
private:
void applyAttributes();
void applyUniforms();
struct Uniform
{
struct Data
{
float m_matVal[4 * 4];
int m_intVal[4];
float m_floatVal[4];
} m_data;
EDataType m_type;
GLint m_handle;
};
struct Attribute
{
GLint m_handle;
size_t m_offset;
EDataType m_type;
size_t m_count;
size_t m_stride;
};
GLuint m_handle;
typedef map<ESemantic, Uniform> TUniforms;
TUniforms m_uniforms;
typedef map<ESemantic, Attribute> TAttributes;
TAttributes m_attributes;
Storage m_storage;
template <unsigned N>
void setParamImpl(ESemantic sem,
EDataType dt,
math::Matrix<float, N, N> const & m);
public:
DECLARE_EXCEPTION(Exception, RootException);
DECLARE_EXCEPTION(LinkException, Exception);
Program(shared_ptr<Shader> const & vxShader,
shared_ptr<Shader> const & frgShader);
~Program();
unsigned getParam(char const * name);
void setParam(ESemantic sem, float v0);
void setParam(ESemantic sem, float v0, float v1);
void setParam(ESemantic sem, float v0, float v1, float v2);
void setParam(ESemantic sem, float v0, float v1, float v2, float v3);
void setParam(ESemantic sem, int v0);
void setParam(ESemantic sem, int v0, int v1);
void setParam(ESemantic sem, int v0, int v1, int v2);
void setParam(ESemantic sem, int v0, int v1, int v2, int v3);
void setParam(ESemantic sem, math::Matrix<float, 2, 2> const & m);
void setParam(ESemantic sem, math::Matrix<float, 3, 3> const & m);
void setParam(ESemantic sem, math::Matrix<float, 4, 4> const & m);
void setVertexDecl(VertexDecl const * decl);
void setStorage(Storage const & storage);
void makeCurrent();
};
}
}
|