首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

SDL图片加载有关问题

2012-09-17 
SDL图片加载问题/*我写的这个为什么没有图片加载的效果,我是新手,请大神指点*/#include iostream#includ

SDL图片加载问题

/*我写的这个为什么没有图片加载的效果,我是新手,请大神指点*/
#include <iostream> 
#include "SDL/SDL.h" 

 int main(int argc,char* argv[]) 

//-------数据定义--------
const int SCREEN_WIDTH = 640;// 窗口宽
const int SCREEN_HEIGHT = 480;//高
const int SCREEN_BPP = 32;//像素位数
const Uint32 SCREEN_FLAGS = SDL_SWSURFACE;//标志
SDL_Surface* pScreen = 0;

SDL_Init(SDL_INIT_EVERYTHING);//装载SDL

  pScreen = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,SCREEN_FLAGS); //创建SDL窗口
try
{
if(pScreen == 0)
throw SDL_GetError();
}
catch(const char *s)
{
std::cerr<<"SDL_SetVideoMode()failed!\n"<<s<<std::endl;
}

//装载bmp图片
SDL_Surface *pShowBMP = 0;
pShowBMP = SDL_LoadBMP("hello.bmp");//装载bmp图片,并使它为界面
try
{
if(pShowBMP == 0)
throw SDL_GetError();
}
catch(const char *s)
{
std::cout<<"SDL_LoadBMP()failed:"<<s<<std::endl;
SDL_Quit();
}
system("PAUSE");
SDL_Quit();
  return 0; 

 

[解决办法]
怎么没看到 SDL_Flip(pScreen);

热点排行