diff --git a/sdl_opengl_bare.d b/sdl_opengl_bare.d index 566b6db..a481ded 100644 --- a/sdl_opengl_bare.d +++ b/sdl_opengl_bare.d @@ -5,7 +5,6 @@ import derelict.opengl.glu; enum int WIDTH = 800; enum int HEIGHT = 600; -static bool drawing = false; void init() { @@ -22,7 +21,6 @@ void init() void display() { - drawing = true; glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(SDL_GetTicks() * 90.0 / 1000, 0, 0, 1); @@ -37,21 +35,9 @@ void display() glVertex3f(5.0, -5.0, 0.0); glEnd(); glPopMatrix(); - drawing = false; SDL_GL_SwapBuffers(); } -extern (C) Uint32 timer_callback(Uint32 interval, void *param) -{ - if (!drawing) - { - SDL_Event event; - event.type = SDL_USEREVENT; - SDL_PushEvent(&event); - } - return interval; -} - int main(char[][] args) { DerelictSDL.load(); @@ -76,20 +62,19 @@ int main(char[][] args) init(); SDL_Event event; - SDL_AddTimer(1000 / 60, &timer_callback, null); - while (SDL_WaitEvent(&event)) + for (;;) { - if (event.type == SDL_QUIT) - break; - else if (event.type == SDL_KEYDOWN) + if (SDL_PollEvent(&event)) { - if (event.key.keysym.sym == SDLK_ESCAPE) + if (event.type == SDL_QUIT) break; + else if (event.type == SDL_KEYDOWN) + { + if (event.key.keysym.sym == SDLK_ESCAPE) + break; + } } - else if (event.type == SDL_USEREVENT) - { - display(); - } + display(); } SDL_Quit();