12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #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;
- }
-
- SDL_Surface* grass = SDL_LoadBMP("textures/grass.bmp");
-
- 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_BlitSurface(grass, 0x0, screen, 0x0);
- SDL_Flip(screen);
- SDL_Delay(16);
- }
-
- SDL_FreeSurface(grass);
- SDL_FreeSurface(screen);
- std::cout << "No error caught." << std::endl;
- return 0;
- }
|