displayManager.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef DISPLAYMANAGER_H
  2. #define DISPLAYMANAGER_H
  3. #include "SDL.h"
  4. #include "buffer.h"
  5. //Manages all low level display and window SDL stuff
  6. //Currently set up to work using SDL2 hardware rendering
  7. //I tested software rendering and although it was faster for simple color passes
  8. //It was slower when I tried to implement alpha blending, so I decided to revert
  9. //Back to the hardware accelerated backend.
  10. class DisplayManager{
  11. public:
  12. const static int SCREEN_WIDTH = 640; //640
  13. const static int SCREEN_HEIGHT = 480; //480
  14. const static int SCREEN_PITCH = SCREEN_HEIGHT*sizeof(Uint32);
  15. //Dummy Constructor / Destructor
  16. DisplayManager();
  17. ~DisplayManager();
  18. //Initializes SDL context and creates window according to values above
  19. bool startUp();
  20. void shutDown();
  21. //Clear screens to black
  22. void clear();
  23. //Swaps the pixel buffer with the texture buffer and draws to screen
  24. void swapBuffers(Buffer<Uint32> *pixelBuffer);
  25. private:
  26. bool startSDL();
  27. bool createWindow();
  28. bool createSDLRenderer();
  29. bool createScreenTexture();
  30. SDL_Texture *mTexture;
  31. SDL_Renderer *mSDLRenderer;
  32. SDL_Window *mWindow;
  33. //These are only really needed for the texture copying operation
  34. int mTexturePitch;
  35. void *mTexturePixels;
  36. };
  37. #endif