1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

screen surface is now private member of ScreenHandler instead of global

This commit is contained in:
Ivan Savenko
2025-02-10 17:23:20 +00:00
parent 31e627f128
commit eb7587c000
16 changed files with 85 additions and 40 deletions

View File

@@ -11,11 +11,14 @@
#include "StdInc.h"
#include "ScreenHandler.h"
#include "../CGameInfo.h"
#include "../CMT.h"
#include "../eventsSDL/NotificationHandler.h"
#include "../gui/CGuiHandler.h"
#include "../gui/CursorHandler.h"
#include "../gui/WindowHandler.h"
#include "../render/Canvas.h"
#include "../renderSDL/SDL_Extensions.h"
#include "CMT.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/constants/StringConstants.h"
@@ -34,7 +37,6 @@
static SDL_Window * mainWindow = nullptr;
SDL_Renderer * mainRenderer = nullptr;
SDL_Texture * screenTexture = nullptr;
SDL_Surface * screen = nullptr; //main screen surface
static const std::string NAME = GameConstants::VCMI_VERSION; //application name
static constexpr Point heroes3Resolution = Point(800, 600);
@@ -621,6 +623,24 @@ void ScreenHandler::clearScreen()
SDL_RenderPresent(mainRenderer);
}
Canvas ScreenHandler::getScreenCanvas() const
{
return Canvas::createFromSurface(screen, CanvasScalingPolicy::AUTO);
}
void ScreenHandler::updateScreenTexture()
{
SDL_UpdateTexture(screenTexture, nullptr, screen->pixels, screen->pitch);
}
void ScreenHandler::presetScreenTexture()
{
SDL_RenderClear(mainRenderer);
SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr);
CCS->curh->render();
SDL_RenderPresent(mainRenderer);
}
std::vector<Point> ScreenHandler::getSupportedResolutions() const
{
int displayID = getPreferredDisplayIndex();