Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL/SDL.h>
- int main()
- {
- SDL_Event e;
- SDL_Surface *output;
- output = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
- int fps_cap = 1;
- int loop = 1;
- int last_loop, time;
- while (loop)
- {
- last_loop = SDL_GetTicks();
- while (SDL_PollEvent(&e))
- {
- switch (e.type)
- {
- case SDL_QUIT:
- loop = 0;
- break;
- default: break;
- }
- }
- SDL_FillRect(output, NULL, SDL_MapRGB(output->format, rand() % 256, rand() % 256, rand() % 256));
- SDL_Flip(output);
- time = SDL_GetTicks() - last_loop;
- if (time < 1000 / fps_cap)
- SDL_Delay(1000 / fps_cap - time);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement