17 int width,
int height,
25 inputEventGenerator_, cliComm_, videoSystem_)
30 renderer.reset(SDL_CreateRenderer(
window.get(), -1, 0));
32 std::string_view err = SDL_GetError();
35 SDL_RenderSetLogicalSize(renderer.get(), width, height);
38 surface.
reset(SDL_CreateRGBSurface(
40 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000));
42 std::string_view err = SDL_GetError();
47 texture.reset(SDL_CreateTexture(
48 renderer.get(), SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STREAMING,
51 std::string_view err = SDL_GetError();
65 SDL_UpdateTexture(texture.get(),
nullptr, surface->pixels, surface->pitch);
66 SDL_RenderClear(render);
67 SDL_RenderCopy(render, texture.get(),
nullptr,
nullptr);
80 return std::make_unique<SDLSnow<uint16_t>>(*
this,
getDisplay());
84 return std::make_unique<SDLSnow<uint32_t>>(*
this,
getDisplay());
94 const bool openGL =
false;
96 return std::make_unique<OSDConsoleRenderer>(
97 reactor, console, width, height, openGL);
102 return std::make_unique<SDLOSDGUILayer>(gui);
107 return std::make_unique<SDLOffScreenSurface>(*surface);
119 VLA(
const void*, rowPointers, height);
121 for (
auto i :
xrange(
size_t(height))) {
122 rowPointers[i] = &buffer[3 * size_t(width) * i];
124 if (SDL_RenderReadPixels(
126 SDL_PIXELFORMAT_RGB24, buffer.
data(), width * 3)) {
127 throw MSXException(
"Couldn't acquire screenshot pixels: ", SDL_GetError());
129 PNG::save(width, rowPointers, filename);
134 SDL_FillRect(surface.
get(),
nullptr, 0);
void reset(SDL_Surface *surface_=nullptr)
Represents the output window/screen of openMSX.
Thrown when a subsystem initialisation fails.
const T * data() const
Returns pointer to the start of the memory buffer.
const PixelFormat & getPixelFormat() const
gl::ivec2 getLogicalSize() const
void calculateViewPort(gl::ivec2 logSize, gl::ivec2 physSize)
Contains the main loop of openMSX.
A frame buffer where pixels can be written to.
void setSDLSurface(SDL_Surface *surface_)
SDL_Renderer * getSDLRenderer() const
void setSDLPixelFormat(const SDL_PixelFormat &format)
void setSDLRenderer(SDL_Renderer *r)
Common functionality for the plain SDL and SDLGL VisibleSurface classes.
void createSurface(int width, int height, unsigned flags)
void finish() override
When a complete frame is finished, call this method.
void saveScreenshot(const std::string &filename) override
Save the content of this OutputSurface to a PNG file.
SDLVisibleSurface(int width, int height, Display &display, RTScheduler &rtScheduler, EventDistributor &eventDistributor, InputEventGenerator &inputEventGenerator, CliComm &cliComm, VideoSystem &videoSystem)
std::unique_ptr< Layer > createConsoleLayer(Reactor &reactor, CommandConsole &console) override
static void saveScreenshotSDL(const SDLOutputSurface &output, const std::string &filename)
std::unique_ptr< Layer > createSnowLayer() override
void flushFrameBuffer() override
Copy frame buffer to display buffer.
std::unique_ptr< OutputSurface > createOffScreenSurface() override
Create an off-screen OutputSurface which has similar properties as this VisibleSurface.
std::unique_ptr< Layer > createOSDGUILayer(OSDGUI &gui) override
void fullScreenUpdated(bool fullScreen) override
void clearScreen() override
Clear frame buffer (paint it black).
Display & getDisplay() const
This file implemented 3 utility functions:
size_t size(std::string_view utf8)
#define VLA(TYPE, NAME, LENGTH)
constexpr auto xrange(T e)