我目前使用SDL在屏幕上绘制图像,它没有错误地加载图像。但是当我将图像绘制到屏幕上时,没有显示任何内容。这里是我的代码:SDL不绘制图像
图像加载功能:
SDL_Surface *d2Sprite::Load(char *file)
{
SDL_Surface *temp = NULL;
SDL_Surface *opt = NULL;
if((temp = SDL_LoadBMP(file)) == NULL)
{
cout << "Unable to load image '" << file << "'. " << SDL_GetError() << endl;
return NULL;
}
opt = SDL_DisplayFormatAlpha(temp);
SDL_FreeSurface(temp);
return opt;
}
绘图功能:
bool d2Sprite::Draw(SDL_Surface *dest, SDL_Surface *src, int x, int y)
{
if(dest == NULL || src == NULL)
{
cout << "Unable draw sprite! " << SDL_GetError() << endl;
return false;
}
SDL_Rect destR;
destR.x = x;
destR.y = y;
SDL_BlitSurface(src, NULL, dest, &destR);
return true;
}
嗨,我试过你的建议,但它仍然没有画。如果您可以查看一下,我已经上传了整个源代码,https://docs.google.com/open?id=0B54ow8GRluDUVFRydU9wX1lIWjQ。我一直在试图让图像画好几天。谢谢。 – Antony