Changeset d8cb15e in opengl-game for opengl-game.cpp


Ignore:
Timestamp:
Aug 30, 2019, 7:30:53 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
5529ab5
Parents:
d5f2b42
Message:

Implement GetError() in game-gui-glfw and start using game-gui-glfw in opengl-game to show a window

File:
1 edited

Legend:

Unmodified
Added
Removed
  • opengl-game.cpp

    rd5f2b42 rd8cb15e  
    33#include <iostream>
    44
     5#include "game-gui-glfw.hpp"
     6
    57using namespace std;
    68
    79OpenGLGame::OpenGLGame() {
     10   gui = nullptr;
     11   window = nullptr;
    812}
    913
     
    1216
    1317void OpenGLGame::run() {
    14    cout << "Running like a boss!" << endl;
     18   if (initWindow() == RTWO_ERROR) {
     19      return;
     20   }
     21   initOpenGL();
     22   mainLoop();
     23   cleanup();
    1524}
     25
     26bool 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
     45void OpenGLGame::initOpenGL() {
     46}
     47
     48void OpenGLGame::mainLoop() {
     49   while (!glfwWindowShouldClose(window)) {
     50      glfwPollEvents();
     51
     52      glfwSwapBuffers(window);
     53   }
     54}
     55
     56void OpenGLGame::cleanup() {
     57   gui->DestroyWindow();
     58   gui->Shutdown();
     59   delete gui;
     60}
Note: See TracChangeset for help on using the changeset viewer.