Browse Source

get minimal example running

testing
cinnaboot 6 years ago
parent
commit
e27403f3e5
  1. BIN
      data/palette.png
  2. 23
      examples/main.cpp

BIN
data/palette.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

23
examples/main.cpp

@ -1,4 +1,6 @@
#include <SDL2/SDL.h>
#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;
}

Loading…
Cancel
Save