title: SDL window instantly closing
body: <p>I followed a youtube tutorial on how to get started with SDL and my current progress seems to skip my handleEvents, update &amp; render functions and just clear &amp; close the window.</p>
  
  <p>Main.cpp</p>
  
  <pre><code>#include "main.h"
  
  using namespace std;
  
  SDLMain* sdlwindow = nullptr;
  
  int main(int argc, char *args[])
  {
      sdlwindow = new SDLMain();
      sdlwindow-&gt;init("PLS - Partikel &amp; Lyd System", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, false);
  
      while (sdlwindow-&gt;online()) {
          sdlwindow-&gt;handleEvents();
          sdlwindow-&gt;update();
          sdlwindow-&gt;render();
      }
  
      sdlwindow-&gt;clean();
      return 0;
  }
  </code></pre>
  
  <p>SDLMain.cpp</p>
  
  <pre><code>#include "SDLmain.h"
  
  SDLMain::SDLMain(){}
  SDLMain::~SDLMain(){}
  void SDLMain::init(const char* TITLE, int XPOS, int YPOS, int WIDTH, int HEIGHT, bool FULLSCREEN){
  
      int FLAGS = 0;
      if (FULLSCREEN) {
          FLAGS = SDL_WINDOW_FULLSCREEN;
      }
  
      if (SDL_Init(SDL_INIT_EVERYTHING == 0)) {
  
          window = SDL_CreateWindow(TITLE, XPOS, YPOS, WIDTH, HEIGHT, FLAGS);
          if (window) {
              std::cout &lt;&lt; "SDL Window was successfully created!" &lt;&lt; std::endl;
          }
          else {
              std::cout &lt;&lt; "SDL Window failed. SDL Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          }
  
          renderer = SDL_CreateRenderer(window, -1, 0);
          if (renderer) {
              SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
              std::cout &lt;&lt; "SDL Renderer was successfully created!" &lt;&lt; std::endl;
          }
          else {
              std::cout &lt;&lt; "SDL Renderer failed. SDL Error: " &lt;&lt; SDL_GetError() &lt;&lt; std::endl;
          }
  
          isOnline = true;
      }
      else {
          isOnline = false;
      }
  }
  
  void SDLMain::handleEvents() {
      SDL_Event event;
      SDL_PollEvent(&amp;event);
  
      switch (event.type) {
      case SDL_QUIT:
          isOnline = false;
          break;
  
      default:
          break;
      }
  }
  void SDLMain::update(){}
  void SDLMain::render(){
      SDL_RenderClear(renderer);
      //Add stuff to render
      SDL_RenderPresent(renderer);
  }
  void SDLMain::clean(){
      SDL_DestroyWindow(window);
      SDL_DestroyRenderer(renderer);
      SDL_Quit();
      std::cout &lt;&lt; "SDL System cleaned!" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>SDLMain.h</p>
  
  <pre><code>#pragma once
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;SDL.h&gt;
  
  class SDLMain {
  public:
      SDLMain();
      ~SDLMain();
  
      void init(const char* TITLE, int XPOS, int YPOS, int WIDTH, int HEIGHT, bool FULLSCREEN);
      void handleEvents();
      void update();
      void render();
      void clean();
  
      bool online() {
          return isOnline;
      }
  
  private:
      bool isOnline;
      SDL_Window* window;
      SDL_Renderer* renderer;
  };
  </code></pre>