Change some client hooks to use GlStateManager functions (#5010)

This commit is contained in:
Ben Staddon 2018-07-05 03:59:12 +01:00 committed by mezz
parent c3aa99677a
commit 5624afbc32

View file

@ -22,14 +22,13 @@ package net.minecraftforge.client;
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.BOSSINFO; import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.BOSSINFO;
import static net.minecraftforge.common.ForgeVersion.Status.BETA; import static net.minecraftforge.common.ForgeVersion.Status.BETA;
import static net.minecraftforge.common.ForgeVersion.Status.BETA_OUTDATED; import static net.minecraftforge.common.ForgeVersion.Status.BETA_OUTDATED;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL20.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.vecmath.Matrix3f; import javax.vecmath.Matrix3f;
@ -126,8 +125,9 @@ import net.minecraftforge.fml.common.FMLLog;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.BufferUtils; import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import java.util.Optional;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
public class ForgeHooksClient public class ForgeHooksClient
@ -154,7 +154,7 @@ public class ForgeHooksClient
if (block != null && block.isBed(state, world, pos, entity)) if (block != null && block.isBed(state, world, pos, entity))
{ {
glRotatef((float)(block.getBedDirection(state, world, pos).getHorizontalIndex() * 90), 0.0F, 1.0F, 0.0F); GL11.glRotatef((float)(block.getBedDirection(state, world, pos).getHorizontalIndex() * 90), 0.0F, 1.0F, 0.0F);
} }
} }
@ -423,7 +423,7 @@ public class ForgeHooksClient
matrixBuf.put(t); matrixBuf.put(t);
} }
matrixBuf.flip(); matrixBuf.flip();
glMultMatrix(matrixBuf); GL11.glMultMatrix(matrixBuf);
} }
// moved and expanded from WorldVertexBufferUploader.draw // moved and expanded from WorldVertexBufferUploader.draw
@ -437,32 +437,32 @@ public class ForgeHooksClient
switch(attrType) switch(attrType)
{ {
case POSITION: case POSITION:
glVertexPointer(count, constant, stride, buffer); GlStateManager.glVertexPointer(count, constant, stride, buffer);
glEnableClientState(GL_VERTEX_ARRAY); GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY);
break; break;
case NORMAL: case NORMAL:
if(count != 3) if(count != 3)
{ {
throw new IllegalArgumentException("Normal attribute should have the size 3: " + attr); throw new IllegalArgumentException("Normal attribute should have the size 3: " + attr);
} }
glNormalPointer(constant, stride, buffer); GlStateManager.glNormalPointer(constant, stride, buffer);
glEnableClientState(GL_NORMAL_ARRAY); GlStateManager.glEnableClientState(GL11.GL_NORMAL_ARRAY);
break; break;
case COLOR: case COLOR:
glColorPointer(count, constant, stride, buffer); GlStateManager.glColorPointer(count, constant, stride, buffer);
glEnableClientState(GL_COLOR_ARRAY); GlStateManager.glEnableClientState(GL11.GL_COLOR_ARRAY);
break; break;
case UV: case UV:
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex()); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex());
glTexCoordPointer(count, constant, stride, buffer); GlStateManager.glTexCoordPointer(count, constant, stride, buffer);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
break; break;
case PADDING: case PADDING:
break; break;
case GENERIC: case GENERIC:
glEnableVertexAttribArray(attr.getIndex()); GL20.glEnableVertexAttribArray(attr.getIndex());
glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer); GL20.glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer);
default: default:
FMLLog.log.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName()); FMLLog.log.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName());
} }
@ -474,25 +474,25 @@ public class ForgeHooksClient
switch(attrType) switch(attrType)
{ {
case POSITION: case POSITION:
glDisableClientState(GL_VERTEX_ARRAY); GlStateManager.glDisableClientState(GL11.GL_VERTEX_ARRAY);
break; break;
case NORMAL: case NORMAL:
glDisableClientState(GL_NORMAL_ARRAY); GlStateManager.glDisableClientState(GL11.GL_NORMAL_ARRAY);
break; break;
case COLOR: case COLOR:
glDisableClientState(GL_COLOR_ARRAY); GlStateManager.glDisableClientState(GL11.GL_COLOR_ARRAY);
// is this really needed? // is this really needed?
GlStateManager.resetColor(); GlStateManager.resetColor();
break; break;
case UV: case UV:
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex()); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex());
glDisableClientState(GL_TEXTURE_COORD_ARRAY); GlStateManager.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
break; break;
case PADDING: case PADDING:
break; break;
case GENERIC: case GENERIC:
glDisableVertexAttribArray(attr.getIndex()); GL20.glDisableVertexAttribArray(attr.getIndex());
default: default:
FMLLog.log.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName()); FMLLog.log.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName());
} }