Fixed flicking on AMD

This commit is contained in:
2025-03-01 22:33:49 -06:00
parent c29d435b06
commit 6c3305be10
4 changed files with 27 additions and 7 deletions

View File

@ -10,17 +10,25 @@
#include "display/scene.h" #include "display/scene.h"
#include "display/shader/shadermanager.h" #include "display/shader/shadermanager.h"
#include "display/quad.h" #include "display/quad.h"
#include "display/window.h"
render_t RENDER; render_t RENDER;
void renderInit() { void renderInit() {
memset(&RENDER, 0, sizeof(render_t)); memset(&RENDER, 0, sizeof(render_t));
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
assertNoGLError();
shaderManagerInit(); shaderManagerInit();
quadInit(); quadInit();
} }
void renderUpdate() { void renderUpdate() {
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
assertNoGLError();
// Update shader stuff // Update shader stuff
shaderManagerUpdate(); shaderManagerUpdate();

View File

@ -12,10 +12,14 @@ shaderbuffer_t TRANSFORMS_BUFFER;
transformsdata_t TRANSFORMS_DATA; transformsdata_t TRANSFORMS_DATA;
void transformsInit() { void transformsInit() {
memset(&TRANSFORMS_DATA, 0, sizeof(transformsdata_t));
shaderBufferInit(&TRANSFORMS_BUFFER, sizeof(transformsdata_t)); shaderBufferInit(&TRANSFORMS_BUFFER, sizeof(transformsdata_t));
glm_mat4_identity(TRANSFORMS_DATA.projection); glm_mat4_identity(TRANSFORMS_DATA.projection);
glm_mat4_identity(TRANSFORMS_DATA.view); glm_mat4_identity(TRANSFORMS_DATA.view);
TRANSFORMS_DATA.resolution[0] = WINDOW_WIDTH;
TRANSFORMS_DATA.resolution[1] = WINDOW_HEIGHT;
} }
void transformsUpdate() { void transformsUpdate() {
@ -25,7 +29,7 @@ void transformsUpdate() {
glm_perspective( glm_perspective(
glm_rad(45.0f), glm_rad(45.0f),
TRANSFORMS_DATA.resolution[0] / TRANSFORMS_DATA.resolution[1], TRANSFORMS_DATA.resolution[0] / TRANSFORMS_DATA.resolution[1],
0.1f, 1.0f,
100.0f, 100.0f,
TRANSFORMS_DATA.projection TRANSFORMS_DATA.projection
); );

View File

@ -8,8 +8,8 @@
#include "window.h" #include "window.h"
GLFWwindow* window; GLFWwindow* window;
int32_t WINDOW_WIDTH; uint32_t WINDOW_WIDTH;
int32_t WINDOW_HEIGHT; uint32_t WINDOW_HEIGHT;
int32_t windowInit() { int32_t windowInit() {
// Initialize GLFW // Initialize GLFW
@ -29,14 +29,21 @@ int32_t windowInit() {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
glfwWindowHint(GLFW_MAXIMIZED, GLFW_FALSE); glfwWindowHint(GLFW_MAXIMIZED, GLFW_FALSE);
glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE);
glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_TRUE);
window = glfwCreateWindow( window = glfwCreateWindow(
WINDOW_WIDTH_DEFAULT, WINDOW_HEIGHT_DEFAULT, WINDOW_WIDTH_DEFAULT, WINDOW_HEIGHT_DEFAULT,
"Dusk", "Dusk",
NULL, NULL NULL, NULL
); );
WINDOW_WIDTH = WINDOW_WIDTH_DEFAULT;
WINDOW_HEIGHT = WINDOW_HEIGHT_DEFAULT;
if(!window) { if(!window) {
glfwTerminate(); glfwTerminate();
return -2; return -2;
@ -44,8 +51,9 @@ int32_t windowInit() {
// Make the window's context current // Make the window's context current
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
glfwSwapInterval(1);
// Get initial framebuffer size // Get initial framebuffer sizeglfwCreateWindow
glfwGetFramebufferSize(window, &WINDOW_WIDTH, &WINDOW_HEIGHT); glfwGetFramebufferSize(window, &WINDOW_WIDTH, &WINDOW_HEIGHT);
// Load OpenGL functions using glad or another loader here if necessary // Load OpenGL functions using glad or another loader here if necessary
@ -61,7 +69,7 @@ bool_t windowShouldClose() {
void windowUpdate() { void windowUpdate() {
glfwSwapBuffers(window); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
glfwGetFramebufferSize(window, &WINDOW_WIDTH, &WINDOW_HEIGHT); glfwGetFramebufferSize(window, &WINDOW_WIDTH, &WINDOW_HEIGHT);
} }

View File

@ -13,8 +13,8 @@
#define WINDOW_HEIGHT_DEFAULT SCREEN_HEIGHT*3 #define WINDOW_HEIGHT_DEFAULT SCREEN_HEIGHT*3
extern GLFWwindow* window; extern GLFWwindow* window;
extern int32_t WINDOW_WIDTH; extern uint32_t WINDOW_WIDTH;
extern int32_t WINDOW_HEIGHT; extern uint32_t WINDOW_HEIGHT;
/** /**
* Initializes the game render window. * Initializes the game render window.