Changeset 0df3c9a in opengl-game for space-game.cpp
- Timestamp:
- Aug 29, 2019, 9:16:07 PM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 4eb4d0a
- Parents:
- eba8c0c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
space-game.cpp
reba8c0c r0df3c9a 1 1 #include "space-game.hpp" 2 2 3 #include <iostream> 4 5 #include "game-gui-sdl.hpp" 6 7 using namespace std; 8 9 SpaceGame::SpaceGame() { 10 gui = nullptr; 11 window = nullptr; 12 } 13 14 SpaceGame::~SpaceGame() { 15 } 16 3 17 void SpaceGame::run() { 18 if (initWindow() == RTWO_ERROR) { 19 return; 20 } 21 initVulkan(); 22 mainLoop(); 23 cleanup(); 4 24 } 25 26 bool SpaceGame::initWindow() { 27 gui = new GameGui_SDL(); 28 29 if (gui->Init() == RTWO_ERROR) { 30 cout << "UI library could not be initialized!" << endl; 31 cout << SDL_GetError() << endl; 32 return RTWO_ERROR; 33 } 34 cout << "GUI init succeeded" << endl; 35 36 window = (SDL_Window*) gui->CreateWindow("Vulkan Game", SCREEN_WIDTH, SCREEN_HEIGHT); 37 if (window == nullptr) { 38 cout << "Window could not be created!" << endl; 39 return RTWO_ERROR; 40 } 41 42 return RTWO_SUCCESS; 43 } 44 45 void SpaceGame::initVulkan() { 46 } 47 48 void SpaceGame::mainLoop() { 49 SDL_Event e; 50 bool quit = false; 51 52 while (!quit) { 53 while (SDL_PollEvent(&e)) { 54 if (e.type == SDL_QUIT) { 55 quit = true; 56 } 57 if (e.type == SDL_KEYDOWN) { 58 quit = true; 59 } 60 if (e.type == SDL_MOUSEBUTTONDOWN) { 61 quit = true; 62 } 63 } 64 } 65 } 66 67 void SpaceGame::cleanup() { 68 gui->DestroyWindow(); 69 gui->Shutdown(); 70 delete gui; 71 }
Note:
See TracChangeset
for help on using the changeset viewer.