Changeset f6521fb in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Sep 13, 2019, 1:30:24 AM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
c61323a
Parents:
203ab1b
Message:

Add processEvents() and pollEvent() to GameGui, implement them for GameGui_SDL, and add a union for different event types, similar to the SDL_Event union

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r203ab1b rf6521fb  
    6161
    6262void VulkanGame::mainLoop() {
    63    SDL_Event e;
    64    //MouseEvent mouseEvent;
     63   UIEvent e;
    6564   bool quit = false;
    6665
    6766   while (!quit) {
    68       /*
    6967      gui->processEvents();
    7068
    71       if (gui->getKeyEvent(SDLK_ESCAPE) == RTWO_KEY_EVENT_PRESSED) {
    72          quit = true;
    73       }
    74 
    75       while (gui->pollMouseEvent(&mouseEvent)) {
    76          cout << "Mouse click detected at (" << mouseEvent.x << ", " << mouseEvent.y << ")" << endl;
    77       }
    78       */
    79 
    80       while (SDL_PollEvent(&e)) {
    81          if (e.type == SDL_QUIT) {
    82             quit = true;
    83          }
    84          if (e.type == SDL_KEYDOWN) {
    85             quit = true;
    86          }
    87          if (e.type == SDL_MOUSEBUTTONDOWN) {
    88             quit = true;
     69      while (gui->pollEvent(&e)) {
     70         switch(e.type) {
     71            case UI_EVENT_QUIT:
     72               cout << "Quit event detected" << endl;
     73               quit = true;
     74               break;
     75            case UI_EVENT_WINDOW:
     76               cout << "Window event detected" << endl;
     77               // Currently unused
     78               break;
     79            case UI_EVENT_KEY:
     80               if (e.key.keycode == SDL_SCANCODE_ESCAPE) {
     81                  quit = true;
     82               } else {
     83                  cout << "Key event detected" << endl;
     84               }
     85               break;
     86            case UI_EVENT_MOUSEBUTTONDOWN:
     87               cout << "Mouse button down event detected" << endl;
     88               break;
     89            case UI_EVENT_MOUSEBUTTONUP:
     90               cout << "Mouse button up event detected" << endl;
     91               break;
     92            case UI_EVENT_MOUSEMOTION:
     93               break;
    8994         }
    9095      }
Note: See TracChangeset for help on using the changeset viewer.