mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-19 11:59:40 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65d9bf8f2f | ||
|
|
3ee82e7157 | ||
|
|
3b61bb74a2 | ||
|
|
f378b6e7ba |
No files matched your search
@@ -9,6 +9,7 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.joml.Vector3d;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -44,6 +45,9 @@ public class CapturingTessellator extends Tessellator implements ITessellatorIns
|
||||
// Any offset we need to the Tesselator's offset!
|
||||
private final BlockPos offset = new BlockPos();
|
||||
|
||||
private final Vector3d storedTranslation = new Vector3d();
|
||||
private boolean translationStored = false;
|
||||
|
||||
public void setOffset(BlockPos pos) {
|
||||
this.offset.set(pos);
|
||||
}
|
||||
@@ -53,7 +57,7 @@ public class CapturingTessellator extends Tessellator implements ITessellatorIns
|
||||
|
||||
|
||||
static {
|
||||
Field rbs = ReflectionHelper.findField(Tessellator.class, "rawBufferSize");
|
||||
final Field rbs = ReflectionHelper.findField(Tessellator.class, "rawBufferSize");
|
||||
rbs.setAccessible(true);
|
||||
try {
|
||||
sRawBufferSize = MethodHandles.lookup().unreflectSetter(rbs);
|
||||
@@ -137,6 +141,22 @@ public class CapturingTessellator extends Tessellator implements ITessellatorIns
|
||||
return byteBuffer;
|
||||
}
|
||||
|
||||
public void storeTranslation() {
|
||||
if(translationStored) throw new IllegalStateException("Translation already stored!");
|
||||
translationStored = true;
|
||||
this.storedTranslation.set(xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
public void restoreTranslation() {
|
||||
if(!translationStored) throw new IllegalStateException("Translation not stored!");
|
||||
|
||||
xOffset = storedTranslation.x;
|
||||
yOffset = storedTranslation.y;
|
||||
zOffset = storedTranslation.z;
|
||||
storedTranslation.zero();
|
||||
translationStored = false;
|
||||
}
|
||||
|
||||
public static int createBrightness(int sky, int block) {
|
||||
return sky << 20 | block << 4;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class VertexBuffer implements AutoCloseable {
|
||||
|
||||
public VertexBuffer upload(ByteBuffer buffer) {
|
||||
if(format == null) throw new IllegalStateException("No format specified for VBO upload");
|
||||
upload(buffer, buffer.capacity() / format.getVertexSize());
|
||||
upload(buffer, buffer.remaining() / format.getVertexSize());
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -75,11 +75,8 @@ public class VertexBuffer implements AutoCloseable {
|
||||
unbind();
|
||||
}
|
||||
public void render() {
|
||||
if(format == null) throw new IllegalStateException("No format specified for VBO render");
|
||||
bind();
|
||||
format.setupBufferState(0L);
|
||||
setupState();
|
||||
draw();
|
||||
format.clearBufferState();
|
||||
unbind();
|
||||
cleanupState();
|
||||
}
|
||||
}
|
||||
+68
-36
@@ -3,11 +3,8 @@
|
||||
* License terms: https://www.lwjgl.org/license
|
||||
*/
|
||||
|
||||
package net.coderbot.iris.gl;
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.Iris;
|
||||
import org.lwjgl.opengl.AMDDebugOutput;
|
||||
import org.lwjgl.opengl.AMDDebugOutputCallback;
|
||||
import org.lwjgl.opengl.ARBDebugOutput;
|
||||
@@ -21,6 +18,7 @@ import org.lwjgl.opengl.KHRDebugCallback;
|
||||
import java.io.PrintStream;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
import static org.lwjgl.opengl.ARBDebugOutput.glDebugMessageCallbackARB;
|
||||
|
||||
public final class GLDebug {
|
||||
@@ -30,7 +28,7 @@ public final class GLDebug {
|
||||
*/
|
||||
public static int setupDebugMessageCallback() {
|
||||
if (Thread.currentThread() != GLStateManager.getMainThread()) {
|
||||
AngelicaTweaker.LOGGER.warn("setupDebugMessageCallback called from non-main thread!");
|
||||
LOGGER.warn("setupDebugMessageCallback called from non-main thread!");
|
||||
return 0;
|
||||
}
|
||||
return setupDebugMessageCallback(System.err);
|
||||
@@ -64,7 +62,7 @@ public final class GLDebug {
|
||||
return throwable;
|
||||
}
|
||||
|
||||
private static void printTrace(PrintStream stream) {
|
||||
public static void printTrace(PrintStream stream) {
|
||||
trace(new Consumer<String>() {
|
||||
boolean first = true;
|
||||
|
||||
@@ -84,8 +82,8 @@ public final class GLDebug {
|
||||
* @return 0 for failure, 1 for success, 2 for restart required.
|
||||
*/
|
||||
public static int setupDebugMessageCallback(PrintStream stream) {
|
||||
if (Iris.capabilities.OpenGL43 || Iris.capabilities.GL_KHR_debug) {
|
||||
Iris.logger.info("[GL] Using OpenGL 4.3 for error logging.");
|
||||
if (GLStateManager.capabilities.OpenGL43 || GLStateManager.capabilities.GL_KHR_debug) {
|
||||
LOGGER.info("[GL] Using OpenGL 4.3 for error logging.");
|
||||
KHRDebugCallback proc = new KHRDebugCallback((source, type, id, severity, message) -> {
|
||||
stream.println("[LWJGL] OpenGL debug message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
@@ -102,13 +100,13 @@ public final class GLDebug {
|
||||
GL43.glDebugMessageCallback(proc);
|
||||
|
||||
if ((GL11.glGetInteger(GL30.GL_CONTEXT_FLAGS) & GL43.GL_CONTEXT_FLAG_DEBUG_BIT) == 0) {
|
||||
Iris.logger.warn("[GL] Warning: A non-debug context may not produce any debug output.");
|
||||
LOGGER.warn("[GL] Warning: A non-debug context may not produce any debug output.");
|
||||
GL11.glEnable(GL43.GL_DEBUG_OUTPUT);
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
} else if (Iris.capabilities.GL_ARB_debug_output) {
|
||||
Iris.logger.info("[GL] Using ARB_debug_output for error logging.");
|
||||
} else if (GLStateManager.capabilities.GL_ARB_debug_output) {
|
||||
LOGGER.info("[GL] Using ARB_debug_output for error logging.");
|
||||
ARBDebugOutputCallback proc = new ARBDebugOutputCallback((source, type, id, severity, message) -> {
|
||||
stream.println("[LWJGL] ARB_debug_output message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
@@ -124,8 +122,8 @@ public final class GLDebug {
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_NOTIFICATION, null, false);
|
||||
ARBDebugOutput.glDebugMessageCallbackARB(proc);
|
||||
return 1;
|
||||
} else if (Iris.capabilities.GL_AMD_debug_output) {
|
||||
Iris.logger.info("[GL] Using AMD_debug_output for error logging.");
|
||||
} else if (GLStateManager.capabilities.GL_AMD_debug_output) {
|
||||
LOGGER.info("[GL] Using AMD_debug_output for error logging.");
|
||||
AMDDebugOutputCallback proc = new AMDDebugOutputCallback((id, category, severity, message) -> {
|
||||
stream.println("[LWJGL] AMD_debug_output message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
@@ -141,29 +139,29 @@ public final class GLDebug {
|
||||
AMDDebugOutput.glDebugMessageCallbackAMD(proc);
|
||||
return 1;
|
||||
} else {
|
||||
Iris.logger.info("[GL] No debug output implementation is available, cannot return debug info.");
|
||||
LOGGER.info("[GL] No debug output implementation is available, cannot return debug info.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int disableDebugMessages() {
|
||||
if (Iris.capabilities.OpenGL43) {
|
||||
if (GLStateManager.capabilities.OpenGL43) {
|
||||
GL43.glDebugMessageCallback(null);
|
||||
return 1;
|
||||
} else if (Iris.capabilities.GL_KHR_debug) {
|
||||
} else if (GLStateManager.capabilities.GL_KHR_debug) {
|
||||
KHRDebug.glDebugMessageCallback(null);
|
||||
if (Iris.capabilities.OpenGL30 && (GL11.glGetInteger(GL30.GL_CONTEXT_FLAGS) & 2) == 0) {
|
||||
if (GLStateManager.capabilities.OpenGL30 && (GL11.glGetInteger(GL30.GL_CONTEXT_FLAGS) & 2) == 0) {
|
||||
GL11.glDisable(GL43.GL_DEBUG_OUTPUT);
|
||||
}
|
||||
return 1;
|
||||
} else if (Iris.capabilities.GL_ARB_debug_output) {
|
||||
} else if (GLStateManager.capabilities.GL_ARB_debug_output) {
|
||||
glDebugMessageCallbackARB(null);
|
||||
return 1;
|
||||
} else if (Iris.capabilities.GL_AMD_debug_output) {
|
||||
} else if (GLStateManager.capabilities.GL_AMD_debug_output) {
|
||||
AMDDebugOutput.glDebugMessageCallbackAMD(null);
|
||||
return 1;
|
||||
} else {
|
||||
Iris.logger.info("[GL] No debug output implementation is available, cannot disable debug info.");
|
||||
LOGGER.info("[GL] No debug output implementation is available, cannot disable debug info.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -273,14 +271,17 @@ public final class GLDebug {
|
||||
|
||||
private static DebugState debugState;
|
||||
|
||||
private static interface DebugState {
|
||||
private interface DebugState {
|
||||
void nameObject(int id, int object, String name);
|
||||
void pushGroup(int id, String name);
|
||||
void pushGroup(String name);
|
||||
void popGroup();
|
||||
void debugMessage(String name);
|
||||
}
|
||||
|
||||
private static class KHRDebugState implements DebugState {
|
||||
private boolean hasGroup;
|
||||
private static final int ID = 0;
|
||||
private int depth = 0;
|
||||
private static final int maxDepth = GL11.glGetInteger(KHRDebug.GL_MAX_DEBUG_GROUP_STACK_DEPTH);
|
||||
|
||||
@Override
|
||||
public void nameObject(int id, int object, String name) {
|
||||
@@ -288,19 +289,28 @@ public final class GLDebug {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushGroup(int id, String name) {
|
||||
KHRDebug.glPushDebugGroup(KHRDebug.GL_DEBUG_SOURCE_APPLICATION, id, name);
|
||||
hasGroup = true;
|
||||
public void pushGroup(String name) {
|
||||
depth++;
|
||||
if (depth > maxDepth) {
|
||||
throw new RuntimeException("Stack overflow");
|
||||
}
|
||||
KHRDebug.glPushDebugGroup(KHRDebug.GL_DEBUG_SOURCE_APPLICATION, ID, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popGroup() {
|
||||
if (hasGroup) {
|
||||
KHRDebug.glPopDebugGroup();
|
||||
hasGroup = false;
|
||||
}
|
||||
depth--;
|
||||
if (depth < 0) {
|
||||
throw new RuntimeException("Stack underflow");
|
||||
}
|
||||
KHRDebug.glPopDebugGroup();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugMessage(String message) {
|
||||
KHRDebug.glDebugMessageInsert(KHRDebug.GL_DEBUG_SOURCE_APPLICATION, KHRDebug.GL_DEBUG_TYPE_MARKER, ID, KHRDebug.GL_DEBUG_SEVERITY_NOTIFICATION, message);
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnsupportedDebugState implements DebugState {
|
||||
@Override
|
||||
@@ -308,16 +318,21 @@ public final class GLDebug {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushGroup(int id, String name) {
|
||||
public void pushGroup(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popGroup() {
|
||||
}
|
||||
}
|
||||
|
||||
public static void initRenderer() {
|
||||
if (Iris.capabilities.GL_KHR_debug || Iris.capabilities.OpenGL43) {
|
||||
@Override
|
||||
public void debugMessage(String name) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void initDebugState() {
|
||||
if (GLStateManager.capabilities.GL_KHR_debug || GLStateManager.capabilities.OpenGL43) {
|
||||
debugState = new KHRDebugState();
|
||||
} else {
|
||||
debugState = new UnsupportedDebugState();
|
||||
@@ -325,6 +340,23 @@ public final class GLDebug {
|
||||
}
|
||||
|
||||
public static void nameObject(int id, int object, String name) {
|
||||
debugState.nameObject(id, object, name);
|
||||
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
|
||||
debugState.nameObject(id, object, name);
|
||||
}
|
||||
}
|
||||
public static void pushGroup(String group) {
|
||||
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
|
||||
debugState.pushGroup(group);
|
||||
}
|
||||
}
|
||||
public static void popGroup() {
|
||||
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
|
||||
debugState.popGroup();
|
||||
}
|
||||
}
|
||||
public static void debugMessage(String message) {
|
||||
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
|
||||
debugState.debugMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,11 +45,13 @@ import org.joml.Vector3f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.opengl.ARBMultitexture;
|
||||
import org.lwjgl.opengl.ContextCapabilities;
|
||||
import org.lwjgl.opengl.Drawable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
@@ -63,6 +65,8 @@ import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
@SuppressWarnings("unused") // Used in ASM
|
||||
public class GLStateManager {
|
||||
public static ContextCapabilities capabilities;
|
||||
|
||||
public static final boolean BYPASS_CACHE = Boolean.parseBoolean(System.getProperty("angelica.disableGlCache", "false"));
|
||||
public static final int MAX_ATTRIB_STACK_DEPTH = GL11.glGetInteger(GL11.GL_MAX_ATTRIB_STACK_DEPTH);
|
||||
public static final int MAX_MODELVIEW_STACK_DEPTH = GL11.glGetInteger(GL11.GL_MAX_MODELVIEW_STACK_DEPTH);
|
||||
@@ -124,9 +128,9 @@ public class GLStateManager {
|
||||
private static final Map<IStateStack<?>, ISettableState<?>> glListStates = new Object2ObjectArrayMap<>();
|
||||
private static final Int2ObjectMap<Set<Map.Entry<IStateStack<?>, ISettableState<?>>>> glListChanges = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private static boolean hudCaching$blendEnabled;
|
||||
|
||||
public static void init() {
|
||||
capabilities = GLContext.getCapabilities();
|
||||
|
||||
if (AngelicaConfig.enableIris) {
|
||||
StateUpdateNotifiers.blendFuncNotifier = listener -> blendFuncListener = listener;
|
||||
StateUpdateNotifiers.fogToggleNotifier = listener -> fogToggleListener = listener;
|
||||
@@ -138,8 +142,18 @@ public class GLStateManager {
|
||||
if(BYPASS_CACHE) {
|
||||
LOGGER.info("GLStateManager cache bypassed");
|
||||
}
|
||||
if(AngelicaMod.lwjglDebug) {
|
||||
LOGGER.info("Enabling additional LWJGL debug output");
|
||||
|
||||
GLDebug.setupDebugMessageCallback();
|
||||
GLDebug.initDebugState();
|
||||
|
||||
GLDebug.debugMessage("Angelica Debug Annotator Initialized");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void assertMainThread() {
|
||||
if (Thread.currentThread() != CurrentThread && !runningSplash) {
|
||||
LOGGER.info("Call from not the Current Thread! - " + Thread.currentThread().getName() + " Current thread: " + CurrentThread.getName());
|
||||
@@ -204,7 +218,6 @@ public class GLStateManager {
|
||||
return;
|
||||
}
|
||||
}
|
||||
hudCaching$blendEnabled = true;
|
||||
blendMode.enable();
|
||||
}
|
||||
|
||||
@@ -215,7 +228,6 @@ public class GLStateManager {
|
||||
return;
|
||||
}
|
||||
}
|
||||
hudCaching$blendEnabled = false;
|
||||
blendMode.disable();
|
||||
}
|
||||
|
||||
@@ -299,36 +311,24 @@ public class GLStateManager {
|
||||
}
|
||||
|
||||
public static void glColor4f(float red, float green, float blue, float alpha) {
|
||||
if (!hudCaching$blendEnabled && HUDCaching.renderingCacheOverride && alpha < 1f) {
|
||||
alpha = 1f;
|
||||
}
|
||||
if (changeColor(red, green, blue, alpha)) {
|
||||
GL11.glColor4f(red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glColor4d(double red, double green, double blue, double alpha) {
|
||||
if (!hudCaching$blendEnabled && HUDCaching.renderingCacheOverride && alpha < 1d) {
|
||||
alpha = 1d;
|
||||
}
|
||||
if (changeColor((float) red, (float) green, (float) blue, (float) alpha)) {
|
||||
GL11.glColor4d(red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glColor4b(byte red, byte green, byte blue, byte alpha) {
|
||||
if (!hudCaching$blendEnabled && HUDCaching.renderingCacheOverride && alpha < Byte.MAX_VALUE) {
|
||||
alpha = Byte.MAX_VALUE;
|
||||
}
|
||||
if (changeColor(b2f(red), b2f(green), b2f(blue), b2f(alpha))) {
|
||||
GL11.glColor4b(red, green, blue, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glColor4ub(byte red, byte green, byte blue, byte alpha) {
|
||||
if (!hudCaching$blendEnabled && HUDCaching.renderingCacheOverride && alpha < Byte.MAX_VALUE) {
|
||||
alpha = Byte.MAX_VALUE;
|
||||
}
|
||||
if (changeColor(ub2f(red), ub2f(green), ub2f(blue), ub2f(alpha))) {
|
||||
GL11.glColor4ub(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ public class TessellatorManager {
|
||||
|
||||
public static void startCapturing() {
|
||||
if(currentlyCapturing.get()) throw new IllegalStateException("Tried to start capturing when already capturing!");
|
||||
if(capturingTessellator.get().getQuads().size() > 0) throw new IllegalStateException("Tried to start capturing with existing collected Quads!");
|
||||
final CapturingTessellator tess = capturingTessellator.get();
|
||||
if(tess.getQuads().size() > 0) throw new IllegalStateException("Tried to start capturing with existing collected Quads!");
|
||||
tess.storeTranslation();
|
||||
|
||||
currentlyCapturing.set(true);
|
||||
}
|
||||
@@ -59,6 +61,7 @@ public class TessellatorManager {
|
||||
|
||||
final List<Quad> quads = tess.getQuads();
|
||||
tess.discard();
|
||||
tess.restoreTranslation();
|
||||
|
||||
return quads;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.TessellatorManager;
|
||||
@@ -34,10 +35,7 @@ public class HUDCaching {
|
||||
public static Framebuffer framebuffer;
|
||||
static {
|
||||
framebuffer = new Framebuffer(0, 0, true);
|
||||
framebuffer.framebufferColor[0] = 0.0F;
|
||||
framebuffer.framebufferColor[1] = 0.0F;
|
||||
framebuffer.framebufferColor[2] = 0.0F;
|
||||
framebuffer.framebufferColor[3] = 0.0F;
|
||||
framebuffer.setFramebufferColor(0, 0, 0, 0);
|
||||
}
|
||||
private static boolean dirty = true;
|
||||
|
||||
@@ -112,30 +110,23 @@ public class HUDCaching {
|
||||
return;
|
||||
}
|
||||
|
||||
GLStateManager.enableDepthTest();
|
||||
ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int width = resolution.getScaledWidth();
|
||||
int height = resolution.getScaledHeight();
|
||||
renderer.setupOverlayRendering();
|
||||
GLStateManager.enableBlend();
|
||||
|
||||
if (dirty) {
|
||||
dirty = false;
|
||||
checkFramebufferSizes(mc.displayWidth, mc.displayHeight);
|
||||
framebuffer.framebufferClear();
|
||||
resetFramebuffer(mc.displayWidth, mc.displayHeight);
|
||||
framebuffer.bindFramebuffer(false);
|
||||
GLStateManager.disableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GLStateManager.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GLStateManager.disableLighting();
|
||||
GLStateManager.disableFog();
|
||||
renderingCacheOverride = true;
|
||||
ingame.renderGameOverlay(partialTicks, hasScreen, mouseX, mouseY);
|
||||
renderingCacheOverride = false;
|
||||
mc.getFramebuffer().bindFramebuffer(false);
|
||||
GLStateManager.enableBlend();
|
||||
} else {
|
||||
renderer.setupOverlayRendering();
|
||||
}
|
||||
|
||||
ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int width = resolution.getScaledWidth();
|
||||
int height = resolution.getScaledHeight();
|
||||
GLStateManager.enableBlend();
|
||||
|
||||
// reset the color that may be applied by some items
|
||||
GLStateManager.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
@@ -148,8 +139,6 @@ public class HUDCaching {
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
}
|
||||
|
||||
Tessellator tessellator = TessellatorManager.get();
|
||||
|
||||
if (ingame instanceof GuiIngameForge) {
|
||||
GuiIngameForgeAccessor guiForge = ((GuiIngameForgeAccessor) ingame);
|
||||
if (renderHelmetCaptured) {
|
||||
@@ -168,36 +157,46 @@ public class HUDCaching {
|
||||
}
|
||||
if (renderPortalCapturedTicks > 0)
|
||||
{
|
||||
gui.callFunc_130015_b(renderPortalCapturedTicks, width, height);
|
||||
}
|
||||
if (renderCrosshairsCaptured) {
|
||||
mc.getTextureManager().bindTexture(Gui.icons);
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.enableAlphaTest();
|
||||
drawTexturedModalRect(tessellator, (width >> 1) - 7, (height >> 1) - 7);
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
gui.callRenderPortal(renderPortalCapturedTicks, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
// render cached frame
|
||||
Tessellator tessellator = TessellatorManager.get();
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GLStateManager.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
framebuffer.bindFramebufferTexture();
|
||||
drawTexturedRect(tessellator, (float) resolution.getScaledWidth_double(), (float) resolution.getScaledHeight_double());
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
|
||||
GLStateManager.enableDepthTest();
|
||||
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
mc.getTextureManager().bindTexture(Gui.icons);
|
||||
}
|
||||
|
||||
/**
|
||||
* We are skipping certain render calls when rendering into cache,
|
||||
* however, we cannot skip the GL state changes. This will fix
|
||||
* the state before we start rendering
|
||||
*/
|
||||
public static void fixGLStateBeforeRenderingCache() {
|
||||
GLStateManager.glDepthMask(true);
|
||||
GLStateManager.enableDepthTest();
|
||||
GLStateManager.enableAlphaTest();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.disableBlend();
|
||||
}
|
||||
|
||||
private static void checkFramebufferSizes(int width, int height) {
|
||||
private static void resetFramebuffer(int width, int height) {
|
||||
if (framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
|
||||
framebuffer.createBindFramebuffer(width, height);
|
||||
framebuffer.framebufferWidth = width;
|
||||
framebuffer.framebufferHeight = height;
|
||||
framebuffer.createBindFramebuffer(width, height);
|
||||
framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
|
||||
} else {
|
||||
framebuffer.framebufferClear();
|
||||
}
|
||||
// copy depth buffer from MC
|
||||
OpenGlHelper.func_153171_g(GL30.GL_READ_FRAMEBUFFER, mc.getFramebuffer().framebufferObject);
|
||||
OpenGlHelper.func_153171_g(GL30.GL_DRAW_FRAMEBUFFER, framebuffer.framebufferObject);
|
||||
GL30.glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT, GL11.GL_NEAREST);
|
||||
}
|
||||
|
||||
private static void drawTexturedRect(Tessellator tessellator, float width, float height) {
|
||||
@@ -214,13 +213,4 @@ public class HUDCaching {
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
}
|
||||
|
||||
private static void drawTexturedModalRect(Tessellator tessellator, int x, int y) {
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(x, y + 16, 100.0, 0.0, 0.0625);
|
||||
tessellator.addVertexWithUV(x + 16, y + 16, 100.0, 0.0625, 0.0625);
|
||||
tessellator.addVertexWithUV(x + 16, y, 100.0, 0.0625, 0.0);
|
||||
tessellator.addVertexWithUV(x, y, 100.0, 0.0, 0.0);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,7 +47,9 @@ public enum Mixins {
|
||||
|
||||
ANGELICA_ENABLE_DEBUG(new Builder("Angelica Debug").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaMod.lwjglDebug).addMixinClasses(
|
||||
"angelica.debug.MixinSplashProgress"
|
||||
"angelica.debug.MixinProfiler"
|
||||
,"angelica.debug.MixinSplashProgress"
|
||||
,"angelica.debug.MixinTextureManager"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -79,12 +81,6 @@ public enum Mixins {
|
||||
)
|
||||
),
|
||||
|
||||
SODIUM_STARTUP(new Builder("Start Sodium").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableSodium && !AngelicaConfig.enableIris).addMixinClasses(
|
||||
"sodium.startup.MixinInitDebug"
|
||||
)
|
||||
),
|
||||
|
||||
SODIUM(new Builder("Sodium").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableSodium).addMixinClasses(
|
||||
"sodium.MixinChunkProviderClient"
|
||||
@@ -194,7 +190,7 @@ public enum Mixins {
|
||||
"angelica.animation.MixinRenderBlockFluid",
|
||||
"angelica.animation.MixinWorldRenderer",
|
||||
"angelica.animation.MixinRenderItem")),
|
||||
|
||||
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new Builder("Add animation speedup support to Campfire Backport").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.CAMPFIRE_BACKPORT).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.speedupAnimations)
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.debug;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Profiler.class)
|
||||
public class MixinProfiler {
|
||||
@Inject(method = "startSection(Ljava/lang/String;)V", at = @At("HEAD"))
|
||||
private void debugStartSection(String name, CallbackInfo ci) {
|
||||
GLDebug.pushGroup("minecraft:" + name);
|
||||
}
|
||||
|
||||
@Inject(method = "endSection()V", at = @At("HEAD"))
|
||||
private void debugEndSection(CallbackInfo ci) {
|
||||
GLDebug.popGroup();
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.debug;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(TextureManager.class)
|
||||
public class MixinTextureManager {
|
||||
@Inject(method = "loadTexture", at = @At("RETURN"))
|
||||
private void onTextureLoad(ResourceLocation resource, ITextureObject texture, CallbackInfoReturnable<Boolean> cir) {
|
||||
if(texture != null && texture != TextureUtil.missingTexture) {
|
||||
final int curId = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getGlTextureId());
|
||||
GLDebug.nameObject(GL11.GL_TEXTURE, texture.getGlTextureId(), resource.toString());
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, curId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -13,7 +13,6 @@ public interface GuiIngameAccessor {
|
||||
@Invoker
|
||||
void callRenderPumpkinBlur(int width, int height);
|
||||
|
||||
// render portal
|
||||
@Invoker
|
||||
void callFunc_130015_b(float partialTicks, int width, int height);
|
||||
@Invoker("func_130015_b")
|
||||
void callRenderPortal(float partialTicks, int width, int height);
|
||||
}
|
||||
+7
-2
@@ -1,10 +1,12 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.hudcaching;
|
||||
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
|
||||
@Mixin(GuiIngameForge.class)
|
||||
public interface GuiIngameForgeAccessor {
|
||||
|
||||
@@ -16,4 +18,7 @@ public interface GuiIngameForgeAccessor {
|
||||
|
||||
@Invoker(remap = false)
|
||||
void callRenderPortal(int width, int height, float partialTicks);
|
||||
|
||||
@Invoker(remap = false)
|
||||
void callBind(ResourceLocation res);
|
||||
}
|
||||
+15
-2
@@ -1,12 +1,15 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.hudcaching;
|
||||
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
|
||||
@Mixin(GuiIngameForge.class)
|
||||
public class MixinGuiIngameForge_HUDCaching {
|
||||
@Inject(method = "renderGameOverlay", at = @At("HEAD"))
|
||||
@@ -23,6 +26,7 @@ public class MixinGuiIngameForge_HUDCaching {
|
||||
private void angelica$captureRenderCrosshair(CallbackInfo ci) {
|
||||
if (HUDCaching.renderingCacheOverride) {
|
||||
HUDCaching.renderCrosshairsCaptured = true;
|
||||
HUDCaching.fixGLStateBeforeRenderingCache();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -42,4 +46,13 @@ public class MixinGuiIngameForge_HUDCaching {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderBossHealth", at = @At("HEAD"))
|
||||
private void angelica$bindBossHealthTexture(CallbackInfo ci) {
|
||||
// boss health texture is bind in renderCrosshairs
|
||||
// but HUD caching skips rendering crosshairs when rendering into cache
|
||||
if (HUDCaching.renderingCacheOverride) {
|
||||
((GuiIngameForgeAccessor) this).callBind(Gui.icons);
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -6,7 +6,10 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiIngame;
|
||||
|
||||
@Mixin(GuiIngame.class)
|
||||
@@ -44,4 +47,15 @@ public class MixinGuiIngame_HUDCaching {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "func_96136_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawString(Ljava/lang/String;III)I"))
|
||||
private int angelica$fixScoreboardTextAlpha(FontRenderer fontRenderer, String text, int x, int y, int color, Operation<Integer> op) {
|
||||
// Vanilla uses 0x20 for the alpha but it looks like 0xFF for some reason
|
||||
// here we just make it 0xFF so it doesn't cause issues
|
||||
if (HUDCaching.renderingCacheOverride) {
|
||||
color |= 0xFF000000;
|
||||
}
|
||||
return op.call(fontRenderer, text, x, y, color);
|
||||
}
|
||||
|
||||
}
|
||||
-3
@@ -3,7 +3,6 @@ package com.gtnewhorizons.angelica.mixins.early.shaders.startup;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.GLDebug;
|
||||
import net.coderbot.iris.gl.IrisRenderSystem;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -20,8 +19,6 @@ public class MixinInitRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
Iris.identifyCapabilities();
|
||||
GLDebug.initRenderer();
|
||||
IrisRenderSystem.initRenderer();
|
||||
Iris.onRenderSystemInit();
|
||||
}
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.sodium.startup;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(OpenGlHelper.class)
|
||||
public class MixinInitDebug {
|
||||
@Inject(method = "initializeTextures", at = @At("RETURN"))
|
||||
private static void sodium$initIrisDebug(CallbackInfo ci) {
|
||||
if (Thread.currentThread() != GLStateManager.getMainThread()) {
|
||||
AngelicaTweaker.LOGGER.warn("Renderer initialization called from non-main thread!");
|
||||
return;
|
||||
}
|
||||
// Temp -- move this into common debug code
|
||||
Iris.identifyCapabilities();
|
||||
Iris.setDebug(AngelicaMod.lwjglDebug);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-8
@@ -1,5 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.buffer;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.BufferVertexFormat;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
@@ -24,14 +25,7 @@ public class VertexBufferBuilder implements VertexBufferView {
|
||||
// The new capacity will at least as large as the write it needs to service
|
||||
final int cap = Math.max(this.capacity * 2, this.capacity + len);
|
||||
|
||||
// Allocate a new buffer and copy the old buffer's contents into it
|
||||
final ByteBuffer buffer = BufferUtils.createByteBuffer(cap);
|
||||
this.buffer.rewind();
|
||||
buffer.put(this.buffer);
|
||||
buffer.position(0);
|
||||
|
||||
// Update the buffer and capacity now
|
||||
this.buffer = buffer;
|
||||
this.buffer = CompatMemoryUtil.memReallocDirect(this.buffer, cap);
|
||||
this.capacity = cap;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,12 @@ package net.coderbot.iris;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.mitchej123.hodgepodge.Common;
|
||||
import com.mitchej123.hodgepodge.client.HodgepodgeClient;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.config.IrisConfig;
|
||||
import net.coderbot.iris.gl.GLDebug;
|
||||
import net.coderbot.iris.gl.shader.StandardMacros;
|
||||
import net.coderbot.iris.gui.screen.ShaderPackScreen;
|
||||
import net.coderbot.iris.pipeline.DeferredWorldRenderingPipeline;
|
||||
@@ -38,8 +34,6 @@ import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.ContextCapabilities;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -61,7 +55,6 @@ import java.util.zip.ZipException;
|
||||
|
||||
public class Iris {
|
||||
public final boolean isDevelopmentEnvironment;
|
||||
public static ContextCapabilities capabilities;
|
||||
|
||||
/**
|
||||
* The user-facing name of the mod. Moved into a constant to facilitate easy branding changes (for forks). You'll still need to change this separately in
|
||||
@@ -179,9 +172,6 @@ public class Iris {
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public static void identifyCapabilities() {
|
||||
capabilities = GLContext.getCapabilities();
|
||||
}
|
||||
/**
|
||||
* Called once RenderSystem#initRenderer has completed. This means that we can safely access OpenGL.
|
||||
*/
|
||||
@@ -192,8 +182,6 @@ public class Iris {
|
||||
return;
|
||||
}
|
||||
|
||||
setDebug(irisConfig.areDebugOptionsEnabled());
|
||||
|
||||
PBRTextureManager.INSTANCE.init();
|
||||
|
||||
// Only load the shader pack when we can access OpenGL
|
||||
@@ -387,34 +375,6 @@ public class Iris {
|
||||
logger.info("Shaders are disabled");
|
||||
}
|
||||
|
||||
// Temp escalation
|
||||
public static void setDebug(boolean enable) {
|
||||
GLStateManager.assertMainThread();
|
||||
final int success;
|
||||
if (enable) {
|
||||
success = GLDebug.setupDebugMessageCallback();
|
||||
} else {
|
||||
success = GLDebug.disableDebugMessages();
|
||||
}
|
||||
logger.info("Debug functionality is " + (enable ? "enabled, logging will be more verbose!" : "disabled."));
|
||||
if (Minecraft.getMinecraft().thePlayer != null) {
|
||||
Minecraft.getMinecraft().thePlayer.sendChatMessage(I18n.format(success != 0 ? (enable
|
||||
? "iris.shaders.debug.enabled"
|
||||
: "iris.shaders.debug.disabled") : "iris.shaders.debug.failure"));
|
||||
if (success == 2) {
|
||||
Minecraft.getMinecraft().thePlayer.sendChatMessage(I18n.format("iris.shaders.debug.restart"));
|
||||
}
|
||||
}
|
||||
if(Iris.isInitialized()) {
|
||||
try {
|
||||
irisConfig.setDebugEnabled(enable);
|
||||
irisConfig.save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Optional<Properties> tryReadConfigProperties(Path path) {
|
||||
final Properties properties = new Properties();
|
||||
|
||||
|
||||
@@ -27,11 +27,6 @@ public class IrisConfig {
|
||||
*/
|
||||
private boolean enableShaders;
|
||||
|
||||
/**
|
||||
* If debug features should be enabled. Gives much more detailed OpenGL error outputs at the cost of performance.
|
||||
*/
|
||||
private boolean enableDebugOptions;
|
||||
|
||||
/**
|
||||
* If the update notification should be disabled or not.
|
||||
*/
|
||||
@@ -42,7 +37,6 @@ public class IrisConfig {
|
||||
public IrisConfig(Path propertiesPath) {
|
||||
shaderPackName = null;
|
||||
enableShaders = true;
|
||||
enableDebugOptions = false;
|
||||
disableUpdateMessage = false;
|
||||
this.propertiesPath = propertiesPath;
|
||||
}
|
||||
@@ -97,18 +91,10 @@ public class IrisConfig {
|
||||
return enableShaders;
|
||||
}
|
||||
|
||||
public boolean areDebugOptionsEnabled() {
|
||||
return enableDebugOptions;
|
||||
}
|
||||
|
||||
public boolean shouldDisableUpdateMessage() {
|
||||
return disableUpdateMessage;
|
||||
}
|
||||
|
||||
public void setDebugEnabled(boolean enabled) {
|
||||
enableDebugOptions = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether shaders should be used for rendering.
|
||||
*/
|
||||
@@ -134,7 +120,6 @@ public class IrisConfig {
|
||||
}
|
||||
shaderPackName = properties.getProperty("shaderPack");
|
||||
enableShaders = !"false".equals(properties.getProperty("enableShaders"));
|
||||
enableDebugOptions = "true".equals(properties.getProperty("enableDebugOptions"));
|
||||
disableUpdateMessage = "true".equals(properties.getProperty("disableUpdateMessage"));
|
||||
// TODO: GUI
|
||||
// try {
|
||||
@@ -161,7 +146,6 @@ public class IrisConfig {
|
||||
final Properties properties = new Properties();
|
||||
properties.setProperty("shaderPack", getShaderPackName().orElse(""));
|
||||
properties.setProperty("enableShaders", enableShaders ? "true" : "false");
|
||||
properties.setProperty("enableDebugOptions", enableDebugOptions ? "true" : "false");
|
||||
properties.setProperty("disableUpdateMessage", disableUpdateMessage ? "true" : "false");
|
||||
// properties.setProperty("maxShadowRenderDistance", String.valueOf(IrisVideoSettings.shadowDistance));
|
||||
properties.setProperty("maxShadowRenderDistance", String.valueOf(32));
|
||||
|
||||
@@ -33,15 +33,15 @@ public class IrisRenderSystem {
|
||||
|
||||
public static void initRenderer() {
|
||||
try {
|
||||
if (Iris.capabilities.OpenGL45) {
|
||||
if (GLStateManager.capabilities.OpenGL45) {
|
||||
dsaState = new DSACore();
|
||||
Iris.logger.info("OpenGL 4.5 detected, enabling DSA.");
|
||||
}
|
||||
hasMultibind = Iris.capabilities.OpenGL45;
|
||||
hasMultibind = GLStateManager.capabilities.OpenGL45;
|
||||
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
try {
|
||||
if (dsaState == null && Iris.capabilities.GL_ARB_direct_state_access) {
|
||||
if (dsaState == null && GLStateManager.capabilities.GL_ARB_direct_state_access) {
|
||||
dsaState = new DSAARB();
|
||||
Iris.logger.info("ARB_direct_state_access detected, enabling DSA.");
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class IrisRenderSystem {
|
||||
}
|
||||
|
||||
try {
|
||||
hasMultibind |= Iris.capabilities.GL_ARB_multi_bind;
|
||||
hasMultibind |= GLStateManager.capabilities.GL_ARB_multi_bind;
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
|
||||
supportsCompute = supportsCompute();
|
||||
@@ -187,7 +187,7 @@ public class IrisRenderSystem {
|
||||
}
|
||||
|
||||
public static void bindImageTexture(int unit, int texture, int level, boolean layered, int layer, int access, int format) {
|
||||
if (Iris.capabilities.OpenGL42) {
|
||||
if (GLStateManager.capabilities.OpenGL42) {
|
||||
GL42.glBindImageTexture(unit, texture, level, layered, layer, access, format);
|
||||
} else {
|
||||
EXTShaderImageLoadStore.glBindImageTextureEXT(unit, texture, level, layered, layer, access, format);
|
||||
@@ -195,9 +195,9 @@ public class IrisRenderSystem {
|
||||
}
|
||||
|
||||
public static int getMaxImageUnits() {
|
||||
if (Iris.capabilities.OpenGL42) {
|
||||
if (GLStateManager.capabilities.OpenGL42) {
|
||||
return GL11.glGetInteger(GL42.GL_MAX_IMAGE_UNITS);
|
||||
} else if (Iris.capabilities.GL_EXT_shader_image_load_store) {
|
||||
} else if (GLStateManager.capabilities.GL_EXT_shader_image_load_store) {
|
||||
return GL11.glGetInteger(EXTShaderImageLoadStore.GL_MAX_IMAGE_UNITS_EXT);
|
||||
} else {
|
||||
return 0;
|
||||
@@ -223,7 +223,7 @@ public class IrisRenderSystem {
|
||||
}
|
||||
|
||||
public static boolean supportsBufferBlending() {
|
||||
return Iris.capabilities.GL_ARB_draw_buffers_blend || Iris.capabilities.OpenGL40;
|
||||
return GLStateManager.capabilities.GL_ARB_draw_buffers_blend || GLStateManager.capabilities.OpenGL40;
|
||||
}
|
||||
|
||||
public static void disableBufferBlend(int buffer) {
|
||||
@@ -353,7 +353,7 @@ public class IrisRenderSystem {
|
||||
|
||||
@Override
|
||||
public int bufferStorage(int target, FloatBuffer data, int usage) {
|
||||
int buffer = GL45.glCreateBuffers();
|
||||
final int buffer = GL45.glCreateBuffers();
|
||||
GL45.glNamedBufferData(buffer, data, usage);
|
||||
return buffer;
|
||||
}
|
||||
@@ -424,7 +424,7 @@ public class IrisRenderSystem {
|
||||
|
||||
@Override
|
||||
public void copyTexSubImage2D(int destTexture, int target, int i, int i1, int i2, int i3, int i4, int width, int height) {
|
||||
int previous = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
final int previous = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, destTexture);
|
||||
GL11.glCopyTexSubImage2D(target, i, i1, i2, i3, i4, width, height);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, previous);
|
||||
@@ -438,7 +438,7 @@ public class IrisRenderSystem {
|
||||
|
||||
@Override
|
||||
public int bufferStorage(int target, FloatBuffer data, int usage) {
|
||||
int buffer = GL15.glGenBuffers();
|
||||
final int buffer = GL15.glGenBuffers();
|
||||
GL15.glBindBuffer(target, buffer);
|
||||
bufferData(target, data, usage);
|
||||
GL15.glBindBuffer(target, 0);
|
||||
@@ -461,14 +461,14 @@ public class IrisRenderSystem {
|
||||
|
||||
@Override
|
||||
public int createFramebuffer() {
|
||||
int framebuffer = OpenGlHelper.func_153165_e/*glGenFramebuffers*/();
|
||||
final int framebuffer = OpenGlHelper.func_153165_e/*glGenFramebuffers*/();
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createTexture(int target) {
|
||||
int texture = GL11.glGenTextures();
|
||||
final int texture = GL11.glGenTextures();
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
return texture;
|
||||
}
|
||||
@@ -496,7 +496,7 @@ public class IrisRenderSystem {
|
||||
// TODO: Proper notification of compute support
|
||||
public static boolean supportsCompute() {
|
||||
try {
|
||||
return Iris.capabilities.GL_ARB_compute_shader;
|
||||
return GLStateManager.capabilities.GL_ARB_compute_shader;
|
||||
} catch(Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package net.coderbot.iris.gl.shader;
|
||||
|
||||
import net.coderbot.iris.gl.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import net.coderbot.iris.gl.GlResource;
|
||||
import net.coderbot.iris.gl.IrisRenderSystem;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
package net.coderbot.iris.gl.shader;
|
||||
|
||||
import net.coderbot.iris.gl.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import net.coderbot.iris.gl.IrisRenderSystem;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.coderbot.iris.gl.texture;
|
||||
|
||||
import net.coderbot.iris.Iris;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.coderbot.iris.gl.IrisRenderSystem;
|
||||
import net.coderbot.iris.gl.framebuffer.GlFramebuffer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -78,7 +78,7 @@ public interface DepthCopyStrategy {
|
||||
}
|
||||
|
||||
static DepthCopyStrategy fastest(boolean combinedStencilRequired) {
|
||||
if (Iris.capabilities.GL_ARB_copy_image) {
|
||||
if (GLStateManager.capabilities.GL_ARB_copy_image) {
|
||||
return new Gl43CopyImage();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class HandRenderer {
|
||||
@@ -58,7 +60,11 @@ public class HandRenderer {
|
||||
public boolean isHandTranslucent(InteractionHand hand) {
|
||||
// TODO: Offhand
|
||||
// Item item = Minecraft.getMinecraft().thePlayer.getItemBySlot(hand == InteractionHand.OFF_HAND ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND).getItem();
|
||||
Item item = Minecraft.getMinecraft().thePlayer.getHeldItem().getItem();
|
||||
ItemStack heldItem = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
||||
if (heldItem == null) {
|
||||
return false;
|
||||
}
|
||||
Item item = heldItem.getItem();
|
||||
|
||||
if (item instanceof ItemBlock itemBlock) {
|
||||
// TODO: RenderType
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.coderbot.iris.postprocess;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.IrisRenderSystem;
|
||||
import net.coderbot.iris.gl.framebuffer.GlFramebuffer;
|
||||
import net.coderbot.iris.gl.program.Program;
|
||||
@@ -40,7 +39,7 @@ public class CenterDepthSampler {
|
||||
this.framebuffer = new GlFramebuffer();
|
||||
|
||||
// Fall back to a less precise format if the system doesn't support OpenGL 3
|
||||
InternalTextureFormat format = Iris.capabilities.OpenGL32 ? InternalTextureFormat.R32F : InternalTextureFormat.RGB16;
|
||||
InternalTextureFormat format = GLStateManager.capabilities.OpenGL32 ? InternalTextureFormat.R32F : InternalTextureFormat.RGB16;
|
||||
setupColorTexture(texture, format);
|
||||
setupColorTexture(altTexture, format);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, 0);
|
||||
@@ -51,7 +50,7 @@ public class CenterDepthSampler {
|
||||
try {
|
||||
String fsh = new String(IOUtils.toByteArray(Objects.requireNonNull(getClass().getResourceAsStream("/centerDepth.fsh"))), StandardCharsets.UTF_8);
|
||||
|
||||
if (Iris.capabilities.OpenGL32) {
|
||||
if (GLStateManager.capabilities.OpenGL32) {
|
||||
fsh = fsh.replace("VERSIONPLACEHOLDER", "150 compatibility");
|
||||
} else {
|
||||
fsh = fsh.replace("#define IS_GL3", "");
|
||||
|
||||
Reference in new issue
Block a user