-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDisplay.cpp
More file actions
55 lines (46 loc) · 1.07 KB
/
Copy pathDisplay.cpp
File metadata and controls
55 lines (46 loc) · 1.07 KB
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
#include "Display.h"
namespace Display
{
std::unique_ptr<sf::Window> window;
void init()
{
sf::ContextSettings settings;
settings.depthBits = 24;
settings.majorVersion = 3;
settings.minorVersion = 3; // OpenGL 3.3
// create the SFML window
window = std::make_unique<sf::Window>(sf::VideoMode(WIDTH, HEIGHT), "Window", sf::Style::Close, settings);
glewInit();
// set the viewport to cover the entire window
glViewport(0, 0, WIDTH, HEIGHT);
}
void close()
{
window->close();
}
void clear()
{
// set the clear color to black
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
}
void update()
{
window->display();
}
void checkForClose()
{
sf::Event e;
while (window->pollEvent(e))
{
if (e.type == sf::Event::Closed)
{
close();
}
}
}
bool isOpen()
{
return window->isOpen();
}
}