-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window.cpp
61 lines (48 loc) · 1.38 KB
/
Window.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
#ifndef WIDNOW_DOT_H_
#define WINDOW_DOT_H_
#include "constants.h"
#include "Window.h"
#include <iostream>
using std::cout;
using std::endl;
namespace game {
//Default constructor that sets up the window to be rendered to
Window::Window(): theWindow(NULL) {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
cout << "SDL could not initialize! SDL_Error: " << SDL_GetError() << endl;
}
else {
if( !SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1")) {
cout << "Linear texture filtering won't work son." << endl;
}
this->theWindow = SDL_CreateWindow("Platformer", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
if(theWindow == NULL) {
cout << "Window could not be created! SDL_Error: "
<< SDL_GetError() << endl;
}
}
}
//copy constructor
Window::Window(const Window& toCopy): theWindow(NULL) {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
cout << "SDL could not initialize! SDL_Error: " << SDL_GetError() << endl;
}
else {
this->theWindow = SDL_CreateWindow("Platformer", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
if(theWindow == NULL) {
cout << "Window could not be created! SDL_Error: "
<< SDL_GetError() << endl;
}
}
}
//deallocate memory for the window
Window::~Window() {
if (theWindow != NULL) {
SDL_DestroyWindow(theWindow);
theWindow = NULL;
}
}
}
#endif