1
0
Fork 0

Revert "experimental new rendering"

This reverts commit 2006e31a71.
This commit is contained in:
Sen 2025-08-30 22:33:55 +02:00
parent 2006e31a71
commit 82b57873c2
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
96 changed files with 3105 additions and 1659 deletions

View file

@ -30,7 +30,7 @@ import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL46C;
import org.lwjgl.opengl.GL46;
import client.audio.AudioInterface;
import client.audio.MidiBank;
@ -428,8 +428,8 @@ public class Client implements IThreadListener {
Client.this.renderer.checkBlockLight(pos);
}
public int getWorldLight(BlockPos pos) {
return Client.this.renderer.getWorldLight(pos);
public int getCombinedLight(BlockPos pos) {
return Client.this.renderer.getCombinedLight(pos);
}
}
@ -889,21 +889,20 @@ public class Client implements IThreadListener {
this.textureManager = new TextureManager();
this.textureManager.onReload();
this.soundManager = new SoundManager(this);
Log.RENDER.debug("Maximale Anisotropie: %.1f", this.anisotropyMax = GL46C.glGetFloat(GL46C.GL_MAX_TEXTURE_MAX_ANISOTROPY));
Log.RENDER.debug("Maximale Texturgröße: %d", GL46C.glGetInteger(GL46C.GL_MAX_TEXTURE_SIZE));
// GlState.enableTexture2D();
// GlState.shadeModel(GL46C.GL_SMOOTH);
GL46C.glActiveTexture(GL46C.GL_TEXTURE0);
GL46C.glClearDepth(1.0D);
// GlState.enableDepth();
GlState.depthFunc(GL46C.GL_LEQUAL);
// GlState.enableAlpha();
// GlState.alphaFunc(GL46C.GL_GREATER, 0.1F);
GlState.cullFace(GL46C.GL_BACK);
// GlState.enableCull();
// GL46C.glMatrixMode(GL46C.GL_PROJECTION);
// GL46C.glLoadIdentity();
// GL46C.glMatrixMode(GL46C.GL_MODELVIEW);
Log.RENDER.debug("Maximale Anisotropie: %.1f", this.anisotropyMax = GL46.glGetFloat(GL46.GL_MAX_TEXTURE_MAX_ANISOTROPY));
Log.RENDER.debug("Maximale Texturgröße: %d", GL46.glGetInteger(GL46.GL_MAX_TEXTURE_SIZE));
GlState.enableTexture2D();
GlState.shadeModel(GL46.GL_SMOOTH);
GL46.glClearDepth(1.0D);
GlState.enableDepth();
GlState.depthFunc(GL46.GL_LEQUAL);
GlState.enableAlpha();
GlState.alphaFunc(GL46.GL_GREATER, 0.1F);
GlState.cullFace(GL46.GL_BACK);
GlState.enableCull();
GL46.glMatrixMode(GL46.GL_PROJECTION);
GL46.glLoadIdentity();
GL46.glMatrixMode(GL46.GL_MODELVIEW);
this.textureMap = new TextureMap();
this.textureManager.loadTexture(TextureMap.BLOCKS, this.textureMap);
this.updateTexture();
@ -1132,13 +1131,13 @@ public class Client implements IThreadListener {
}
public void render() {
GlState.tryBlendFuncSeparate(GL46C.GL_SRC_ALPHA, GL46C.GL_ONE_MINUS_SRC_ALPHA, GL46C.GL_SRC_ALPHA, GL46C.GL_ONE_MINUS_SRC_ALPHA);
GlState.tryBlendFuncSeparate(GL46.GL_SRC_ALPHA, GL46.GL_ONE_MINUS_SRC_ALPHA, GL46.GL_SRC_ALPHA, GL46.GL_ONE_MINUS_SRC_ALPHA);
GlState.enableDepth();
GlState.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
GL46C.glClear(GL46C.GL_COLOR_BUFFER_BIT | GL46C.GL_DEPTH_BUFFER_BIT);
GL46.glClear(GL46.GL_COLOR_BUFFER_BIT | GL46.GL_DEPTH_BUFFER_BIT);
if(this.wireframe) {
GL46C.glLineWidth(1.0f);
GL46C.glPolygonMode(GL46C.GL_FRONT_AND_BACK, GL46C.GL_LINE);
GL46.glLineWidth(1.0f);
GL46.glPolygonMode(GL46.GL_FRONT_AND_BACK, GL46.GL_LINE);
}
if(this.open == null) {
if(this.player != null && this.viewEntity == this.player)
@ -1151,18 +1150,18 @@ public class Client implements IThreadListener {
this.soundManager.setListener(this.player, (float)this.tickFraction);
if(this.player != null && (this.player.isEntityInsideOpaqueBlock() || this.viewEntity != this.player))
this.thirdPersonView = 0;
// GL46C.glPushMatrix();
GL46C.glClear(GL46C.GL_COLOR_BUFFER_BIT | GL46C.GL_DEPTH_BUFFER_BIT);
// GlState.enableTexture2D();
GL46.glPushMatrix();
GL46.glClear(16640);
GlState.enableTexture2D();
if(this.world != null)
this.renderer.renderWorld((float)this.tickFraction, System.nanoTime() - this.tickStart);
// GL46C.glPopMatrix();
//
// GlState.disableTexture2D();
GL46.glPopMatrix();
GlState.disableTexture2D();
GlState.disableCull();
GlState.enableBlend();
if(this.wireframe)
GL46C.glPolygonMode(GL46C.GL_FRONT_AND_BACK, GL46C.GL_FILL);
GL46.glPolygonMode(GL46.GL_FRONT_AND_BACK, GL46.GL_FILL);
}
private int drawStat(int x, int y, String name, int value, int max, int color) {
@ -1180,23 +1179,6 @@ public class Client implements IThreadListener {
Drawing.drawGradient(x + 2, y + 20 + 2, (int)(246.0f * fill), 6, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
return y + 40;
}
private boolean isVisionObscured() {
if(this.player.isEntityInsideOpaqueBlock()) {
State state = this.world.getState(new BlockPos(this.player));
for(int i = 0; i < 8; ++i) {
double d0 = this.player.posX + (double)(((float)((i >> 0) % 2) - 0.5F) * this.player.width * 0.8F);
double d1 = this.player.posY + (double)(((float)((i >> 1) % 2) - 0.5F) * 0.1F);
double d2 = this.player.posZ + (double)(((float)((i >> 2) % 2) - 0.5F) * this.player.width * 0.8F);
BlockPos blockpos = new BlockPos(d0, d1 + (double)this.player.getEyeHeight(), d2);
State bstate = this.world.getState(blockpos);
if(bstate.getBlock().isVisuallyOpaque())
state = bstate;
}
return state.getBlock() != Blocks.air;
}
return false;
}
public void renderHud() {
final int selected = this.world != null && this.player != null && this.viewEntity == this.player ? this.player.getSelectedIndex() : -1;
@ -1207,13 +1189,11 @@ public class Client implements IThreadListener {
final int by = this.fbY - 20 * scale;
final int xoff = (this.fbX / scale - (width < 20 ? ((size - 2) * width + 40 + width / 2) : (size * 20 - 2))) / 2 + (width < 20 && selected == 0 ? 20 - width : 0) - 2;
this.setupOverlay();
if(this.world != null && this.player != null && this.viewEntity == this.player && this.isVisionObscured())
Drawing.drawGradient(0, 0, this.fbX, this.fbY, 0xff2f2f2f, 0xff000000);
if(this.world != null && !(this.open instanceof GuiConsole) && this.player != null && this.viewEntity == this.player) {
if(this.open == null) {
if(this.thirdPersonView == 0) {
if(this.drawDebug) {
// this.renderWorldDirections((float)this.tickFraction);
this.renderWorldDirections((float)this.tickFraction);
}
else if(this.crosshairSize > 0) {
final int color = this.pointed != null && this.pointed.type != ObjectType.MISS ? this.crosshairColorTarget : this.crosshairColorBase;
@ -1222,8 +1202,8 @@ public class Client implements IThreadListener {
Drawing.drawRect(this.fbX / 2 - this.crosshairSize, this.fbY / 2 - 1, this.crosshairSize * 2, 2, color);
}
else {
// GlState.color(color);
// Drawing.drawTexturedRect(this, "textures/crosshair.png", 32, 32, this.fbX / 2 - 16, this.fbY / 2 - 16, 0, 0, 32, 32);
GlState.color(color);
Drawing.drawTexturedRect(this, "textures/crosshair.png", 32, 32, this.fbX / 2 - 16, this.fbY / 2 - 16, 0, 0, 32, 32);
}
}
}
@ -1377,61 +1357,61 @@ public class Client implements IThreadListener {
}
}
// GlState.bindTexture(0);
// GlState.setActiveTexture(GL46C.GL_TEXTURE0);
// GlState.enableTexture2D();
// if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
// GlState.enableRescaleNormal();
// GlState.enableBlend();
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
// ItemRenderer.enableGUIStandardItemLighting();
// GL46C.glPushMatrix();
// GL46C.glTranslatef(0.0f, (float)by, 0.0f);
// if(this.scaleHotbar)
// GL46C.glScalef(2.0f, 2.0f, 2.0f);
//
// int xPos = xoff;
// for(int index = 0; index < size; ++index) {
// ItemStack itemstack = this.player.getStackInSlot(index);
// if(itemstack != null) {
// if(width < 20 && selected != index && selected != index + 1 && index != size - 1) {
// this.scissor(xPos * scale, this.fbY - (by + 16 * scale), (width - 1) * scale, 16 * scale);
// GL46C.glEnable(GL46C.GL_SCISSOR_TEST);
// }
// GlState.enableDepth();
// this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, 0);
// if(width < 20 && selected != index && selected != index + 1 && index != size - 1)
// GL46C.glDisable(GL46C.GL_SCISSOR_TEST);
// }
// xPos += width >= 20 || selected == index || selected == index + 1 ? 20 : width;
// }
//
// if(this.infoOverlay) {
// Item item = null;
// if((this.pointed != null && this.pointed.type == ObjectType.BLOCK && this.pointed.block != null) || this.pointedLiquid != null)
// item = this.pointedLiquid != null ? (this.world.getState(this.pointedLiquid).getBlock() instanceof BlockLiquid liquid ? ItemBucket.getByFluid(liquid) : null) : this.world.getState(this.pointed.block).getBlock().getItem();
// else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null)
// item = this.pointed.entity.getItem();
// if(item != null) {
// GL46C.glPopMatrix();
// GL46C.glPushMatrix();
// GL46C.glTranslatef((float)(this.fbX / 2 - 180 + 4 + 1), (float)(this.hudMargin + 20 + 1), 0.0f);
// GL46C.glScalef(2.0f, 2.0f, 2.0f);
// GlState.enableDepth();
// this.renderItem.renderItemAndEffectIntoGUI(new ItemStack(item), 0, 0);
// }
// }
//
// GL46C.glPopMatrix();
// ItemRenderer.disableStandardItemLighting();
// GlState.disableRescaleNormal();
// GlState.disableBlend();
// }
//
// GlState.disableTexture2D();
// GlState.disableCull();
// GlState.enableBlend();
// GlState.disableDepth();
GlState.bindTexture(0);
GlState.setActiveTexture(GL46.GL_TEXTURE0);
GlState.enableTexture2D();
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
GlState.enableRescaleNormal();
GlState.enableBlend();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
ItemRenderer.enableGUIStandardItemLighting();
GL46.glPushMatrix();
GL46.glTranslatef(0.0f, (float)by, 0.0f);
if(this.scaleHotbar)
GL46.glScalef(2.0f, 2.0f, 2.0f);
int xPos = xoff;
for(int index = 0; index < size; ++index) {
ItemStack itemstack = this.player.getStackInSlot(index);
if(itemstack != null) {
if(width < 20 && selected != index && selected != index + 1 && index != size - 1) {
this.scissor(xPos * scale, this.fbY - (by + 16 * scale), (width - 1) * scale, 16 * scale);
GL46.glEnable(GL46.GL_SCISSOR_TEST);
}
GlState.enableDepth();
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, 0);
if(width < 20 && selected != index && selected != index + 1 && index != size - 1)
GL46.glDisable(GL46.GL_SCISSOR_TEST);
}
xPos += width >= 20 || selected == index || selected == index + 1 ? 20 : width;
}
if(this.infoOverlay) {
Item item = null;
if((this.pointed != null && this.pointed.type == ObjectType.BLOCK && this.pointed.block != null) || this.pointedLiquid != null)
item = this.pointedLiquid != null ? (this.world.getState(this.pointedLiquid).getBlock() instanceof BlockLiquid liquid ? ItemBucket.getByFluid(liquid) : null) : this.world.getState(this.pointed.block).getBlock().getItem();
else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null)
item = this.pointed.entity.getItem();
if(item != null) {
GL46.glPopMatrix();
GL46.glPushMatrix();
GL46.glTranslatef((float)(this.fbX / 2 - 180 + 4 + 1), (float)(this.hudMargin + 20 + 1), 0.0f);
GL46.glScalef(2.0f, 2.0f, 2.0f);
GlState.enableDepth();
this.renderItem.renderItemAndEffectIntoGUI(new ItemStack(item), 0, 0);
}
}
GL46.glPopMatrix();
ItemRenderer.disableStandardItemLighting();
GlState.disableRescaleNormal();
GlState.disableBlend();
}
GlState.disableTexture2D();
GlState.disableCull();
GlState.enableBlend();
GlState.disableDepth();
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
int xPos = xoff * scale;
for(int index = 0; index < size; ++index) {
@ -1491,8 +1471,8 @@ public class Client implements IThreadListener {
"Tickrate: %s%.2f" + Color.RESET + " %s [" + Color.GREEN + "%.1f" + Color.RESET + "], %.3f ms, E %d ms" +
"%s%s"
,
GL46C.glGetString(GL46C.GL_VERSION),
GL46C.glGetString(GL46C.GL_RENDERER), GL46C.glGetString(GL46C.GL_VENDOR),
GL46.glGetString(GL46.GL_VERSION),
GL46.glGetString(GL46.GL_RENDERER), GL46.glGetString(GL46.GL_VENDOR),
this.framecode(), this.framerate < 1.0f ? 1.0f / this.framerate : this.framerate, this.framerate < 1.0f ? "SPF" : "FPS",
this.vsync ? Color.DARK_GRAY + "VSYNC" : (this.syncLimited ? Color.GREEN + "" + this.syncLimit : Color.RED + "UNL"),
(float)PerfSection.getTotal(false) / 1000.0f, this.fbRawX, this.fbRawY,
@ -2178,7 +2158,7 @@ public class Client implements IThreadListener {
}
private void fbsize(int x, int y) {
GL46C.glViewport(0, 0, x, y);
GL46.glViewport(0, 0, x, y);
this.fbRawX = x;
this.fbRawY = y;
this.rescale();
@ -2360,19 +2340,23 @@ public class Client implements IThreadListener {
}
public void setupOverlay() {
// GlState.disableCull();
// GlState.disableDepth();
// GlState.enableBlend();
// GlState.tryBlendFuncSeparate(GL46C.GL_SRC_ALPHA, GL46C.GL_ONE_MINUS_SRC_ALPHA, GL46C.GL_ONE, GL46C.GL_ONE_MINUS_SRC_ALPHA);
GL46C.glClear(GL46C.GL_DEPTH_BUFFER_BIT);
// GL46C.glOrtho(0.0D, (double)this.fbRawX, (double)this.fbRawY, 0.0D, 1000.0D, 3000.0D);
// GL46C.glTranslatef(0.0F, 0.0F, -2000.0F);
// if(this.scale != 1)
// GL46C.glScalef((float)this.scale, (float)this.scale, 1.0f);
GlState.disableDepth();
GlState.tryBlendFuncSeparate(GL46.GL_SRC_ALPHA, GL46.GL_ONE_MINUS_SRC_ALPHA, GL46.GL_ONE, GL46.GL_ONE_MINUS_SRC_ALPHA);
GlState.setActiveTexture(GL46.GL_TEXTURE0);
GlState.color(1.0f, 1.0f, 1.0f, 1.0f);
GL46.glClear(256);
GL46.glMatrixMode(GL46.GL_PROJECTION);
GL46.glLoadIdentity();
GL46.glOrtho(0.0D, (double)this.fbRawX, (double)this.fbRawY, 0.0D, 1000.0D, 3000.0D);
GL46.glMatrixMode(GL46.GL_MODELVIEW);
GL46.glLoadIdentity();
GL46.glTranslatef(0.0F, 0.0F, -2000.0F);
if(this.scale != 1)
GL46.glScalef((float)this.scale, (float)this.scale, 1.0f);
}
public void scissor(int x, int y, int width, int height) {
GL46C.glScissor(x * this.scale, y * this.scale, width * this.scale, height * this.scale);
GL46.glScissor(x * this.scale, y * this.scale, width * this.scale, height * this.scale);
}
private void addFrame(long runningTime)
@ -2416,9 +2400,9 @@ public class Client implements IThreadListener {
Window.destroyWindow();
Util.panic("Inkompatible OpenGL-Version", "OpenGL 4.6 oder höher ist erforderlich, um dieses Programm auszuführen.");
}
Log.SYSTEM.info("OpenGL %s", GL46C.glGetString(GL46C.GL_VERSION));
Log.SYSTEM.info("GL_VENDOR: %s", GL46C.glGetString(GL46C.GL_VENDOR));
Log.SYSTEM.info("GL_RENDERER: %s", GL46C.glGetString(GL46C.GL_RENDERER));
Log.SYSTEM.info("OpenGL %s", GL46.glGetString(GL46.GL_VERSION));
Log.SYSTEM.info("GL_VENDOR: %s", GL46.glGetString(GL46.GL_VENDOR));
Log.SYSTEM.info("GL_RENDERER: %s", GL46.glGetString(GL46.GL_RENDERER));
Log.SYSTEM.info("Starte ...");
this.init();
@ -2427,8 +2411,8 @@ public class Client implements IThreadListener {
System.gc();
Font.loadFonts();
Font.select(this.font);
// GlState.enableBlend();
// GlState.blendFunc(GL46C.GL_SRC_ALPHA, GL46C.GL_ONE_MINUS_SRC_ALPHA);
GlState.enableBlend();
GlState.blendFunc(GL46.GL_SRC_ALPHA, GL46.GL_ONE_MINUS_SRC_ALPHA);
this.initConsole();
Shader.loadShaders();
this.startSound(true);
@ -2459,6 +2443,7 @@ public class Client implements IThreadListener {
Bind.updateBinds();
this.input();
Bind.enableInput();
GlState.setActiveTexture(GL46.GL_TEXTURE0);
GlState.bindTexture(0);
this.inputGui();
if(this.open != null)
@ -2475,7 +2460,7 @@ public class Client implements IThreadListener {
this.finish();
PerfSection.SWAP.enter();
if(this.glFlush)
GL46C.glFlush();
GL46.glFlush();
Window.swapBuffers();
PerfSection.EVENTS.enter();
Log.flushLog();
@ -2570,7 +2555,7 @@ public class Client implements IThreadListener {
this.saving = true;
final int stride = ((this.fbRawX * 3) & 3) != 0 ? 4 + ((this.fbRawX * 3) & ~3) : (this.fbRawX * 3);
final ByteBuffer data = ByteBuffer.allocateDirect(stride * this.fbRawY).order(ByteOrder.nativeOrder());
GL46C.glReadPixels(0, 0, this.fbRawX, this.fbRawY, GL46C.GL_RGB, GL46C.GL_UNSIGNED_BYTE, data);
GL46.glReadPixels(0, 0, this.fbRawX, this.fbRawY, GL46.GL_RGB, GL46.GL_UNSIGNED_BYTE, data);
new Thread(new Runnable() {
public void run() {
byte[] pixels = new byte[stride * Client.this.fbRawY];
@ -3308,23 +3293,23 @@ public class Client implements IThreadListener {
}
}
// private void renderWorldDirections(float partialTicks) {
// GlState.enableBlend();
// GlState.tryBlendFuncSeparate(GL46C.GL_SRC_ALPHA, GL46C.GL_ONE_MINUS_SRC_ALPHA, GL46C.GL_ONE, GL46C.GL_ZERO);
// GL46C.glLineWidth(1.0F);
// GlState.disableTexture2D();
// GlState.depthMask(false);
// GL46C.glPushMatrix();
// GL46C.glTranslatef((float)(this.fbX / 2), (float)(this.fbY / 2), 0.0F);
// this.renderer.rotateCamera(this.viewEntity, partialTicks, true);
// Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 24D, 1D, 1D), 255, 0, 0, 255);
// Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, 1D, 24D), 0, 0, 255, 255);
// Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, -20D, 1D), 0, 255, 0, 255);
// GL46C.glPopMatrix();
// GlState.depthMask(true);
// GlState.enableTexture2D();
// GlState.disableBlend();
// }
private void renderWorldDirections(float partialTicks) {
GlState.enableBlend();
GlState.tryBlendFuncSeparate(GL46.GL_SRC_ALPHA, GL46.GL_ONE_MINUS_SRC_ALPHA, GL46.GL_ONE, GL46.GL_ZERO);
GL46.glLineWidth(1.0F);
GlState.disableTexture2D();
GlState.depthMask(false);
GL46.glPushMatrix();
GL46.glTranslatef((float)(this.fbX / 2), (float)(this.fbY / 2), 0.0F);
this.renderer.rotateCamera(this.viewEntity, partialTicks, true);
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 24D, 1D, 1D), 255, 0, 0, 255);
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, 1D, 24D), 0, 0, 255, 255);
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, -20D, 1D), 0, 255, 0, 255);
GL46.glPopMatrix();
GlState.depthMask(true);
GlState.enableTexture2D();
GlState.disableBlend();
}
private int blendColors(int color1, int color2, float value) {
int i = color1 >> 24 & 255;