Changeset d5f2b42 in opengl-game


Ignore:
Timestamp:
Aug 30, 2019, 7:25:55 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
d8cb15e
Parents:
d02c25f
Message:

Create a generic GetError() function in game-gui that returns the last error returned by a call to some other function in game-gui

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • game-gui-sdl.cpp

    rd02c25f rd5f2b42  
    11#include "game-gui-sdl.hpp"
     2
     3string GameGui_SDL::s_errorMessage;
     4
     5string& GameGui_SDL::GetError() {
     6   GameGui_SDL::s_errorMessage = SDL_GetError();
     7
     8   return GameGui_SDL::s_errorMessage;
     9}
    210
    311bool GameGui_SDL::Init() {
     
    513   // prevents SDL from setting up its own handlers for SIG_SEGV and stuff like that
    614
    7    // If this function fails, I can call SDL_GetError() for more info
    8    // I should create a generic error retrieval function, similar to SDL_GetError()
     15   GameGui_SDL::s_errorMessage = "No error";
    916
    10    // cout << "SDL could not initialize! SDL_Error: " << SDL_GetError() << endl;
    11 
    12    // TODO: Print out contextual error messages instead of just returning
    1317   if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
    1418      return RTWO_ERROR;
  • game-gui-sdl.hpp

    rd02c25f rd5f2b42  
    1111class GameGui_SDL : public GameGui {
    1212   public:
     13      string& GetError();
     14
    1315      bool Init();
    1416      void Shutdown();
     
    2628   private:
    2729      SDL_Window* window;
     30
     31      static string s_errorMessage;
    2832};
    2933
  • game-gui.hpp

    rd02c25f rd5f2b42  
    1818      virtual ~GameGui() {};
    1919
     20      virtual string& GetError() = 0;
     21
    2022      virtual bool Init() = 0;
    2123      virtual void Shutdown() = 0;
  • vulkan-game.cpp

    rd02c25f rd5f2b42  
    3030   if (gui->Init() == RTWO_ERROR) {
    3131      cout << "UI library could not be initialized!" << endl;
    32       cout << SDL_GetError() << endl;
     32      cout << gui->GetError() << endl;
    3333      return RTWO_ERROR;
    3434   }
Note: See TracChangeset for help on using the changeset viewer.