-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindowsystem.cc
78 lines (59 loc) · 1.97 KB
/
windowsystem.cc
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
#include "windowsystem.h"
#include "util.h"
#include "utilvr.h"
using namespace std;
WindowSystem::WindowSystem() : width(800), height(800) {
}
WindowSystem::~WindowSystem() {
if (window) {
SDL_DestroyWindow(window);
SDL_Quit();
window = 0;
}
}
void WindowSystem::init() {
sdl_check(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER));
init_window();
}
void WindowSystem::init_window() {
cout << "in setup window" << endl;
int pos_x = 700;
int pos_y = 100;
Uint32 wflags = SDL_WINDOW_SHOWN;
window = SDL_CreateWindow( "hellovr [Vulkan]", pos_x, pos_y, width, height, wflags );
if (!window) {
cerr << "SDL Window problem: " << SDL_GetError() << endl;
throw "";
}
cout << "setting title" << endl;
string title("Window Title");
SDL_SetWindowTitle( window, title.c_str() );
}
void WindowSystem::setup() {
vector<Pos2Tex2> verts;
//left eye verts
verts.push_back( Pos2Tex2{ Vector2(-1, -1), Vector2(0, 1)});
verts.push_back( Pos2Tex2{ Vector2(0, -1), Vector2(1, 1)} );
verts.push_back( Pos2Tex2{ Vector2(-1, 1), Vector2(0, 0)} );
verts.push_back( Pos2Tex2{ Vector2(0, 1), Vector2(1, 0) });
// right eye verts
verts.push_back( Pos2Tex2{ Vector2(0, -1), Vector2(0, 1)} );
verts.push_back( Pos2Tex2{ Vector2(1, -1), Vector2(1, 1)} );
verts.push_back( Pos2Tex2{ Vector2(0, 1), Vector2(0, 0)} );
verts.push_back( Pos2Tex2{ Vector2(1, 1), Vector2(1, 0)} );
vector<uint16_t> indices = { 0, 1, 3, 0, 3, 2, 4, 5, 7, 4, 7, 6};
cout << "setting up buffers" << endl;
//aTODO: add initialisation
vertex_buf.init(verts, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, HOST);
index_buf.init(indices, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, HOST);
//framebuffer = new FrameRenderBuffer();
// framebuffer->init(width, height);
cout << " done with buffers" << endl;
}
void WindowSystem::destroy_buffers() {
vertex_buf.destroy();
index_buf.destroy();
}
void WindowSystem::show_message(string str) {
SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "Notice", str.c_str(), NULL );
}