Cleaned up OpenGL calls in CustomObjectRenderer and PathPreviewRenderer
This commit is contained in:
@@ -24,31 +24,20 @@ public class CustomObjectRenderer {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderCustomObjects(RenderWorldLastEvent event) {
|
public void renderCustomObjects(RenderWorldLastEvent event) {
|
||||||
if(!ReplayHandler.isInReplay() || mc.getRenderViewEntity() == null) return;
|
if(!ReplayHandler.isInReplay() || mc.getRenderViewEntity() == null || ReplayHandler.getCustomImageObjects().isEmpty()) return;
|
||||||
|
|
||||||
double dX = mc.getRenderViewEntity().lastTickPosX + (mc.getRenderViewEntity().posX - mc.getRenderViewEntity().lastTickPosX) * (double)event.partialTicks;
|
double dX = mc.getRenderViewEntity().lastTickPosX + (mc.getRenderViewEntity().posX - mc.getRenderViewEntity().lastTickPosX) * (double)event.partialTicks;
|
||||||
double dY = mc.getRenderViewEntity().lastTickPosY + (mc.getRenderViewEntity().posY - mc.getRenderViewEntity().lastTickPosY) * (double)event.partialTicks;
|
double dY = mc.getRenderViewEntity().lastTickPosY + (mc.getRenderViewEntity().posY - mc.getRenderViewEntity().lastTickPosY) * (double)event.partialTicks;
|
||||||
double dZ = mc.getRenderViewEntity().lastTickPosZ + (mc.getRenderViewEntity().posZ - mc.getRenderViewEntity().lastTickPosZ) * (double)event.partialTicks;
|
double dZ = mc.getRenderViewEntity().lastTickPosZ + (mc.getRenderViewEntity().posZ - mc.getRenderViewEntity().lastTickPosZ) * (double)event.partialTicks;
|
||||||
|
|
||||||
GlStateManager.pushAttrib();
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
|
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
GlStateManager.disableLighting();
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.enableDepth();
|
|
||||||
|
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
for(CustomImageObject object : ReplayHandler.getCustomImageObjects()) {
|
for(CustomImageObject object : ReplayHandler.getCustomImageObjects()) {
|
||||||
drawCustomImageObject(dX, dY, dZ, object);
|
drawCustomImageObject(dX, dY, dZ, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.enableLighting();
|
|
||||||
GlStateManager.disableBlend();
|
|
||||||
GlStateManager.popAttrib();
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawCustomImageObject(double playerX, double playerY, double playerZ, CustomImageObject customImageObject) {
|
private void drawCustomImageObject(double playerX, double playerY, double playerZ, CustomImageObject customImageObject) {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package eu.crushedpixel.replaymod.renderer;
|
|||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.events.KeyframesModifyEvent;
|
import eu.crushedpixel.replaymod.events.KeyframesModifyEvent;
|
||||||
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
|
||||||
import eu.crushedpixel.replaymod.holders.Keyframe;
|
|
||||||
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
import eu.crushedpixel.replaymod.holders.AdvancedPosition;
|
||||||
|
import eu.crushedpixel.replaymod.holders.Keyframe;
|
||||||
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
|
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
|
||||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -44,9 +44,6 @@ public class PathPreviewRenderer {
|
|||||||
double doubleY = entity.posY;
|
double doubleY = entity.posY;
|
||||||
double doubleZ = entity.posZ;
|
double doubleZ = entity.posZ;
|
||||||
|
|
||||||
GlStateManager.pushAttrib();
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
|
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
GlStateManager.disableTexture2D();
|
GlStateManager.disableTexture2D();
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
@@ -87,6 +84,7 @@ public class PathPreviewRenderer {
|
|||||||
|
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
GlStateManager.blendFunc(GL11.GL_DST_COLOR, GL11.GL_SRC_COLOR);
|
GlStateManager.blendFunc(GL11.GL_DST_COLOR, GL11.GL_SRC_COLOR);
|
||||||
|
|
||||||
GlStateManager.disableDepth();
|
GlStateManager.disableDepth();
|
||||||
|
|
||||||
for(Keyframe<AdvancedPosition> kf : distanceSorted) {
|
for(Keyframe<AdvancedPosition> kf : distanceSorted) {
|
||||||
@@ -102,13 +100,7 @@ public class PathPreviewRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.disableAlpha();
|
|
||||||
GlStateManager.disableTexture2D();
|
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.enableLighting();
|
|
||||||
|
|
||||||
GlStateManager.popAttrib();
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -138,6 +130,8 @@ public class PathPreviewRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawConnection(double playerX, double playerY, double playerZ, AdvancedPosition pos1, AdvancedPosition pos2, int color) {
|
private void drawConnection(double playerX, double playerY, double playerZ, AdvancedPosition pos1, AdvancedPosition pos2, int color) {
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
WorldRenderer renderer = tessellator.getWorldRenderer();
|
WorldRenderer renderer = tessellator.getWorldRenderer();
|
||||||
|
|
||||||
@@ -158,6 +152,8 @@ public class PathPreviewRenderer {
|
|||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
renderer.setTranslation(0, 0, 0);
|
renderer.setTranslation(0, 0, 0);
|
||||||
|
|
||||||
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawPoint(double playerX, double playerY, double playerZ, Keyframe<AdvancedPosition> kf) {
|
private void drawPoint(double playerX, double playerY, double playerZ, Keyframe<AdvancedPosition> kf) {
|
||||||
@@ -298,7 +294,6 @@ public class PathPreviewRenderer {
|
|||||||
renderer.addVertexWithUV(x + cubeSize, y + cubeSize, z, 2 * 8 / 64f, 0);
|
renderer.addVertexWithUV(x + cubeSize, y + cubeSize, z, 2 * 8 / 64f, 0);
|
||||||
|
|
||||||
Tessellator.getInstance().draw();
|
Tessellator.getInstance().draw();
|
||||||
|
|
||||||
renderer.setTranslation(0, 0, 0);
|
renderer.setTranslation(0, 0, 0);
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|||||||
Reference in New Issue
Block a user