Skip to content

Commit 9915641

Browse files
committed
Stop using deprecated GlStateManager in PanelStudio-MC17
1 parent 0299801 commit 9915641

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

panelstudio-mc17/src/main/java/com/lukflug/panelstudio/mc17/GLInterface.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.lwjgl.opengl.GL11;
1919

2020
import com.lukflug.panelstudio.base.IInterface;
21-
import com.mojang.blaze3d.platform.GlStateManager;
2221
import com.mojang.blaze3d.platform.TextureUtil;
2322
import com.mojang.blaze3d.systems.RenderSystem;
2423

@@ -181,14 +180,14 @@ public void drawImage (Rectangle r, int rotation, boolean parity, int image, Col
181180
RenderSystem.setShaderTexture(0,image);
182181
Tessellator tessellator = Tessellator.getInstance();
183182
BufferBuilder bufferbuilder = tessellator.getBuffer();
184-
GlStateManager._enableTexture();
183+
RenderSystem.enableTexture();
185184
bufferbuilder.begin(DrawMode.QUADS,VertexFormats.POSITION_COLOR_TEXTURE);
186185
bufferbuilder.vertex(r.x,r.y+r.height,getZLevel()).color(color.getRed()/255.0f,color.getGreen()/255.0f,color.getBlue()/255.0f,color.getAlpha()/255.0f).texture(texCoords[0][0],texCoords[0][1]).next();
187186
bufferbuilder.vertex(r.x+r.width,r.y+r.height,getZLevel()).color(color.getRed()/255.0f,color.getGreen()/255.0f,color.getBlue()/255.0f,color.getAlpha()/255.0f).texture(texCoords[1][0],texCoords[1][1]).next();
188187
bufferbuilder.vertex(r.x+r.width,r.y,getZLevel()).color(color.getRed()/255.0f,color.getGreen()/255.0f,color.getBlue()/255.0f,color.getAlpha()/255.0f).texture(texCoords[2][0],texCoords[2][1]).next();
189188
bufferbuilder.vertex(r.x,r.y,getZLevel()).color(color.getRed()/255.0f,color.getGreen()/255.0f,color.getBlue()/255.0f,color.getAlpha()/255.0f).texture(texCoords[3][0],texCoords[3][1]).next();
190189
tessellator.draw();
191-
GlStateManager._disableTexture();
190+
RenderSystem.disableTexture();
192191
}
193192

194193
/**
@@ -197,17 +196,15 @@ public void drawImage (Rectangle r, int rotation, boolean parity, int image, Col
197196
*/
198197
protected void scissor (Rectangle r) {
199198
if (r==null) {
200-
GL11.glScissor(0,0,0,0);
201-
GL11.glEnable(GL11.GL_SCISSOR_TEST);
199+
RenderSystem.enableScissor(0,0,0,0);
202200
return;
203201
}
204202
Point a=guiToScreen(r.getLocation()),b=guiToScreen(new Point(r.x+r.width,r.y+r.height));
205203
if (!clipX) {
206204
a.x=0;
207-
b.x=MinecraftClient.getInstance().getWindow().getWidth();
205+
b.x=MinecraftClient.getInstance().getWindow().getFramebufferWidth();
208206
}
209-
GL11.glScissor(Math.min(a.x,b.x),Math.min(a.y,b.y),Math.abs(b.x-a.x),Math.abs(b.y-a.y));
210-
GL11.glEnable(GL11.GL_SCISSOR_TEST);
207+
RenderSystem.enableScissor(Math.min(a.x,b.x),Math.min(a.y,b.y),Math.abs(b.x-a.x),Math.abs(b.y-a.y));
211208
}
212209

213210
@Override
@@ -242,7 +239,7 @@ public void window (Rectangle r) {
242239
public void restore() {
243240
if (!clipRect.isEmpty()) {
244241
clipRect.pop();
245-
if (clipRect.isEmpty()) GL11.glDisable(GL11.GL_SCISSOR_TEST);
242+
if (clipRect.isEmpty()) RenderSystem.disableScissor();
246243
else scissor(clipRect.peek());
247244
}
248245
}
@@ -266,7 +263,7 @@ public Point screenToGui (Point p) {
266263
public Point guiToScreen (Point p) {
267264
double resX=getScreenWidth();
268265
double resY=getScreenHeight();
269-
return new Point((int)Math.round(p.x*MinecraftClient.getInstance().getWindow().getWidth()/resX),(int)Math.round((resY-p.y)*MinecraftClient.getInstance().getWindow().getHeight()/resY));
266+
return new Point((int)Math.round(p.x*MinecraftClient.getInstance().getWindow().getFramebufferWidth()/resX),(int)Math.round((resY-p.y)*MinecraftClient.getInstance().getWindow().getFramebufferHeight()/resY));
270267
}
271268

272269
/**

0 commit comments

Comments
 (0)