From 75ef3f0f79a0c093ab24dccd893da33d4a41b5e3 Mon Sep 17 00:00:00 2001 From: RK_01 <50594595+RaphiMC@users.noreply.github.com> Date: Sat, 9 Nov 2024 22:38:25 +0100 Subject: [PATCH 1/2] Set all needed glPixelStore states Fixes a crash when trying to upload the texture if the application changed one of the 3 added states before ImGui was initialized --- imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java b/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java index 7435bffd..66e93831 100644 --- a/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java +++ b/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java @@ -545,6 +545,9 @@ public boolean createFontsTexture() { glBindTexture(GL_TEXTURE_2D, data.fontTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // Not on WebGL/ES + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); // Not on WebGL/ES + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); // Not on WebGL/ES glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Not on WebGL/ES glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width.get(), height.get(), 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); From 8503c9ffd526d2193d1dabed70bc22b8ecf8bf2e Mon Sep 17 00:00:00 2001 From: RK_01 <50594595+RaphiMC@users.noreply.github.com> Date: Sun, 10 Nov 2024 15:04:12 +0100 Subject: [PATCH 2/2] Fix imports --- imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java b/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java index 66e93831..1281d030 100644 --- a/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java +++ b/imgui-lwjgl3/src/main/java/imgui/gl3/ImGuiImplGl3.java @@ -65,6 +65,9 @@ import static org.lwjgl.opengl.GL32.GL_TEXTURE_MIN_FILTER; import static org.lwjgl.opengl.GL32.GL_TRIANGLES; import static org.lwjgl.opengl.GL32.GL_TRUE; +import static org.lwjgl.opengl.GL32.GL_UNPACK_ALIGNMENT; +import static org.lwjgl.opengl.GL32.GL_UNPACK_SKIP_PIXELS; +import static org.lwjgl.opengl.GL32.GL_UNPACK_SKIP_ROWS; import static org.lwjgl.opengl.GL32.GL_UNPACK_ROW_LENGTH; import static org.lwjgl.opengl.GL32.GL_UNSIGNED_BYTE; import static org.lwjgl.opengl.GL32.GL_UNSIGNED_INT;