Added SDL 1c0f6952e65e.

This commit is contained in:
rude
2015-03-15 15:47:43 +01:00
parent 4d04ac181e
commit 6a2aff6450
1109 changed files with 160136 additions and 33995 deletions
+33 -15
View File
@@ -15,6 +15,10 @@
#include <stdio.h>
#include <time.h>
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
#endif
#include "SDL_test_common.h"
@@ -29,6 +33,9 @@ typedef struct {
int scale_direction;
} DrawState;
DrawState *drawstates;
int done;
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static void
quit(int rc)
@@ -130,12 +137,27 @@ Draw(DrawState *s)
/* SDL_Delay(10); */
}
void loop()
{
int i;
SDL_Event event;
/* Check for events */
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
}
for (i = 0; i < state->num_windows; ++i) {
if (state->windows[i] == NULL)
continue;
Draw(&drawstates[i]);
}
}
int
main(int argc, char *argv[])
{
DrawState *drawstates;
int i, done;
SDL_Event event;
int i;
int frames;
Uint32 then, now;
@@ -181,19 +203,15 @@ main(int argc, char *argv[])
frames = 0;
then = SDL_GetTicks();
done = 0;
while (!done) {
/* Check for events */
++frames;
while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done);
}
for (i = 0; i < state->num_windows; ++i) {
if (state->windows[i] == NULL)
continue;
Draw(&drawstates[i]);
}
}
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1);
#else
while (!done) {
++frames;
loop();
}
#endif
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {