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 <concepts>
7#include <SDL.h>
8
9namespace openmsx {
10
12{
13public:
14 SDLDirectPixelAccess(SDL_Surface* surface_);
16
17 template<std::unsigned_integral Pixel>
18 [[nodiscard]] Pixel* getLinePtr(unsigned y) {
19 return reinterpret_cast<Pixel*>(static_cast<char*>(surface->pixels) + y * surface->pitch);
20 }
21
22private:
23 SDL_Surface* surface;
24};
25
31{
32public:
35
36 [[nodiscard]] SDL_Surface* getSDLSurface() const { return surface; }
37 [[nodiscard]] SDL_Renderer* getSDLRenderer() const { return renderer; }
38
51 {
53 }
54
58 virtual void flushFrameBuffer() {}
59
63 virtual void clearScreen() {}
64
65protected:
66 SDLOutputSurface() = default;
67
68 void setSDLPixelFormat(const SDL_PixelFormat& format);
69 void setSDLSurface(SDL_Surface* surface_) { surface = surface_; }
70 void setSDLRenderer(SDL_Renderer* r) { renderer = r; }
71
72private:
73 SDL_Surface* surface = nullptr;
74 SDL_Renderer* renderer = nullptr;
75};
76
77} // namespace openmsx
78
79#endif
A frame buffer where pixels can be written to.
SDLDirectPixelAccess(SDL_Surface *surface_)
Pixel * getLinePtr(unsigned y)
A frame buffer where pixels can be written to.
void setSDLSurface(SDL_Surface *surface_)
virtual void flushFrameBuffer()
Copy frame buffer to display buffer.
SDL_Renderer * getSDLRenderer() const
SDL_Surface * getSDLSurface() const
virtual void clearScreen()
Clear frame buffer (paint it black).
SDLDirectPixelAccess getDirectPixelAccess()
Return a SDLDirectPixelAccess object.
void setSDLPixelFormat(const SDL_PixelFormat &format)
SDLOutputSurface(const SDLOutputSurface &)=delete
SDLOutputSurface & operator=(const SDLOutputSurface &)=delete
void setSDLRenderer(SDL_Renderer *r)
This file implemented 3 utility functions:
Definition: Autofire.cc:9
uint32_t Pixel