我有一个小脚本,旨在获取用户的屏幕分辨率并将其分配给一个变量,但我收到一个Access Violation
错误,不知道如何修复它(我对这种语言很陌生)所以希望有人能告诉我我应该怎么写。
这是我的设置:
//get player's screen info
const SDL_VideoInfo* myScreen = SDL_GetVideoInfo();
//SDL screen
SDL_Surface *screen;
int reso_x = myScreen->current_w; //resolution width (ERROR here)
int reso_y = myScreen->current_h; //resolution height
Uint8 video_bpp = 32;
Uint32 videoflags = SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT;// | SDL_FULLSCREEN;
/* Initialize the SDL library */
if ( SDL_Init(videoflags) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n",
SDL_GetError());
exit(1);
}
//setup Screen
screen = SDL_SetVideoMode(reso_x, reso_y, video_bpp, videoflags|SDL_FULLSCREEN);
有人知道我错误的原因吗?