mirror of
https://github.com/thepigeongenerator/mcaselector-lite
synced 2026-02-08 07:33:35 +01:00
fix: window resize updates happen each update.
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "../error.h"
|
#include "../error.h"
|
||||||
#include "../util/types.h"
|
#include "../util/types.h"
|
||||||
#include "../util/vec/int2.h"
|
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
|
||||||
#define VERTC 3
|
#define VERTC 3
|
||||||
@@ -17,6 +16,7 @@ static GLuint pipe;
|
|||||||
static GLuint vbo; // vertex buffer object
|
static GLuint vbo; // vertex buffer object
|
||||||
static GLuint vao; // vertex array object
|
static GLuint vao; // vertex array object
|
||||||
static GLuint screen_loc; // location to where OpenGL sends to the shaders of the screen dimensions
|
static GLuint screen_loc; // location to where OpenGL sends to the shaders of the screen dimensions
|
||||||
|
static int win_w, win_h;
|
||||||
|
|
||||||
static void screen_resize(int w, int h) {
|
static void screen_resize(int w, int h) {
|
||||||
i32 verts[VERTC][4] = {
|
i32 verts[VERTC][4] = {
|
||||||
@@ -28,6 +28,8 @@ static void screen_resize(int w, int h) {
|
|||||||
glUniform2i(screen_loc, w, h); // send the screen dimensions to the shader pipeline
|
glUniform2i(screen_loc, w, h); // send the screen dimensions to the shader pipeline
|
||||||
glViewport(0, 0, w, h); // update the viewport
|
glViewport(0, 0, w, h); // update the viewport
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_DYNAMIC_DRAW); // bind the data to it
|
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_DYNAMIC_DRAW); // bind the data to it
|
||||||
|
win_w = w;
|
||||||
|
win_h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
int render_init(void) {
|
int render_init(void) {
|
||||||
@@ -62,7 +64,7 @@ int render_init(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_update(GLFWwindow* win) {
|
void render_update(GLFWwindow *win) {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
@@ -70,11 +72,8 @@ void render_update(GLFWwindow* win) {
|
|||||||
glfwGetWindowSize(win, &w, &h);
|
glfwGetWindowSize(win, &w, &h);
|
||||||
glUseProgram(pipe);
|
glUseProgram(pipe);
|
||||||
|
|
||||||
int2 windim = {0};
|
if (w != win_w || h != win_h)
|
||||||
if (w != windim.x || h != windim.y) { // false negative when h and w swap integers, but this is quite a rare occurrence and it's impact is minimal
|
screen_resize(w, h);
|
||||||
windim = (int2){w, h};
|
|
||||||
screen_resize(windim.x, windim.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
glClearColor(0.1F, 0.1F, 0.1F, 1.0F);
|
glClearColor(0.1F, 0.1F, 0.1F, 1.0F);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||||
|
|||||||
Reference in New Issue
Block a user