Changeset b6e60b4 in opengl-game


Ignore:
Timestamp:
Sep 3, 2019, 7:11:36 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
ed7c953
Parents:
7fc5e27
Message:

In vulkangame and openglgame:

  • use int instead of usigned int for width and heights paremters
  • Fix a bug where GUI_FLAGS_WINDOW_FULLSCREEN was being incorrectly checked
  • Print the size of a window after it has been created
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • opengl-game.cpp

    r7fc5e27 rb6e60b4  
    1717}
    1818
    19 void OpenGLGame::run(unsigned int width, unsigned int height, unsigned char guiFlags) {
     19void OpenGLGame::run(int width, int height, unsigned char guiFlags) {
    2020   if (initWindow(width, height, guiFlags) == RTWO_ERROR) {
    2121      return;
    2222   }
     23
    2324   initOpenGL();
    2425   mainLoop();
     
    2627}
    2728
    28 bool OpenGLGame::initWindow(unsigned int width, unsigned int height, unsigned char guiFlags) {
     29bool OpenGLGame::initWindow(int width, int height, unsigned char guiFlags) {
    2930   gui = new GameGui_GLFW();
    3031
    31    if (gui->Init() == RTWO_ERROR) {
     32   if (gui->init() == RTWO_ERROR) {
    3233      cout << "UI library could not be initialized!" << endl;
    33       cout << gui->GetError() << endl;
     34      cout << gui->getError() << endl;
    3435      return RTWO_ERROR;
    3536   }
    3637   cout << "GUI init succeeded" << endl;
    3738
    38    window = (GLFWwindow*) gui->CreateWindow("OpenGL Game", width, height, guiFlags | GUI_FLAGS_WINDOW_FULLSCREEN);
     39   window = (GLFWwindow*) gui->createWindow("OpenGL Game", width, height, guiFlags & GUI_FLAGS_WINDOW_FULLSCREEN);
    3940   if (window == nullptr) {
    4041      cout << "Window could not be created!" << endl;
    4142      return RTWO_ERROR;
    4243   }
     44
     45   int actualWidth=0, actualHeight=0;
     46   gui->getWindowSize(&actualWidth, &actualHeight);
     47
     48   cout << "Target window size: (" << width << ", " << height << ")" << endl;
     49   cout << "Actual window size: (" << actualWidth << ", " << actualHeight << ")" << endl;
    4350
    4451   return RTWO_SUCCESS;
     
    6168
    6269void OpenGLGame::cleanup() {
    63    gui->DestroyWindow();
    64    gui->Shutdown();
     70   gui->destroyWindow();
     71   gui->shutdown();
    6572   delete gui;
    6673}
  • opengl-game.hpp

    r7fc5e27 rb6e60b4  
    99      ~OpenGLGame();
    1010
    11       void run(unsigned int width, unsigned int height, unsigned char guiFlags);
     11      void run(int width, int height, unsigned char guiFlags);
    1212
    1313   private:
     
    1515      GLFWwindow* window;
    1616
    17       bool initWindow(unsigned int width, unsigned int height, unsigned char guiFlags);
     17      bool initWindow(int width, int height, unsigned char guiFlags);
    1818      void initOpenGL();
    1919      void mainLoop();
  • vulkan-game.cpp

    r7fc5e27 rb6e60b4  
    1818}
    1919
    20 void VulkanGame::run(unsigned int width, unsigned int height, unsigned char guiFlags) {
     20void VulkanGame::run(int width, int height, unsigned char guiFlags) {
    2121   if (initWindow(width, height, guiFlags) == RTWO_ERROR) {
    2222      return;
    2323   }
     24
    2425   initVulkan();
    2526   mainLoop();
     
    2728}
    2829
    29 bool VulkanGame::initWindow(unsigned int width, unsigned int height, unsigned char guiFlags) {
     30bool VulkanGame::initWindow(int width, int height, unsigned char guiFlags) {
    3031   gui = new GameGui_SDL();
    3132
    32    if (gui->Init() == RTWO_ERROR) {
     33   if (gui->init() == RTWO_ERROR) {
    3334      cout << "UI library could not be initialized!" << endl;
    34       cout << gui->GetError() << endl;
     35      cout << gui->getError() << endl;
    3536      return RTWO_ERROR;
    3637   }
    37    cout << "GUI init succeeded" << endl;
    3838
    39    window = (SDL_Window*) gui->CreateWindow("Vulkan Game", width, height, guiFlags | GUI_FLAGS_WINDOW_FULLSCREEN);
     39   window = (SDL_Window*) gui->createWindow("Vulkan Game", width, height, guiFlags & GUI_FLAGS_WINDOW_FULLSCREEN);
    4040   if (window == nullptr) {
    4141      cout << "Window could not be created!" << endl;
    4242      return RTWO_ERROR;
    4343   }
     44
     45   int actualWidth, actualHeight;
     46   gui->getWindowSize(&actualWidth, &actualHeight);
     47
     48   cout << "Target window size: (" << width << ", " << height << ")" << endl;
     49   cout << "Actual window size: (" << actualWidth << ", " << actualHeight << ")" << endl;
    4450
    4551   return RTWO_SUCCESS;
     
    6975
    7076void VulkanGame::cleanup() {
    71    gui->DestroyWindow();
    72    gui->Shutdown();
     77   gui->destroyWindow();
     78   gui->shutdown();
    7379   delete gui;
    7480}
  • vulkan-game.hpp

    r7fc5e27 rb6e60b4  
    99      ~VulkanGame();
    1010
    11       void run(unsigned int width, unsigned int height, unsigned char guiFlags);
     11      void run(int width, int height, unsigned char guiFlags);
    1212
    1313   private:
     
    1515      SDL_Window* window;
    1616
    17       bool initWindow(unsigned int width, unsigned int height, unsigned char guiFlags);
     17      bool initWindow(int width, int height, unsigned char guiFlags);
    1818      void initVulkan();
    1919      void mainLoop();
Note: See TracChangeset for help on using the changeset viewer.