Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef __cplusplus
- #include <cstdlib>
- #else
- #include <stdlib.h>
- #endif
- #include <iostream>
- #include <fstream>
- #include <SDL/SDL.h>
- using namespace std;
- string fileName;
- string entireFileName;
- int option;
- void menu() {
- cout << "Podaj nazwe pliku (bez rozszerzenia): ";
- cin >> fileName;
- entireFileName = fileName + ".bmp";
- fstream fileExists;
- fileExists.open(entireFileName.c_str());
- if(!fileExists.is_open()) {
- cout << "File does not exist!" << endl;
- menu();
- }
- cout << endl;
- }
- int main ( int argc, char** argv )
- {
- menu();
- // load an image
- SDL_Surface* bmp = SDL_LoadBMP(entireFileName.c_str());
- // program main loop
- bool done = false;
- while (!done)
- {
- // message processing loop
- SDL_Event event;
- while (SDL_PollEvent(&event))
- {
- // check for messages
- switch (event.type)
- {
- // exit if the window is closed
- case SDL_QUIT:
- done = true;
- break;
- // check for keypresses
- case SDL_KEYDOWN:
- {
- // exit if ESCAPE is pressed
- if (event.key.keysym.sym == SDLK_ESCAPE)
- done = true;
- break;
- }
- } // end switch
- } // end of message processing
- } // end main loop
- // free loaded bitmap
- SDL_FreeSurface(bmp);
- // all is well ;)
- printf("Exited cleanly\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement