瀏覽代碼

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

AlexVinS 11 年之前
父節點
當前提交
ecc7b8e05a
共有 5 個文件被更改,包括 9 次插入11 次删除
  1. 2 0
      client/CMT.cpp
  2. 0 3
      client/CPlayerInterface.cpp
  3. 0 8
      client/CPreGame.cpp
  4. 4 0
      client/gui/CCursorHandler.cpp
  5. 3 0
      client/gui/CGuiHandler.cpp

+ 2 - 0
client/CMT.cpp

@@ -930,6 +930,8 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen)
 		logGlobal->errorStream() << SDL_GetError();
 		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,
                                             SDL_PIXELFORMAT_ARGB8888,

+ 0 - 3
client/CPlayerInterface.cpp

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

+ 0 - 8
client/CPreGame.cpp

@@ -532,18 +532,10 @@ void CGPreGame::update()
 	// check for null othervice crash on finishing a campaign
 	// /FIXME: find out why GH.listInt is empty to begin with
 	if (GH.topInt() != nullptr)
-#ifdef VCMI_SDL1
 		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())
 		GH.drawFPSCounter();
-
-	// draw the mouse cursor and update the screen
-	CCS->curh->render();
 }
 
 void CGPreGame::openCampaignScreen(std::string name)

+ 4 - 0
client/gui/CCursorHandler.cpp

@@ -25,6 +25,10 @@ void CCursorHandler::initCursor()
 	currentCursor = nullptr;
 
 	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);
 
 	changeGraphic(ECursor::ADVENTURE, 0);

+ 3 - 0
client/gui/CGuiHandler.cpp

@@ -414,6 +414,9 @@ void CGuiHandler::renderFrame()
 		if(curInt)
 			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
 		if(0 != SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr))
 			logGlobal->errorStream() << __FUNCTION__ << " SDL_RenderCopy " << SDL_GetError();