feature/imgui-sdl
points-test
|
Last change
on this file since 76d19a8 was d8cb15e, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago |
|
Implement GetError() in game-gui-glfw and start using game-gui-glfw in opengl-game to show a window
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | #include "opengl-game.hpp"
|
|---|
| 2 |
|
|---|
| 3 | #include <iostream>
|
|---|
| 4 |
|
|---|
| 5 | #include "game-gui-glfw.hpp"
|
|---|
| 6 |
|
|---|
| 7 | using namespace std;
|
|---|
| 8 |
|
|---|
| 9 | OpenGLGame::OpenGLGame() {
|
|---|
| 10 | gui = nullptr;
|
|---|
| 11 | window = nullptr;
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | OpenGLGame::~OpenGLGame() {
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | void OpenGLGame::run() {
|
|---|
| 18 | if (initWindow() == RTWO_ERROR) {
|
|---|
| 19 | return;
|
|---|
| 20 | }
|
|---|
| 21 | initOpenGL();
|
|---|
| 22 | mainLoop();
|
|---|
| 23 | cleanup();
|
|---|
| 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
TracBrowser
for help on using the repository browser.