/* * Josh Holtrop * 2008-12-11 * barebones SDL program */ #include #include #include using namespace std; int main(int argc, char * argv[]) { int width = 800; int height = 600; SDL_Surface * screen; SDL_Event event; if (SDL_Init(SDL_INIT_VIDEO)) { cerr << "Failed to initialize SDL!" << endl; return 1; } atexit(SDL_Quit); if (!(screen = SDL_SetVideoMode(width, height, 32, 0))) { cerr << "Failed to set video mode!" << endl; return 2; } Uint32 * pixels = (Uint32 *) screen->pixels; Uint32 c; for (c = 0; c < width * height; c++) *pixels++ = c; SDL_UpdateRect(screen, 0, 0, 0, 0); bool going = true; while (going && SDL_WaitEvent(&event) != 0) { switch (event.type) { case SDL_QUIT: going = false; break; case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_q) going = false; break; } } }