inline OpenGL functions to lwjgl GLxx

This commit is contained in:
Sen 2025-03-18 10:24:05 +01:00
parent 783adb350b
commit a2ffb2991d
90 changed files with 1008 additions and 1204 deletions

View file

@ -21,7 +21,6 @@ import game.renderer.entity.RenderNpc;
import game.renderer.texture.TextureAtlasSprite;
import game.renderer.texture.TextureMap;
import game.util.ExtMath;
import game.window.WCF;
import game.world.BlockPos;
import game.world.State;
import game.world.Vec3;
@ -58,11 +57,11 @@ public class ItemRenderer
public static void enableGUIStandardItemLighting()
{
WCF.glPushMatrix();
WCF.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F);
WCF.glRotatef(165.0F, 1.0F, 0.0F, 0.0F);
GL11.glPushMatrix();
GL11.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(165.0F, 1.0F, 0.0F, 0.0F);
enableStandardItemLighting();
WCF.glPopMatrix();
GL11.glPopMatrix();
}
public static void enableStandardItemLighting()
@ -75,18 +74,18 @@ public class ItemRenderer
float f = 0.4F;
float f1 = 0.6F;
float f2 = 0.0F;
WCF.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, setColorBuffer(
(float)LIGHT0_POS.xCoord, (float)LIGHT0_POS.yCoord, (float)LIGHT0_POS.zCoord, 0.0f));
WCF.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, setColorBuffer(f1, f1, f1, 1.0F));
WCF.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
WCF.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, setColorBuffer(f2, f2, f2, 1.0F));
WCF.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, setColorBuffer(
(float)LIGHT1_POS.xCoord, (float)LIGHT1_POS.yCoord, (float)LIGHT1_POS.zCoord, 0.0f));
WCF.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, setColorBuffer(f1, f1, f1, 1.0F));
WCF.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
WCF.glLight(GL11.GL_LIGHT1, GL11.GL_SPECULAR, setColorBuffer(f2, f2, f2, 1.0F));
GL11.glLightfv(GL11.GL_LIGHT0, GL11.GL_POSITION, setColorBuffer(
(float)LIGHT0_POS.xCoord, (float)LIGHT0_POS.yCoord, (float)LIGHT0_POS.zCoord, 0.0f));
GL11.glLightfv(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, setColorBuffer(f1, f1, f1, 1.0F));
GL11.glLightfv(GL11.GL_LIGHT0, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glLightfv(GL11.GL_LIGHT0, GL11.GL_SPECULAR, setColorBuffer(f2, f2, f2, 1.0F));
GL11.glLightfv(GL11.GL_LIGHT1, GL11.GL_POSITION, setColorBuffer(
(float)LIGHT1_POS.xCoord, (float)LIGHT1_POS.yCoord, (float)LIGHT1_POS.zCoord, 0.0f));
GL11.glLightfv(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, setColorBuffer(f1, f1, f1, 1.0F));
GL11.glLightfv(GL11.GL_LIGHT1, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GL11.glLightfv(GL11.GL_LIGHT1, GL11.GL_SPECULAR, setColorBuffer(f2, f2, f2, 1.0F));
GlState.shadeModel(7424);
WCF.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, setColorBuffer(f, f, f, 1.0F));
GL11.glLightModelfv(GL11.GL_LIGHT_MODEL_AMBIENT, setColorBuffer(f, f, f, 1.0F));
}
public static void disableStandardItemLighting()
@ -111,11 +110,11 @@ public class ItemRenderer
Item item = heldStack.getItem();
if(item.isFirstPerson() || transform != Transforms.Camera.FIRST_PERSON) {
Block block = item.getBlock();
WCF.glPushMatrix();
GL11.glPushMatrix();
if (this.itemRenderer.shouldRenderItemIn3D(heldStack))
{
WCF.glScalef(2.0F, 2.0F, 2.0F);
GL11.glScalef(2.0F, 2.0F, 2.0F);
if (this.isBlockTranslucent(block))
{
@ -130,7 +129,7 @@ public class ItemRenderer
GlState.depthMask(true);
}
WCF.glPopMatrix();
GL11.glPopMatrix();
}
}
}
@ -150,11 +149,11 @@ public class ItemRenderer
*/
private void rotateArroundXAndY(float angle, float angleY)
{
WCF.glPushMatrix();
WCF.glRotatef(angle, 1.0F, 0.0F, 0.0F);
WCF.glRotatef(angleY, 0.0F, 1.0F, 0.0F);
GL11.glPushMatrix();
GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(angleY, 0.0F, 1.0F, 0.0F);
ItemRenderer.enableStandardItemLighting();
WCF.glPopMatrix();
GL11.glPopMatrix();
}
/**
@ -165,7 +164,7 @@ public class ItemRenderer
int i = this.gm.theWorld.getCombinedLight(new BlockPos(clientPlayer.posX, clientPlayer.posY + (double)clientPlayer.getEyeHeight(), clientPlayer.posZ), 0);
float f = (float)(i & 65535);
float f1 = (float)(i >> 16);
WCF.glMultiTexCoord2f(GL13.GL_TEXTURE1, f, f1);
GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, f, f1);
}
/**
@ -175,8 +174,8 @@ public class ItemRenderer
{
float f = entityplayerspIn.prevRenderArmPitch + (entityplayerspIn.renderArmPitch - entityplayerspIn.prevRenderArmPitch) * partialTicks;
float f1 = entityplayerspIn.prevRenderArmYaw + (entityplayerspIn.renderArmYaw - entityplayerspIn.prevRenderArmYaw) * partialTicks;
WCF.glRotatef((entityplayerspIn.rotPitch - f) * 0.1F, 1.0F, 0.0F, 0.0F);
WCF.glRotatef((entityplayerspIn.rotYaw - f1) * 0.1F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef((entityplayerspIn.rotPitch - f) * 0.1F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef((entityplayerspIn.rotYaw - f1) * 0.1F, 0.0F, 1.0F, 0.0F);
}
/**
@ -283,21 +282,21 @@ public class ItemRenderer
float f = -0.3F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI);
float f1 = 0.4F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI * 2.0F);
float f2 = -0.4F * ExtMath.sin(swingProgress * (float)Math.PI);
WCF.glTranslatef(f, f1, f2);
WCF.glTranslatef(0.64000005F, -0.6F, -0.71999997F);
WCF.glTranslatef(0.0F, equipProgress * -0.6F, 0.0F);
WCF.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(f, f1, f2);
GL11.glTranslatef(0.64000005F, -0.6F, -0.71999997F);
GL11.glTranslatef(0.0F, equipProgress * -0.6F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
float f3 = ExtMath.sin(swingProgress * swingProgress * (float)Math.PI);
float f4 = ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI);
WCF.glRotatef(f4 * 70.0F, 0.0F, 1.0F, 0.0F);
WCF.glRotatef(f3 * -20.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(f4 * 70.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(f3 * -20.0F, 0.0F, 0.0F, 1.0F);
this.gm.getTextureManager().bindTexture(clientPlayer.getLocationSkin());
WCF.glTranslatef(-1.0F, 3.6F, 3.5F);
WCF.glRotatef(120.0F, 0.0F, 0.0F, 1.0F);
WCF.glRotatef(200.0F, 1.0F, 0.0F, 0.0F);
WCF.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
WCF.glScalef(1.0F, 1.0F, 1.0F);
WCF.glTranslatef(5.6F, 0.0F, 0.0F);
GL11.glTranslatef(-1.0F, 3.6F, 3.5F);
GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(1.0F, 1.0F, 1.0F);
GL11.glTranslatef(5.6F, 0.0F, 0.0F);
RenderNpc render = this.renderManager.getRenderObject(this.gm.thePlayer.getModel());
GlState.disableCull();
render.renderPlayerArm(this.gm.thePlayer);
@ -314,7 +313,7 @@ public class ItemRenderer
float f = -0.4F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI);
float f1 = 0.2F * ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI * 2.0F);
float f2 = -0.2F * ExtMath.sin(swingProgress * (float)Math.PI);
WCF.glTranslatef(f, f1, f2);
GL11.glTranslatef(f, f1, f2);
}
// /**
@ -346,15 +345,15 @@ public class ItemRenderer
*/
private void transformFirstPersonItem(float equipProgress, float swingProgress)
{
WCF.glTranslatef(0.56F, -0.52F, -0.71999997F);
WCF.glTranslatef(0.0F, equipProgress * -0.6F, 0.0F);
WCF.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(0.56F, -0.52F, -0.71999997F);
GL11.glTranslatef(0.0F, equipProgress * -0.6F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
float f = ExtMath.sin(swingProgress * swingProgress * (float)Math.PI);
float f1 = ExtMath.sin(ExtMath.sqrtf(swingProgress) * (float)Math.PI);
WCF.glRotatef(f * -20.0F, 0.0F, 1.0F, 0.0F);
WCF.glRotatef(f1 * -20.0F, 0.0F, 0.0F, 1.0F);
WCF.glRotatef(f1 * -80.0F, 1.0F, 0.0F, 0.0F);
WCF.glScalef(0.4F, 0.4F, 0.4F);
GL11.glRotatef(f * -20.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(f1 * -20.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(f1 * -80.0F, 1.0F, 0.0F, 0.0F);
GL11.glScalef(0.4F, 0.4F, 0.4F);
}
/**
@ -364,10 +363,10 @@ public class ItemRenderer
*/
private void doBowTransformations(float partialTicks, EntityNPC clientPlayer)
{
WCF.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F);
WCF.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F);
WCF.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F);
WCF.glTranslatef(-0.9F, 0.2F, 0.0F);
GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(-0.9F, 0.2F, 0.0F);
float f = (float)this.itemToRender.getMaxItemUseDuration() - ((float)clientPlayer.getItemInUseCount() - partialTicks + 1.0F);
float f1 = f / 20.0F;
f1 = (f1 * f1 + f1 * 2.0F) / 3.0F;
@ -382,11 +381,11 @@ public class ItemRenderer
float f2 = ExtMath.sin((f - 0.1F) * 1.3F);
float f3 = f1 - 0.1F;
float f4 = f2 * f3;
WCF.glTranslatef(f4 * 0.0F, f4 * 0.01F, f4 * 0.0F);
GL11.glTranslatef(f4 * 0.0F, f4 * 0.01F, f4 * 0.0F);
}
WCF.glTranslatef(f1 * 0.0F, f1 * 0.0F, f1 * 0.1F);
WCF.glScalef(1.0F, 1.0F, 1.0F + f1 * 0.2F);
GL11.glTranslatef(f1 * 0.0F, f1 * 0.0F, f1 * 0.1F);
GL11.glScalef(1.0F, 1.0F, 1.0F + f1 * 0.2F);
}
/**
@ -394,10 +393,10 @@ public class ItemRenderer
*/
private void doBlockTransformations()
{
WCF.glTranslatef(-0.5F, 0.2F, 0.0F);
WCF.glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
WCF.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F);
WCF.glRotatef(60.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, 0.2F, 0.0F);
GL11.glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F);
}
/**
@ -414,7 +413,7 @@ public class ItemRenderer
this.setLightMapFromPlayer(clientplayer);
this.rotateWithPlayerRotations(clientplayer, partialTicks);
GlState.enableRescaleNormal();
WCF.glPushMatrix();
GL11.glPushMatrix();
if (this.itemToRender != null)
{
@ -462,7 +461,7 @@ public class ItemRenderer
this.renderPlayerArm(clientplayer, f, f1);
}
WCF.glPopMatrix();
GL11.glPopMatrix();
GlState.disableRescaleNormal();
ItemRenderer.disableStandardItemLighting();
}
@ -519,7 +518,7 @@ public class ItemRenderer
RenderBuffer worldrenderer = Tessellator.getBuffer();
float f = 0.1F;
GlState.color(0.1F, 0.1F, 0.1F, 0.5F);
WCF.glPushMatrix();
GL11.glPushMatrix();
float f1 = -1.0F;
float f2 = 1.0F;
float f3 = -1.0F;
@ -535,7 +534,7 @@ public class ItemRenderer
worldrenderer.pos(1.0D, 1.0D, -0.5D).tex((double)f6, (double)f8).endVertex();
worldrenderer.pos(-1.0D, 1.0D, -0.5D).tex((double)f7, (double)f8).endVertex();
Tessellator.draw();
WCF.glPopMatrix();
GL11.glPopMatrix();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
}
@ -557,7 +556,7 @@ public class ItemRenderer
for (int i = 0; i < 2; ++i)
{
WCF.glPushMatrix();
GL11.glPushMatrix();
TextureAtlasSprite textureatlassprite = this.gm.getTextureMapBlocks().getAtlasSprite("blocks/fire_layer_1");
this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
float f1 = textureatlassprite.getMinU();
@ -569,15 +568,15 @@ public class ItemRenderer
float f7 = 0.0F - f / 2.0F;
float f8 = f7 + f;
float f9 = -0.5F;
WCF.glTranslatef((float)(-(i * 2 - 1)) * 0.24F, -0.3F, 0.0F);
WCF.glRotatef((float)(i * 2 - 1) * 10.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef((float)(-(i * 2 - 1)) * 0.24F, -0.3F, 0.0F);
GL11.glRotatef((float)(i * 2 - 1) * 10.0F, 0.0F, 1.0F, 0.0F);
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
worldrenderer.pos((double)f5, (double)f7, (double)f9).tex((double)f2, (double)f4).endVertex();
worldrenderer.pos((double)f6, (double)f7, (double)f9).tex((double)f1, (double)f4).endVertex();
worldrenderer.pos((double)f6, (double)f8, (double)f9).tex((double)f1, (double)f3).endVertex();
worldrenderer.pos((double)f5, (double)f8, (double)f9).tex((double)f2, (double)f3).endVertex();
Tessellator.draw();
WCF.glPopMatrix();
GL11.glPopMatrix();
}
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);