-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graphic.h
58 lines (52 loc) · 1.39 KB
/
Graphic.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
#pragma once
#include <GL/glut.h>
#include <cmath>
#include <iostream>
#include <string>
#define MAIN_MENU 1
#define IN_GAME 2
#define GAME_WHITE_WIN 3
#define GAME_BLACK_WIN 4
#define PAUSE 5
const int CircleSegment = 50;
struct Point
{
int x, y;
Point() { x = y = 0; }
Point(int a, int b) :x(a), y(b) {}
bool operator == (const Point& t)const
{
return x == t.x && y == t.y;
}
Point operator + (const Point& t)const
{
return Point(x + t.x, y + t.y);
}
};
struct Rect
{
int lx, ly, rx, ry;
Rect() { lx = ly = rx = ry = 0; }
Rect(int a, int b, int c, int d) :lx(a), ly(b), rx(c), ry(d) {}
bool inRect(Point a)
{
if (lx <= a.x && a.x <= rx && ly <= a.y && a.y <= ry)
return true;
return false;
}
};
struct Text
{
std::string str, font;
int size;
double R, G, B;
Text(std::string _str, std::string _font, int _size, double _R = 0, double _G = 0, double _B = 0)
:str(_str), font(_font), size(_size), R(_R), G(_G), B(_B) {}
};
GLint LoadTexture(const char* file_name);
void DrawTexture(Rect pos, GLint texture);
void DrawCircleTexture(Point pos, double radius, double text_radius, GLint texture);
void DrawTransCircle(Point pos, double radius, double R, double G, double B, double A);
void DrawString(const char* str, const char* font, int size, int x, int y, double R, double G, double B);
void DrawString(const Text& text, Point pos);
void SelectFont(int size, int charset, const char* face);