Changeset 83b5b4b in opengl-game


Ignore:
Timestamp:
Oct 4, 2019, 8:19:15 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
0b1b52d
Parents:
5b02676
git-author:
Dmitry Portnoy <dmitry.portnoy@…> (10/04/19 20:16:22)
git-committer:
Dmitry Portnoy <dmitry.portnoy@…> (10/04/19 20:19:15)
Message:

Handle window resize events in openglgame

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • game-gui-glfw.cpp

    r5b02676 r83b5b4b  
    156156   UIEvent e;
    157157   e.type = UI_EVENT_WINDOWRESIZE;
     158   e.windowResize.width = width;
     159   e.windowResize.height = height;
    158160
    159161   GameGui_GLFW::s_events.push(e);
  • game-gui.hpp

    r5b02676 r83b5b4b  
    4141};
    4242
     43struct WindowResizeEvent {
     44   EventType type;
     45   int width;
     46   int height;
     47};
     48
    4349struct UnknownEvent {
    4450   EventType type;
     
    5157   KeyEvent key;
    5258   MouseEvent mouse;
     59   WindowResizeEvent windowResize;
    5360   UnknownEvent unknown;
    5461};
  • graphics-pipeline.hpp

    r5b02676 r83b5b4b  
    66using namespace std;
    77
     8struct Viewport {
     9   int x;
     10   int y;
     11   int width;
     12   int height;
     13};
     14
    815class GraphicsPipeline {
    916public:
     
    1118
    1219   virtual void createPipeline(string vertShaderFile, string fragShaderFile) = 0;
     20
     21protected:
     22   Viewport viewport; // So far, not used for GraphicsPipeline_OpenGL
    1323};
    1424
  • opengl-game.cpp

    r5b02676 r83b5b4b  
    55#include "consts.hpp"
    66#include "logger.hpp"
     7
     8#include "utils.hpp"
    79
    810using namespace std;
     
    6668   }
    6769
     70   viewport = { 0, 0, gui->getWindowWidth(), gui->getWindowHeight() };
     71
    6872   cout << "Target window size: (" << width << ", " << height << ")" << endl;
    69    cout << "Actual window size: (" << gui->getWindowWidth() << ", " << gui->getWindowHeight() << ")" << endl;
     73   cout << "Actual window size: (" << viewport.width << ", " << viewport.height << ")" << endl;
    7074
    7175   return RTWO_SUCCESS;
     
    141145            case UI_EVENT_WINDOWRESIZE:
    142146               cout << "Window resize event detected" << endl;
     147               viewport.width = e.windowResize.width;
     148               viewport.height = e.windowResize.height;
    143149               break;
    144150            default:
  • opengl-game.hpp

    r5b02676 r83b5b4b  
    11#ifndef _OPENGL_GAME_H
    22#define _OPENGL_GAME_H
     3
     4#include <glm/glm.hpp>
    35
    46#include "IMGUI/imgui.h"
     
    1719   private:
    1820      GameGui* gui;
     21      Viewport viewport;
    1922
    2023      vector<GraphicsPipeline_OpenGL> graphicsPipelines;
Note: See TracChangeset for help on using the changeset viewer.