SDL官方网站 API参考 测试用例: #include "SDL.h" #include <iostream> #include <stdio.h> using namespace std; int count = 0; void escToEscape() { SDL_Surface* hello = NULL; SDL_Surface* screen = NULL; SDL_Init(SDL_INIT_VIDEO); atexit(SDL_Quit); // screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); screen = SDL_SetVideoMode(1280, 800, 32, SDL_FULLSCREEN); hello = SDL_LoadBMP( "Background.bmp" ); SDL_BlitSurface( hello, NULL, screen, NULL ); SDL_Flip( screen ); // 此处是控制台侦听键盘消息 bool gameOver = false; while( gameOver == false ){ // 此为死循环 SDL_Event gameEvent; if ( SDL_PollEvent(&gameEvent) != 0 ){ switch(gameEvent.type) { case SDL_QUIT: case SDL_KEYUP: gameOver = true; break; case SDL_MOUSEMOTION: cout << "SDL_MOUSEMOTION " << count << endl; count++; break; case SDL_MOUSEBUTTONUP: cout << "SDL_MOUSEBUTTONUP " << endl; break; default: break; } } // SDL_Flip( screen ); } } int main( int argc, char* args[] ) { escToEscape(); return 0; }