Browse Source

use renDoRenderLoop() in hello_world example

testing
cinnaboot 6 years ago
parent
commit
7a2bd633e5
  1. 28
      examples/hello_world/main.cpp

28
examples/hello_world/main.cpp

@ -1,40 +1,16 @@
#include <SDL2/SDL.h>
#include "renderer.h"
int
main()
{
render_state* rs = renInit();
render_state* rs = renInit("Hello World");
if (rs == nullptr)
return 1;
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)
|| e.type == SDL_QUIT) {
running = false;
}
}
renRenderFrame(rs);
SDL_GL_SwapWindow(rs->handles.window);
frameTime = SDL_GetTicks() - frameStart;
if (FRAME_DELAY > frameTime)
SDL_Delay(FRAME_DELAY - frameTime);
}
renDoRenderLoop(rs);
return 0;
}

Loading…
Cancel
Save