Update viewport according to the window size

Also dynamically change the resolution for the shaders
This commit is contained in:
rexim 2021-07-06 20:39:52 +07:00
parent 0b7b6fdf7b
commit 757e64e16f
2 changed files with 10 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
te
ded
SDL2
*.exe
*.obj

View File

@ -75,7 +75,7 @@ void usage(FILE *stream)
// TODO: Delete line
// TODO: Split the line on Enter
// #define OPENGL_RENDERER
#define OPENGL_RENDERER
#ifdef OPENGL_RENDERER
void MessageCallback(GLenum source,
@ -246,8 +246,6 @@ int main(int argc, char **argv)
time_uniform = glGetUniformLocation(program, "time");
resolution_uniform = glGetUniformLocation(program, "resolution");
glUniform2f(resolution_uniform, SCREEN_WIDTH, SCREEN_HEIGHT);
}
// Init Font Texture
@ -327,6 +325,13 @@ int main(int argc, char **argv)
}
}
{
int w, h;
SDL_GetWindowSize(window, &w, &h);
glViewport(0, 0, w, h);
glUniform2f(resolution_uniform, (float) w, (float) h);
}
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);