【发布时间】:2013-06-07 11:14:53
【问题描述】:
我想将图像添加到窗口。这是我的代码:
SDL_Surface* bitmap = SDL_LoadBMP("bat.bmp");
// Part of the bitmap that we want to draw
SDL_Rect source;
source.x = 24;
source.y = 63;
source.w = 65;
source.h = 44;
// Part of the screen we want to draw the sprite to
SDL_Rect destination;
destination.x = 100;
destination.y = 100;
destination.w = 65;
destination.h = 44;
SDL_Event event;
bool gameRunning = true;
while (gameRunning)
{
if (SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
gameRunning = false;
}
}
SDL_BlitSurface(bitmap, &source, screen, &destination);
SDL_Flip(screen);
}
当窗口加载时它会变黑并且图像不会出现。怎么了?
【问题讨论】:
-
你可以查看
SDL_BlitSurface的返回值看看是否成功。 libsdl.org/docs/html/sdlblitsurface.html -
它返回 -1。这是什么意思?
-
@WilhelmMichaelsen 您是否阅读过 PureW 发布的文档?