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  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  SDL_Surface* getSDLSurface() const { return surface; }
36  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
openmsx::SDLOutputSurface::clearScreen
virtual void clearScreen()
Clear frame buffer (paint it black).
Definition: SDLOutputSurface.hh:62
openmsx::SDLDirectPixelAccess::~SDLDirectPixelAccess
~SDLDirectPixelAccess()
Definition: SDLOutputSurface.cc:16
openmsx::SDLOutputSurface::getSDLSurface
SDL_Surface * getSDLSurface() const
Definition: SDLOutputSurface.hh:35
openmsx::SDLDirectPixelAccess::getLinePtr
Pixel * getLinePtr(unsigned y)
Definition: SDLOutputSurface.hh:17
openmsx::SDLOutputSurface::getDirectPixelAccess
SDLDirectPixelAccess getDirectPixelAccess()
Return a SDLDirectPixelAccess object.
Definition: SDLOutputSurface.hh:49
openmsx::Pixel
uint32_t Pixel
Definition: GLHQLiteScaler.cc:98
openmsx::SDLOutputSurface::SDLOutputSurface
SDLOutputSurface()=default
openmsx::SDLOutputSurface
A frame buffer where pixels can be written to.
Definition: SDLOutputSurface.hh:30
openmsx::SDLOutputSurface::setSDLRenderer
void setSDLRenderer(SDL_Renderer *r)
Definition: SDLOutputSurface.hh:69
openmsx::SDLOutputSurface::setSDLPixelFormat
void setSDLPixelFormat(const SDL_PixelFormat &format)
Definition: SDLOutputSurface.cc:24
openmsx::SDLOutputSurface::SDLOutputSurface
SDLOutputSurface(const SDLOutputSurface &)=delete
openmsx::SDLOutputSurface::operator=
SDLOutputSurface & operator=(const SDLOutputSurface &)=delete
openmsx::SDLOutputSurface::getSDLRenderer
SDL_Renderer * getSDLRenderer() const
Definition: SDLOutputSurface.hh:36
openmsx::SDLOutputSurface::setSDLSurface
void setSDLSurface(SDL_Surface *surface_)
Definition: SDLOutputSurface.hh:68
OutputSurface.hh
openmsx::SDLOutputSurface::flushFrameBuffer
virtual void flushFrameBuffer()
Copy frame buffer to display buffer.
Definition: SDLOutputSurface.hh:57
openmsx::OutputSurface
A frame buffer where pixels can be written to.
Definition: OutputSurface.hh:20
openmsx::SDLDirectPixelAccess::SDLDirectPixelAccess
SDLDirectPixelAccess(SDL_Surface *surface_)
Definition: SDLOutputSurface.cc:6
openmsx::SDLDirectPixelAccess
Definition: SDLOutputSurface.hh:11
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5