-
Notifications
You must be signed in to change notification settings - Fork 2
/
StartScreen.cpp
102 lines (86 loc) · 2.72 KB
/
StartScreen.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
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
//
// StartScreen.cpp
// CastleBlast
//
// Created by Inês on 12/4/11.
// Copyright 2011 AVT. All rights reserved.
//
#include "StartScreen.h"
#include "Loader.h"
namespace CastleBlast {
StartScreen::StartScreen()
{
#ifdef __APPLE__
_startScreenImage = Loader::loadTexture("Images/StartScreen_Start.png");
_settingsScreenImage = Loader::loadTexture("Images/StartScreen_Settings.png");
#else
_startScreenImage = Loader::loadTexture("..\\..\\src\\Images\\StartScreen_Start.png");
_settingsScreenImage = Loader::loadTexture("..\\..\\src\\Images\\StartScreen_Settings.png");
#endif
}
StartScreen::~StartScreen() {}
void StartScreen::init()
{
cg::tWindowInfo win = cg::Manager::instance()->getApp()->getWindowInfo();
_width = win.width;
_height = win.height;
_start = true;
}
void StartScreen::draw()
{
if(_start)
glBindTexture(GL_TEXTURE_2D, _startScreenImage);
else
glBindTexture(GL_TEXTURE_2D, _settingsScreenImage);
glDisable(GL_DEPTH_TEST); // Disables Depth Testing
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,_width,0,_height,-1,1); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
glDisable(GL_LIGHTING);
glColor3d(1, 1, 1);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
{
glTexCoord2d(0, 0);
glVertex2d(0, 0);
glTexCoord2d(0, 1);
glVertex2d(0, _height);
glTexCoord2d(1, 1);
glVertex2d(_width, _height);
glTexCoord2d(1, 0);
glVertex2d(_width, 0);
}
glEnd();
glDisable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glEnable(GL_DEPTH_TEST);
}
void StartScreen::update(unsigned long elapsed_millis)
{
if(cg::KeyBuffer::instance()->isSpecialKeyDown(GLUT_KEY_DOWN))
_start = false;
if(cg::KeyBuffer::instance()->isSpecialKeyDown(GLUT_KEY_UP))
_start = true;
}
void StartScreen::onReshape(int width, int height)
{
_width = width;
_height = height;
}
bool StartScreen::isStart()
{
return _start;
}
void StartScreen::restart()
{
_start = true;
}
}