openMSX
SDLOutputSurface.hh
Go to the documentation of this file.
1 #ifndef SDLOUTPUTSURFACE_HH
2 #define SDLOUTPUTSURFACE_HH
3 
4 #include "OutputSurface.hh"
5 #include <cassert>
6 #include <SDL.h>
7 
8 namespace openmsx {
9 
11 {
12 public:
13  SDLDirectPixelAccess(SDL_Surface* surface_);
15 
16  template<typename Pixel>
17  [[nodiscard]] Pixel* getLinePtr(unsigned y) {
18  return reinterpret_cast<Pixel*>(static_cast<char*>(surface->pixels) + y * surface->pitch);
19  }
20 
21 private:
22  SDL_Surface* surface;
23 };
24 
30 {
31 public:
34 
35  [[nodiscard]] SDL_Surface* getSDLSurface() const { return surface; }
36  [[nodiscard]] SDL_Renderer* getSDLRenderer() const { return renderer; }
37 
50  {
52  }
53 
57  virtual void flushFrameBuffer() {}
58 
62  virtual void clearScreen() {}
63 
64 protected:
65  SDLOutputSurface() = default;
66 
67  void setSDLPixelFormat(const SDL_PixelFormat& format);
68  void setSDLSurface(SDL_Surface* surface_) { surface = surface_; }
69  void setSDLRenderer(SDL_Renderer* r) { renderer = r; }
70 
71 private:
72  SDL_Surface* surface = nullptr;
73  SDL_Renderer* renderer = nullptr;
74 };
75 
76 } // namespace openmsx
77 
78 #endif
A frame buffer where pixels can be written to.
Pixel * getLinePtr(unsigned y)
SDLDirectPixelAccess(SDL_Surface *surface_)
A frame buffer where pixels can be written to.
void setSDLSurface(SDL_Surface *surface_)
virtual void flushFrameBuffer()
Copy frame buffer to display buffer.
virtual void clearScreen()
Clear frame buffer (paint it black).
SDLDirectPixelAccess getDirectPixelAccess()
Return a SDLDirectPixelAccess object.
SDL_Surface * getSDLSurface() const
SDLOutputSurface & operator=(const SDLOutputSurface &)=delete
void setSDLPixelFormat(const SDL_PixelFormat &format)
SDL_Renderer * getSDLRenderer() const
SDLOutputSurface(const SDLOutputSurface &)=delete
void setSDLRenderer(SDL_Renderer *r)
This file implemented 3 utility functions:
Definition: Autofire.cc:9
uint32_t Pixel