|
|
|
@ -223,45 +223,32 @@ int main(int argc, char **argv)
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo_tex);
|
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
|
|
|
|
|
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
|
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
|
|
|
|
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
|
|
|
|
fbo_tex, 0);
|
|
|
|
|
} else {
|
|
|
|
|
window_show(wnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************** drawing loop ********************/
|
|
|
|
|
while (window_handle_events()) {
|
|
|
|
|
while (to_stdout || window_handle_events()) {
|
|
|
|
|
/* render image to FBO */
|
|
|
|
|
if (to_stdout)
|
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
|
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &frame_start);
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
|
|
|
|
|
|
if (!to_stdout)
|
|
|
|
|
if (to_stdout) {
|
|
|
|
|
glFlush();
|
|
|
|
|
} else {
|
|
|
|
|
window_swap_buffers(wnd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &frame_end);
|
|
|
|
|
|
|
|
|
|
iFrame += 1;
|
|
|
|
|
iTimeDelta = diff_timespec(&frame_end, &frame_start);
|
|
|
|
|
iTime = diff_timespec(&frame_end, &start);
|
|
|
|
|
|
|
|
|
|
glUniform1f(u_iTimeDelta, iTimeDelta);
|
|
|
|
|
glUniform1f(u_iTime, iTime);
|
|
|
|
|
glUniform1ui(u_iFrame, iFrame);
|
|
|
|
|
|
|
|
|
|
/* get image from FBO, dump to stdout */
|
|
|
|
|
if (to_stdout) {
|
|
|
|
|
/* get image from FBO */
|
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, fbo_tex);
|
|
|
|
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA,
|
|
|
|
|
GL_UNSIGNED_BYTE, fb32);
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
|
|
|
|
|
/* convert to 24 bps and dump to stdout */
|
|
|
|
|
convert_for_ffmpeg(fb32, fb24, width, height);
|
|
|
|
|
|
|
|
|
|
if (write_retry(STDOUT_FILENO, fb24,
|
|
|
|
@ -269,6 +256,17 @@ int main(int argc, char **argv)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* update timers */
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_RAW, &frame_end);
|
|
|
|
|
|
|
|
|
|
iFrame += 1;
|
|
|
|
|
iTimeDelta = diff_timespec(&frame_end, &frame_start);
|
|
|
|
|
iTime = diff_timespec(&frame_end, &start);
|
|
|
|
|
|
|
|
|
|
glUniform1f(u_iTimeDelta, iTimeDelta);
|
|
|
|
|
glUniform1f(u_iTime, iTime);
|
|
|
|
|
glUniform1ui(u_iFrame, iFrame);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************** cleanup ********************/
|
|
|
|
|