Changeset 0df3c9a in opengl-game
- Timestamp:
- Aug 29, 2019, 9:16:07 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 4eb4d0a
- Parents:
- eba8c0c
- Files:
-
- 2 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 } -
space-game.hpp
reba8c0c r0df3c9a 2 2 #define _SPACE_GAME_H 3 3 4 #include "game-gui-sdl.hpp" 5 6 const int SCREEN_WIDTH = 800; 7 const int SCREEN_HEIGHT = 600; 8 4 9 class SpaceGame { 5 10 public: 11 SpaceGame(); 12 ~SpaceGame(); 13 6 14 void run(); 15 16 private: 17 GameGui* gui; 18 SDL_Window* window; 19 20 bool initWindow(); 21 void initVulkan(); 22 void mainLoop(); 23 void cleanup(); 7 24 }; 8 25
Note:
See TracChangeset
for help on using the changeset viewer.