【发布时间】:2012-09-02 01:57:50
【问题描述】:
我的图片似乎可以正常加载,但是 除非我将控制台窗口拖到 SDL 显示器上,否则实际上不会显示。 只有控制台窗口重叠的 SDL 显示部分显示,所以我可以 本质上是在使用控制台窗口时“绘制”图像,然后它会保留下来。
#include "SDL.h"
class Game
private:
SDL_Surface* displayWindow_;
//Rest of class
};
关键函数是:(注意GetWallpaper()返回一个有效指针)
void Game::Render(){
GameState* currentGameState = gameStateManager_->GetCurrentState();
if(currentGameState)
{
surface::Draw(currentGameState->GetWallpaper(), displayWindow_, 0, 0);
SDL_Flip(currentGameState->GetWallpaper());
}
return;
}
终于
bool surface::Draw(SDL_Surface* sourceSurface, SDL_Surface* targetSurface,
int x, int y){
if(sourceSurface == NULL || targetSurface == NULL)
return false;
SDL_Rect targetRectangle;
targetRectangle.x = x;
targetRectangle.y = y;
SDL_BlitSurface(sourceSurface, NULL, targetSurface, &targetRectangle);
return true;
}
有人能解释一下吗?
【问题讨论】:
-
我认为你应该翻转
displayWindow_,而不是你从GetWallpaper获得的表面。 -
非常感谢你!你已经破解了它!这就是我使用我不正确理解的功能所得到的!不幸的是我不能代表 cmets(我不认为)
-
如果是这样,我会发布一个正确的答案:)