Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**GreatShow: silly program that repeatedly displays a bunch
- * of images to the screen.
- * WARNING: DON'T RUN THIS IF YOU HAVE PHOTOSENSITIVE EPILEPSY
- *
- * I'm not a doctor and I have no idea if this can trigger a
- * seizure. In Elementary it was supposed to have been used
- * to kill a guy with epilepsy so uh just be careful.
- *
- * Copyright Patrick Simmons, license is GPL 3.0
- */
- #include <sys/types.h>
- #include <dirent.h>
- #include <string>
- #include <vector>
- #include <SDL/SDL.h>
- #include <SDL/SDL_image.h>
- int main(int argc, char** argv)
- {
- //Boilerplate init
- SDL_Init(SDL_INIT_EVERYTHING);
- //Get current display mode
- const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo();
- //Set fullscreen with current display mode
- SDL_Surface* screen = SDL_SetVideoMode(videoInfo->current_w,videoInfo->current_h,0,SDL_FULLSCREEN);
- //Read in images to display
- std::vector<SDL_Surface*> images;
- DIR* dirp = opendir(".");
- dirent* cur = readdir(dirp);
- while(cur)
- {
- std::string x = cur->d_name;
- if(x.length()<4)
- {
- cur = readdir(dirp);
- continue;
- }
- x = x.substr(x.length()-4,4);
- if(x==".png" || x==".jpg" || x==".gif")
- images.push_back(IMG_Load(cur->d_name));
- cur = readdir(dirp);
- }
- //Quickly flash images on screen
- //No way to quit program btw.
- while(true)
- {
- for(int i=0; i<images.size(); i++)
- {
- SDL_BlitSurface(images[i],NULL,screen,NULL);
- SDL_Flip(screen);
- }
- //Quit when user presses any key
- SDL_Event event;
- if(SDL_PollEvent(&event))
- if(event.type==SDL_KEYDOWN)
- break;
- }
- //Boilerplate quit
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement