Changeset d8cb15e in opengl-game for opengl-game.cpp
- Timestamp:
- Aug 30, 2019, 7:30:53 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 5529ab5
- Parents:
- d5f2b42
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
opengl-game.cpp
rd5f2b42 rd8cb15e 3 3 #include <iostream> 4 4 5 #include "game-gui-glfw.hpp" 6 5 7 using namespace std; 6 8 7 9 OpenGLGame::OpenGLGame() { 10 gui = nullptr; 11 window = nullptr; 8 12 } 9 13 … … 12 16 13 17 void OpenGLGame::run() { 14 cout << "Running like a boss!" << endl; 18 if (initWindow() == RTWO_ERROR) { 19 return; 20 } 21 initOpenGL(); 22 mainLoop(); 23 cleanup(); 15 24 } 25 26 bool OpenGLGame::initWindow() { 27 gui = new GameGui_GLFW(); 28 29 if (gui->Init() == RTWO_ERROR) { 30 cout << "UI library could not be initialized!" << endl; 31 cout << gui->GetError() << endl; 32 return RTWO_ERROR; 33 } 34 cout << "GUI init succeeded" << endl; 35 36 window = (GLFWwindow*) gui->CreateWindow("OpenGL 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 OpenGLGame::initOpenGL() { 46 } 47 48 void OpenGLGame::mainLoop() { 49 while (!glfwWindowShouldClose(window)) { 50 glfwPollEvents(); 51 52 glfwSwapBuffers(window); 53 } 54 } 55 56 void OpenGLGame::cleanup() { 57 gui->DestroyWindow(); 58 gui->Shutdown(); 59 delete gui; 60 }
Note:
See TracChangeset
for help on using the changeset viewer.