feature/imgui-sdl
points-test
|
Last change
on this file since 76d19a8 was d5f2b42, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago |
|
Create a generic GetError() function in game-gui that returns the last error returned by a call to some other function in game-gui
|
-
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 |
|
|---|
| 8 | using namespace std;
|
|---|
| 9 |
|
|---|
| 10 | VulkanGame::VulkanGame() {
|
|---|
| 11 | gui = nullptr;
|
|---|
| 12 | window = nullptr;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | VulkanGame::~VulkanGame() {
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | void VulkanGame::run() {
|
|---|
| 19 | if (initWindow() == RTWO_ERROR) {
|
|---|
| 20 | return;
|
|---|
| 21 | }
|
|---|
| 22 | initVulkan();
|
|---|
| 23 | mainLoop();
|
|---|
| 24 | cleanup();
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | bool 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 << gui->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 |
|
|---|
| 46 | void VulkanGame::initVulkan() {
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | void 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 |
|
|---|
| 68 | void VulkanGame::cleanup() {
|
|---|
| 69 | gui->DestroyWindow();
|
|---|
| 70 | gui->Shutdown();
|
|---|
| 71 | delete gui;
|
|---|
| 72 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.