Skip to content

Commit

Permalink
Fixer cubemap face initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocelot5836 committed Nov 17, 2024
1 parent 5aee6f4 commit 0c07cfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ public DynamicCubemapTexture() {
this.height = new int[6];
}

private void init(int face, int width, int height) {
this.width[face] = width;
this.height[face] = height;
RenderSystem.assertOnRenderThreadOrInit();
glTexImage2D(face, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0L);
}

/**
* Initializes each face to the same size white texture.
*
* @param width The width of each face
* @param height The height of each face
*/
public void init(int width, int height) {
for (int i = 0; i < 6; i++) {
this.width[i] = width;
this.height[i] = height;
}

this.bind();
this.setFilter(false, false);
GlStateManager._texParameter(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0);
Expand All @@ -51,7 +53,7 @@ public void init(int width, int height) {

RenderSystem.assertOnRenderThreadOrInit();
for (int i = 0; i < 6; i++) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0L);
this.init(i, width, height);
}
}

Expand Down Expand Up @@ -95,8 +97,10 @@ public void upload(Direction face, NativeImage image) {
* @param image The image to upload
*/
public void upload(int face, NativeImage image) {
if (this.width[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != image.getWidth() || this.height[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != image.getHeight()) {
if (this.id == -1) {
this.init(image.getWidth(), image.getHeight());
} else if (this.width[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != image.getWidth() || this.height[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != image.getHeight()) {
this.init(face, image.getWidth(), image.getHeight());
} else {
this.bind();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import foundry.veil.Veil;
import foundry.veil.platform.VeilPlatform;
import net.minecraft.Util;
import net.minecraft.client.main.Main;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
Expand Down Expand Up @@ -32,7 +33,7 @@ private static void preMain(String[] pArgs, CallbackInfo ci) {
String path = System.getProperty("java.library.path");
String name = System.mapLibraryName("renderdoc");
boolean detected = false;
for (String folder : path.split(";")) {
for (String folder : path.split(Util.getPlatform() == Util.OS.WINDOWS ? ";" : ":")) {
if (Files.exists(Path.of(folder + "/" + name))) {
detected = true;
break;
Expand Down

0 comments on commit 0c07cfb

Please sign in to comment.