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


Ignore:
Timestamp:
Sep 13, 2019, 2:51:30 AM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
1fcca9e
Parents:
f6521fb
Message:

Implement processEvents() and pollEvent() for GameGui_GLFW and re-implement the main loop in opengl-game using those functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • opengl-game.cpp

    rf6521fb rc61323a  
    5757
    5858void OpenGLGame::mainLoop() {
    59    //MouseEvent e;
     59   UIEvent e;
     60   bool quit = false;
    6061
    61    while (!glfwWindowShouldClose(window)) {
    62       /*
     62   while (!quit) {
    6363      gui->processEvents();
    6464
    65       if (gui->getKeyEvent(GLFW_KEY_ESCAPE) == RTWO_KEY_EVENT_PRESSED) {
    66          glfwSetWindowShouldClose(window, 1);
    67       }
    68 
    69       while (gui->pollMouseEvent(&e)) {
    70          cout << "Mouse click detected at (" << e.x << ", " << e.y << ")" << endl;
    71       }
    72       */
    73 
    74       glfwPollEvents();
    75 
    76       if (GameGui_GLFW::s_keyState[GLFW_KEY_ESCAPE] == GLFW_PRESS) {
    77          glfwSetWindowShouldClose(window, 1);
     65      while (gui->pollEvent(&e)) {
     66         switch (e.type) {
     67            case UI_EVENT_QUIT:
     68               cout << "Quit event detected" << endl;
     69               quit = true;
     70               break;
     71            case UI_EVENT_KEY:
     72               if (e.key.keycode == GLFW_KEY_ESCAPE) {
     73                  quit = true;
     74               } else {
     75                  cout << "Key event detected" << endl;
     76               }
     77               break;
     78            default:
     79               cout << "Unhandled UI event: " << e.type << endl;
     80         }
    7881      }
    7982
Note: See TracChangeset for help on using the changeset viewer.