1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

add missing frame counter

This commit is contained in:
FunkyFr3sh 2024-05-18 06:20:13 +02:00
parent 4d07b3d3e1
commit ec48aac4f9
2 changed files with 15 additions and 4 deletions

View File

@ -27,7 +27,8 @@ typedef struct OGLRENDERER
GLint main_vertex_coord_attr_loc;
GLuint main_vbos[3];
GLuint main_vao;
GLint frame_count_uni_loc;
GLint shader1_frame_count_uni_loc;
GLint shader2_frame_count_uni_loc;
GLuint frame_buffer_id[FBO_COUNT];
GLuint frame_buffer_tex_id[FBO_COUNT];
GLint shader1_tex_coord_attr_loc;

View File

@ -507,7 +507,7 @@ static void ogl_init_shader1_program()
GLint vertex_coord_attr_loc = glGetAttribLocation(g_ogl.shader1_program, "VertexCoord");
g_ogl.shader1_tex_coord_attr_loc = glGetAttribLocation(g_ogl.shader1_program, "TexCoord");
g_ogl.frame_count_uni_loc = glGetUniformLocation(g_ogl.shader1_program, "FrameCount");
g_ogl.shader1_frame_count_uni_loc = glGetUniformLocation(g_ogl.shader1_program, "FrameCount");
glGenBuffers(3, g_ogl.shader1_vbos);
@ -717,6 +717,7 @@ static void ogl_init_shader2_program()
GLint vertex_coord_attr_loc = glGetAttribLocation(g_ogl.shader2_program, "VertexCoord");
g_ogl.shader2_tex_coord_attr_loc = glGetAttribLocation(g_ogl.shader2_program, "TexCoord");
g_ogl.shader2_frame_count_uni_loc = glGetUniformLocation(g_ogl.shader2_program, "FrameCount");
glGenBuffers(3, g_ogl.shader2_vbos);
@ -1059,6 +1060,9 @@ static void ogl_render()
if (g_ogl.shader1_program && g_ogl.shader2_program && g_ogl.main_program)
{
static int frames = 0;
frames++;
/* draw surface into framebuffer */
glUseProgram(g_ogl.main_program);
@ -1088,6 +1092,9 @@ static void ogl_render()
glBindFramebuffer(GL_FRAMEBUFFER, g_ogl.frame_buffer_id[1]);
if (g_ogl.shader1_frame_count_uni_loc != -1)
glUniform1i(g_ogl.shader1_frame_count_uni_loc, frames);
glBindVertexArray(g_ogl.shader1_vao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
glBindVertexArray(0);
@ -1116,6 +1123,9 @@ static void ogl_render()
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, g_ogl.frame_buffer_tex_id[0]);
if (g_ogl.shader2_frame_count_uni_loc != -1)
glUniform1i(g_ogl.shader2_frame_count_uni_loc, frames);
glBindVertexArray(g_ogl.shader2_vao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
glBindVertexArray(0);
@ -1161,8 +1171,8 @@ static void ogl_render()
glBindTexture(GL_TEXTURE_2D, g_ogl.frame_buffer_tex_id[0]);
static int frames = 1;
if (g_ogl.frame_count_uni_loc != -1)
glUniform1i(g_ogl.frame_count_uni_loc, frames++);
if (g_ogl.shader1_frame_count_uni_loc != -1)
glUniform1i(g_ogl.shader1_frame_count_uni_loc, frames++);
glBindVertexArray(g_ogl.shader1_vao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);