fixed frame timer

This commit is contained in:
Jarcode
2017-11-26 20:54:44 -08:00
parent 44ce4cf3eb
commit 004d769d00
3 changed files with 12 additions and 5 deletions

View File

@@ -889,12 +889,16 @@ struct renderer* rd_new(int x, int y, int w, int h, const char* data) {
return r;
}
void rd_time(struct renderer* r) {
struct gl_data* gl = r->gl;
glfwSetTime(0.0D); /* reset time for measuring this frame */
}
void rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modified) {
struct gl_data* gl = r->gl;
size_t t, a;
glfwSetTime(0.0D); /* reset time for measuring this frame */
r->alive = !glfwWindowShouldClose(gl->w);
if (!r->alive)
return;
@@ -954,9 +958,8 @@ void rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
glUseProgram(current->shader);
/* Bind framebuffer if this is not the final pass */
if (current->valid) {
if (current->valid)
glBindFramebuffer(GL_FRAMEBUFFER, current->fbo);
}
glClear(GL_COLOR_BUFFER_BIT);
@@ -1019,7 +1022,8 @@ void rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
drawoverlay(&gl->overlay); /* Fullscreen quad (actually just two triangles) */
/* Reset some state */
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (current->valid)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glUseProgram(0);
prev = current;