Skip to content

Commit

Permalink
Optional fix for texture binding issues
Browse files Browse the repository at this point in the history
- Some GPU's may not give textures proper ID's so the check for if it's
already bound can fail, so a config was added to force binding to
prevent the issue.
  • Loading branch information
EternalBlueFlame committed Sep 17, 2017
1 parent 89d9c6d commit 8837415
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/main/java/train/client/tmt/Tessellator.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import train.common.core.handlers.ConfigHandler;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.Arrays;

import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;

Expand Down Expand Up @@ -134,7 +128,7 @@ public static void bindTexture(ResourceLocation textureURI) {
object = TextureUtil.missingTexture;
}

if (GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D) != object.getGlTextureId()) {
if (GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D) != object.getGlTextureId() || ConfigHandler.FORCE_TEXTURE_BINDING) {
GL11.glBindTexture(GL_TEXTURE_2D, object.getGlTextureId());
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/train/common/core/handlers/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ConfigHandler {
public static boolean REAL_TRAIN_SPEED;
public static boolean RETROGEN_CHUNKS;
public static boolean MAKE_MODPACKS_GREAT_AGAIN;
public static boolean FORCE_TEXTURE_BINDING;



Expand Down Expand Up @@ -65,6 +66,7 @@ public static void init(File configFile) {
MAKE_MODPACKS_GREAT_AGAIN = cf.getBoolean("MAKE_MODPACKS_GREAT_AGAIN", CATEGORY_GENERAL, false,
"This will disable some of Traincrafts easier recipes to balance Modpacks");
WINDMILL_CHECK_RADIUS = cf.getInt("WINDMILL_CHECK_RADIUS", CATEGORY_GENERAL, 1, -1, 10, "This sets the radius for the can-see-the-sky-check area around the windmill. 0=only location of windmill, 1=3x3, 2=5x5 etc. Use -1 to turn of this check completely. DEFAULT: 1");
FORCE_TEXTURE_BINDING = cf.get(CATEGORY_GENERAL, "Force_Texture_Binding", true, "Enable this if trains and rollingstock are using block/item textures").getBoolean(false);

} catch (Exception e) {
Traincraft.tcLog.fatal("Traincraft had a problem loading its configuration\n" + e);
Expand Down

0 comments on commit 8837415

Please sign in to comment.