diff --git a/data/palette.png b/data/palette.png new file mode 100644 index 0000000..3b38adf Binary files /dev/null and b/data/palette.png differ diff --git a/examples/main.cpp b/examples/main.cpp index 9703f57..e2af800 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -1,4 +1,6 @@ +#include + #include "renderer.h" @@ -6,6 +8,27 @@ int main() { render_state* rs = renInit(); + const uint TARGET_FPS = 60; + const uint FRAME_DELAY = 1000 / TARGET_FPS; + uint frameStart, frameTime; + bool running = true; + SDL_Event e; + + while (running) { + frameStart = SDL_GetTicks(); + + while (SDL_PollEvent(&e)) { + if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE) + running = false; + } + + renRenderFrame(rs, nullptr, 0); + SDL_GL_SwapWindow(rs->handles.window); + frameTime = SDL_GetTicks() - frameStart; + + if (FRAME_DELAY > frameTime) + SDL_Delay(FRAME_DELAY - frameTime); + } return 0; }