forked from bwrrp/glblaat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGLProgram.h
84 lines (64 loc) · 2.44 KB
/
GLProgram.h
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
// Copyright (c) 2009 Stef Busking
// Distributed under the terms of the MIT License.
#pragma once
#include "GLResource.h"
#include "GL.h"
#include "GLShaderInfo.h"
#include <set>
#include <string>
#include <vector>
class GLShader;
class GLProgram : public GLResource
{
public:
static GLProgram *New();
~GLProgram();
bool AddVertexShader(const std::string &source);
bool AddGeometryShader(const std::string &source);
bool AddFragmentShader(const std::string &source);
void SetParameteri(int param, int value);
bool Link();
bool IsOk() const;
std::string GetInfoLog() const;
std::string GetInfoLogs() const;
void Start();
void Stop();
bool SetUniform1f(const std::string &name, float v1);
bool SetUniform2f(const std::string &name, float v1, float v2);
bool SetUniform3f(const std::string &name, float v1, float v2, float v3);
bool SetUniform4f(const std::string &name,
float v1, float v2, float v3, float v4);
bool SetUniform1fv(const std::string &name, int num, const float *v);
bool SetUniform2fv(const std::string &name, int num, const float *v);
bool SetUniform3fv(const std::string &name, int num, const float *v);
bool SetUniform4fv(const std::string &name, int num, const float *v);
bool SetUniform1i(const std::string &name, int v1);
bool SetUniform2i(const std::string &name, int v1, int v2);
bool SetUniform3i(const std::string &name, int v1, int v2, int v3);
bool SetUniform4i(const std::string &name, int v1, int v2, int v3, int v4);
bool SetUniformMatrix2fv(const std::string &name,
int count, float *v, bool transpose = false);
bool SetUniformMatrix3fv(const std::string &name,
int count, float *v, bool transpose = false);
bool SetUniformMatrix4fv(const std::string &name,
int count, float *v, bool transpose = false);
bool UseTexture(const std::string &name, int texunit);
bool BindAttribLocation(const std::string &name, int index);
int GetAttribLocation(const std::string &name);
std::vector<GLAttributeInfo> GetActiveAttributes();
std::vector<GLUniformInfo> GetActiveUniforms();
// Advanced use only
void AttachShader(GLShader *shader);
void AttachShader(GLShader &shader);
void DetachShader(GLShader *shader);
void DetachShader(GLShader &shader);
protected:
GLuint id;
std::set<GLShader*> shaders;
bool inuse;
GLProgram();
private:
// Not implemented
GLProgram(const GLProgram&);
void operator=(const GLProgram&);
};