-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGobanShader.h
138 lines (119 loc) · 3.23 KB
/
GobanShader.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef GOBAN_GOBANSHADER_H
#define GOBAN_GOBANSHADER_H
#include <string>
#include "glyphy/GlyphyFont.h"
#include "Metrics.h"
#include "GobanModel.h"
class GobanView;
#include "OpenGL.h"
#include "Board.h"
#include "GobanModel.h"
#include "Camera.h"
#include <glm/vec3.hpp>
#include <glm/geometric.hpp>
#include <glm/gtc/matrix_inverse.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "spdlog/spdlog.h"
GLuint shaderCompileFromString(GLenum type, const std::string& source);
GLuint make_buffer(GLenum target, const void *, GLsizei);
std::string createShaderFromFile(const std::string& filename);
class GobanShader {
public:
GobanShader(const GobanView& view): shadersReady(false), shaderChanged(false),
currentProgram(-1), ww(-1.0f), stoneh(-1.0f),
width(0), height(0), gamma(1.0f), contrast(0.0f),
view(view), animT(0.5f)
{
init();
}
void initProgram(const std::string& vprogram, const std::string& fprogram);
void setMetrics(const Metrics &);
void init();
void destroy();
void draw(const GobanModel&, const DDG::Camera&, int, float);
int choose(int idx);
void use();
void unuse();
void setTime(float);
void setPan(glm::vec3);
void setRotation(glm::mat4x4);
void setResolution(float, float);
void setGamma(float);
void setContrast(float);
float getGamma(){ return gamma;}
float getContrast(){ return contrast;}
bool isReady() { return shadersReady;}
float getStoneHeight() const { return currentProgramH; }
void setReady() { shadersReady = true; }
int getCurrentProgram() const {return currentProgram;}
bool shaderAttachFromString(GLuint program, GLenum type, const std::string& source);
private:
GLuint gobanProgram = 0;
GLuint iVertex = 0;
GLint iMouse;
GLint iDim;
GLint iModelView;
GLint iStone;
GLint iResolution;
GLint iStones;
GLuint bufStones;
GLuint uBlockIndex;
GLuint blockBindingPoint = 1;
GLuint vertexBuffer, elementBuffer;
GLint iGamma;
GLint iContrast;
GLint fsu_fNDIM;
GLint fsu_boardaa;
GLint fsu_boardbb;
GLint fsu_boardcc;
GLint fsu_wwx;
GLint fsu_wwy;
GLint fsu_w;
GLint fsu_h;
GLint fsu_stoneRadius;
GLint fsu_d;
GLint fsu_stoneradius2;
GLint fsu_dn;
GLint fsu_b;
GLint fsu_y;
GLint fsu_px;
GLint fsu_pxs;
GLint fsu_r1;
GLint fsu_r2;
GLint fsu_r123r123;
GLint fsu_rrr;
GLint fsu_r1r1ir2ir2;
GLint fsu_maxBound;
GLint fsu_dw;
GLint fsu_iscale;
GLint fsu_bowlRadius;
GLint fsu_bowlRadius2;
GLint fsu_cc;
GLint iWhiteCapturedCount;
GLint iBlackCapturedCount;
GLint iWhiteReservoirCount;
GLint iBlackReservoirCount;
GLint iddc;
GLint fsu_cursor;
int AA;
static const std::array<GLfloat, 16> vertexBufferData;
static const GLushort elementBufferData[];
GLint iTranslate;
GLint iTime;
GLint iAnimT;
GLint iAA;
GLuint vertexShader;
GLuint fragmentShader;
bool shadersReady;
bool shaderChanged;
int currentProgram;
float currentProgramH;
float ww, stoneh;
float width, height;
float gamma, contrast;
const GobanView& view;
public:
const float animT;
};
#endif