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