-
Notifications
You must be signed in to change notification settings - Fork 0
/
GLfuncs.cpp
72 lines (58 loc) · 1.63 KB
/
GLfuncs.cpp
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
#include "gameinclude.h"
extern int screenwidth;
extern int screenheight;
extern player mainPlayer;
extern bool _move;
extern Point mouse;
extern unit *enemy;
extern bool *en_move;
extern int enemy_size;
extern bool ingame;
extern menu Menu;
void resize(int width, int height)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();//unsure what this does?
gluOrtho2D(0.0, width, 0, height);//changes the view to the screen ~ IMPORTANT
glScalef(1, -1, 1);//inverts the y axis
glTranslatef(0, -screenheight, 0);//changes the xy scale, in opengl, 0,0 is bottom left, this makes it upper left
glViewport(0, 0, width, height);
glMatrixMode(GL_MODELVIEW);
screenwidth = width;
screenheight = height;
}
void getResolution()
{
RECT desktop;
// Get a handle to the desktop window
const HWND hDesktop = GetDesktopWindow();
// Get the size of screen to the variable desktop
GetWindowRect(hDesktop, &desktop);
// The top left corner will have coordinates (0,0)
// and the bottom right corner will have coordinates
// (horizontal, vertical)
screenwidth = desktop.right;
screenheight = desktop.bottom;
}
void display(void)
{
if (!ingame )
{
Menu.drawMenu();
}
else
{
//movements handling
playerMovement();//player collisons handled inside this function
enemyMovement();
//player drawing
glPushAttrib(GL_CURRENT_BIT);//keeps players color from changing
glColor4f(0.0, 1.0, 0.0,1.0);
drawPlayer();
//enemy drawing
for (int x=0; x<enemy_size; x++)
drawEnemy(enemy[x].getPosition().x, enemy[x].getPosition().y,enemy[x].getRadius());
}
glutSwapBuffers();//swap bufferes!!!! Important for animation
// glFlush();
}