source:
opengl-game/vulkan-game.cpp@
7fc5e27
Last change on this file since 7fc5e27 was 1ce9afe, checked in by , 5 years ago | |
---|---|
|
|
File size: 1.5 KB |
Rev | Line | |
---|---|---|
[99d44b2] | 1 | #include "vulkan-game.hpp" |
[850e84c] | 2 | |
[0df3c9a] | 3 | #include <iostream> |
4 | ||
[5edbd58] | 5 | #include "consts.hpp" |
6 | ||
[99d44b2] | 7 | #define GAMEGUI_INCLUDE_VULKAN |
[0df3c9a] | 8 | #include "game-gui-sdl.hpp" |
9 | ||
10 | using namespace std; | |
11 | ||
[99d44b2] | 12 | VulkanGame::VulkanGame() { |
[0df3c9a] | 13 | gui = nullptr; |
14 | window = nullptr; | |
15 | } | |
16 | ||
[99d44b2] | 17 | VulkanGame::~VulkanGame() { |
[0df3c9a] | 18 | } |
19 | ||
[5edbd58] | 20 | void VulkanGame::run(unsigned int width, unsigned int height, unsigned char guiFlags) { |
21 | if (initWindow(width, height, guiFlags) == RTWO_ERROR) { | |
[0df3c9a] | 22 | return; |
23 | } | |
24 | initVulkan(); | |
25 | mainLoop(); | |
26 | cleanup(); | |
27 | } | |
28 | ||
[5edbd58] | 29 | bool VulkanGame::initWindow(unsigned int width, unsigned int height, unsigned char guiFlags) { |
[0df3c9a] | 30 | gui = new GameGui_SDL(); |
31 | ||
32 | if (gui->Init() == RTWO_ERROR) { | |
33 | cout << "UI library could not be initialized!" << endl; | |
[d5f2b42] | 34 | cout << gui->GetError() << endl; |
[0df3c9a] | 35 | return RTWO_ERROR; |
36 | } | |
37 | cout << "GUI init succeeded" << endl; | |
38 | ||
[1ce9afe] | 39 | window = (SDL_Window*) gui->CreateWindow("Vulkan Game", width, height, guiFlags | GUI_FLAGS_WINDOW_FULLSCREEN); |
[0df3c9a] | 40 | if (window == nullptr) { |
41 | cout << "Window could not be created!" << endl; | |
42 | return RTWO_ERROR; | |
43 | } | |
44 | ||
45 | return RTWO_SUCCESS; | |
46 | } | |
47 | ||
[99d44b2] | 48 | void VulkanGame::initVulkan() { |
[0df3c9a] | 49 | } |
50 | ||
[99d44b2] | 51 | void VulkanGame::mainLoop() { |
[0df3c9a] | 52 | SDL_Event e; |
53 | bool quit = false; | |
54 | ||
55 | while (!quit) { | |
56 | while (SDL_PollEvent(&e)) { | |
57 | if (e.type == SDL_QUIT) { | |
58 | quit = true; | |
59 | } | |
60 | if (e.type == SDL_KEYDOWN) { | |
61 | quit = true; | |
62 | } | |
63 | if (e.type == SDL_MOUSEBUTTONDOWN) { | |
64 | quit = true; | |
65 | } | |
66 | } | |
67 | } | |
68 | } | |
69 | ||
[99d44b2] | 70 | void VulkanGame::cleanup() { |
[0df3c9a] | 71 | gui->DestroyWindow(); |
72 | gui->Shutdown(); | |
73 | delete gui; | |
[850e84c] | 74 | } |
Note:
See TracBrowser
for help on using the repository browser.