123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #include <iostream>
- #include <SDL/SDL.h>
- int main()
- {
-
-
- if ( SDL_Init( SDL_INIT_VIDEO ) < 0)
- {
- std::cout << "Can't initialize SDL: " << SDL_GetError() << std::endl;
- return 1;
- }
-
- atexit(SDL_Quit);
-
- SDL_WM_SetCaption("Application SDL", 0);
-
-
- SDL_Surface* screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
- if ( !screen )
- {
- std::cout << "Unable to set 640x480 video: " << SDL_GetError() << std::endl;
- return 1;
- }
-
-
-
- bool done(false);
- while (!done)
- {
-
- SDL_Event event;
- while (SDL_PollEvent(&event))
- {
- switch (event.type)
- {
- case SDL_QUIT:
- done = true;
- break;
- case SDL_KEYDOWN:
- if (event.key.keysym.sym == SDLK_ESCAPE)
- done = true;
- break;
- }
- }
-
-
-
- SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 255, 255));
-
- SDL_Flip(screen);
- }
-
- SDL_FreeSurface(screen);
- std::cout << "No error caught." << std::endl;
- return 0;
- }
|