source: opengl-game/vulkan-game.cpp@ 99d44b2

feature/imgui-sdl points-test
Last change on this file since 99d44b2 was 99d44b2, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago

Rename spacegame to vulkangame

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#include "vulkan-game.hpp"
2
3#include <iostream>
4
5#define GAMEGUI_INCLUDE_VULKAN
6#include "game-gui-sdl.hpp"
7
8using namespace std;
9
10VulkanGame::VulkanGame() {
11 gui = nullptr;
12 window = nullptr;
13}
14
15VulkanGame::~VulkanGame() {
16}
17
18void VulkanGame::run() {
19 if (initWindow() == RTWO_ERROR) {
20 return;
21 }
22 initVulkan();
23 mainLoop();
24 cleanup();
25}
26
27bool VulkanGame::initWindow() {
28 gui = new GameGui_SDL();
29
30 if (gui->Init() == RTWO_ERROR) {
31 cout << "UI library could not be initialized!" << endl;
32 cout << SDL_GetError() << endl;
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
46void VulkanGame::initVulkan() {
47}
48
49void VulkanGame::mainLoop() {
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
68void VulkanGame::cleanup() {
69 gui->DestroyWindow();
70 gui->Shutdown();
71 delete gui;
72}
Note: See TracBrowser for help on using the repository browser.