-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawBoard.hpp
106 lines (80 loc) · 3.11 KB
/
drawBoard.hpp
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
#include <stdio.h>
#include <cassert>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <errno.h>
const int ENUM_chessBoard = 20;
const int ENUM_piece_whitePawn = 11;
const int ENUM_piece_whiteBishop = 10;
const int ENUM_piece_whiteKnight = 9;
const int ENUM_piece_whiteRook = 8;
const int ENUM_piece_whiteKing = 7;
const int ENUM_piece_whiteQueen = 6;
const int ENUM_piece_blackPawn = 5;
const int ENUM_piece_blackBishop = 4;
const int ENUM_piece_blackKnight = 3;
const int ENUM_piece_blackRook = 2;
const int ENUM_piece_blackKing = 1;
const int ENUM_piece_blackQueen = 0;
const int ENUM_undoKeyPressed = 0;
const int ENUM_redoKeyPressed = 1;
const int ENUM_setMousePromotion_Queen = 2;
const int ENUM_setMousePromotion_Rook = 3;
const int ENUM_setMousePromotion_Bishop = 4;
const int ENUM_setMousePromotion_Knight = 5;
class myOpenGLWindow{
public:
bool endGui = false;
static int windowWidth;
static int windowHeight;
static bool mouseDown;
static double mouseX;
static double mouseY;
static int clickedBoardPosX;
static int clickedBoardPosY;
static int releasedBoardPosX;
static int releasedBoardPosY;
static bool hasMouseData;
static bool hasKeyboardCommand;
static int keyboardCommand;
static glm::mat4 perspectiveMatrix;
GLuint inputPosAttributeLocation;
GLuint MVPUniformLocation;
GLuint objEnumUniformLocation;
GLFWwindow* mainWindow;
GLuint shaderProgramID = -1;
int numTexturesInitialized = 0;
unsigned int* textureIDs = NULL;
GLint* textureUniformsLocs;
GLuint vaoThingID;
GLuint vboThingID;
static void glfwCallback_error(int error, const char* desc);
static void glfwCallback_keyboardClicked(GLFWwindow* window, int key, int scancode, int action, int mods);
static void glfwCallback_mouseMoved(GLFWwindow* window, double xpos, double ypos);
static void glfwCallback_mouseClicked(GLFWwindow* window, int button, int action, int mods);
static void glfwCallback_windowSizeChanged(GLFWwindow* window, int width, int height);
void setInputCallbacks(void);
void drawSquare(int ENUM, glm::vec3 pos, glm::vec3 size);
void drawThickLine(int ENUM, glm::vec3 start, glm::vec3 end, double thickness);
void drawLine(int ENUM, glm::vec3 start, glm::vec3 end);
static void screenPosToBoardPos(double screenX, double screenY, int* boardX, int* boardY);
static void setOrthoRatioCorrect(void);
void enableTransparency(void);
GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path);
void initGLFW(void);
void initBuffers(void);
void initTextures(int numTextures);
void loadTexture(const char* filename, int textureUnit_num);
unsigned char* readTexture(const char* filename, int* width, int* height, int* numChannels);
GLint getProgramTextureUniformLoc(int textureNum);
void drawStuffOpenGL(chessGame* currentGame, engine* engine1, engine* engine2);
void loopStuffGLFW(double input_timeout);
void drawEngineInfo(engine* engineToDraw);
void closeGLFW(void);
int pieceToEnum(char piece);
myOpenGLWindow(void);
};