1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Draw cursor on each frame. Fix TTF rendering under cursor.

This commit is contained in:
AlexVinS
2014-07-03 18:05:07 +04:00
parent e521e6687a
commit ecc7b8e05a
5 changed files with 9 additions and 11 deletions

View File

@@ -930,6 +930,8 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen)
logGlobal->errorStream() << SDL_GetError(); logGlobal->errorStream() << SDL_GetError();
throw std::runtime_error("Unable to create surface"); throw std::runtime_error("Unable to create surface");
} }
//No blending for screen itself. Required for proper cursor rendering.
SDL_SetSurfaceBlendMode(screen, SDL_BLENDMODE_NONE);
screenTexture = SDL_CreateTexture(mainRenderer, screenTexture = SDL_CreateTexture(mainRenderer,
SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888,

View File

@@ -1580,9 +1580,6 @@ void CPlayerInterface::update()
if (settings["general"]["showfps"].Bool()) if (settings["general"]["showfps"].Bool())
GH.drawFPSCounter(); GH.drawFPSCounter();
// draw the mouse cursor and update the screen
CCS->curh->render();
} }
int CPlayerInterface::getLastIndex( std::string namePrefix) int CPlayerInterface::getLastIndex( std::string namePrefix)

View File

@@ -532,18 +532,10 @@ void CGPreGame::update()
// check for null othervice crash on finishing a campaign // check for null othervice crash on finishing a campaign
// /FIXME: find out why GH.listInt is empty to begin with // /FIXME: find out why GH.listInt is empty to begin with
if (GH.topInt() != nullptr) if (GH.topInt() != nullptr)
#ifdef VCMI_SDL1
GH.topInt()->show(screen); GH.topInt()->show(screen);
#else
//FIXME: find better solution for TTF fonts under cursor glitches
GH.topInt()->showAll(screen);
#endif
if (settings["general"]["showfps"].Bool()) if (settings["general"]["showfps"].Bool())
GH.drawFPSCounter(); GH.drawFPSCounter();
// draw the mouse cursor and update the screen
CCS->curh->render();
} }
void CGPreGame::openCampaignScreen(std::string name) void CGPreGame::openCampaignScreen(std::string name)

View File

@@ -25,6 +25,10 @@ void CCursorHandler::initCursor()
currentCursor = nullptr; currentCursor = nullptr;
help = CSDL_Ext::newSurface(40,40); help = CSDL_Ext::newSurface(40,40);
#ifndef VCMI_SDL1
//No blending. Ensure, that we are copying pixels during "screen restore draw"
SDL_SetSurfaceBlendMode(help,SDL_BLENDMODE_NONE);
#endif // VCMI_SDL1
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
changeGraphic(ECursor::ADVENTURE, 0); changeGraphic(ECursor::ADVENTURE, 0);

View File

@@ -414,6 +414,9 @@ void CGuiHandler::renderFrame()
if(curInt) if(curInt)
curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment
// draw the mouse cursor and update the screen
CCS->curh->render();
#ifndef VCMI_SDL1 #ifndef VCMI_SDL1
if(0 != SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr)) if(0 != SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr))
logGlobal->errorStream() << __FUNCTION__ << " SDL_RenderCopy " << SDL_GetError(); logGlobal->errorStream() << __FUNCTION__ << " SDL_RenderCopy " << SDL_GetError();