Changeset c6f0793 in opengl-game


Ignore:
Timestamp:
Feb 14, 2021, 12:11:30 AM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
9067efc
Parents:
d8cf709
git-author:
Dmitry Portnoy <dportnoy@…> (02/14/21 00:11:10)
git-committer:
Dmitry Portnoy <dportnoy@…> (02/14/21 00:11:30)
Message:

Use done instead of quit as the game loop flag and change it to an instance variable in SDLGame

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.cpp

    rd8cf709 rc6f0793  
    261261   bool show_another_window = false;
    262262
    263    // Main loop
    264    bool done = false;
     263   done = false;
    265264   while (!done) {
    266265      // Poll and handle events (inputs, window resize, etc.)
  • sdl-game.hpp

    rd8cf709 rc6f0793  
    66
    77#include <SDL2/SDL.h>
     8
    89#include "IMGUI/imgui_impl_vulkan.h"
    910
     
    3637         const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
    3738         void* pUserData);
     39
     40      bool done;
    3841
    3942      // TODO: Good place to start using smart pointers
  • vulkan-game.cpp

    rd8cf709 rc6f0793  
    112112
    113113void VulkanGame::quitGame() {
    114    this->quit = true;
     114   done = true;
    115115}
    116116
     
    771771
    772772void VulkanGame::mainLoop() {
    773    this->quit = false;
    774 
    775773   this->startTime = high_resolution_clock::now();
    776774   curTime = duration<float, seconds::period>(high_resolution_clock::now() - this->startTime).count();
     
    781779   lastSpawn_asteroid = curTime;
    782780
    783    while (!this->quit) {
     781   done = false;
     782   while (!done) {
    784783
    785784      this->prevTime = curTime;
     
    805804            case UI_EVENT_QUIT:
    806805               cout << "Quit event detected" << endl;
    807                this->quit = true;
     806               done = true;
    808807               break;
    809808            case UI_EVENT_WINDOW:
     
    821820
    822821               if (e.key.keycode == SDL_SCANCODE_ESCAPE) {
    823                   this->quit = true;
     822                  done = true;
    824823               } else if (e.key.keycode == SDL_SCANCODE_SPACE) {
    825824                  cout << "Adding a plane" << endl;
  • vulkan-game.hpp

    rd8cf709 rc6f0793  
    241241      const vec3 LASER_COLOR = vec3(0.2f, 1.0f, 0.2f);
    242242
    243       bool quit;
     243      bool done;
    244244
    245245      vec3 cam_pos;
Note: See TracChangeset for help on using the changeset viewer.