revert some rendering changes, fix colored lighting
This commit is contained in:
parent
4862b7c9b5
commit
02f3146aea
98 changed files with 1248 additions and 1332 deletions
|
@ -30,7 +30,7 @@ import javax.imageio.ImageIO;
|
|||
import javax.swing.JFileChooser;
|
||||
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL46;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
import client.audio.AudioInterface;
|
||||
import client.audio.MidiBank;
|
||||
|
@ -317,6 +317,12 @@ public class Client implements IThreadListener {
|
|||
Client.CLIENT.updateTexture();
|
||||
}
|
||||
}
|
||||
|
||||
public static class LightFunction implements FloatFunction {
|
||||
public void apply(FloatVar cv, float value) {
|
||||
Client.CLIENT.renderer.loadRenderers();
|
||||
}
|
||||
}
|
||||
|
||||
private interface DebugRunner {
|
||||
void execute(Keysym key);
|
||||
|
@ -485,6 +491,8 @@ public class Client implements IThreadListener {
|
|||
public boolean interrupted;
|
||||
public boolean freecam;
|
||||
public boolean servercam;
|
||||
public boolean shaders;
|
||||
public boolean mipmaps;
|
||||
|
||||
private int leftClickCounter;
|
||||
private int rightClickTimer;
|
||||
|
@ -701,12 +709,10 @@ public class Client implements IThreadListener {
|
|||
@Variable(name = "mid_visualizer", category = CVarCategory.SOUND, display = "Visualisation")
|
||||
public boolean midiVisualizer = true;
|
||||
|
||||
@Variable(name = "gl_light_blend", category = CVarCategory.RENDER, min = 0.0f, max = 1.0f, precision = 2, unit = "%", display = "Lichtüberdeckung")
|
||||
public float lightBlend = 0.5f;
|
||||
@Variable(name = "gl_tex_mipmaps", category = CVarCategory.RENDER, display = "Mipmaps", callback = MipmapFunction.class)
|
||||
private MipmapType mipmapType = MipmapType.LINEAR;
|
||||
private MipmapType mipmapType = MipmapType.NONE;
|
||||
@Variable(name = "gl_use_shader", category = CVarCategory.RENDER, display = "Shader verwenden")
|
||||
public boolean useShader = true;
|
||||
public boolean useShader = false;
|
||||
|
||||
public static final Client CLIENT = new Client();
|
||||
|
||||
|
@ -843,7 +849,8 @@ public class Client implements IThreadListener {
|
|||
Font.unloadFonts();
|
||||
Font.loadFonts();
|
||||
Font.select(this.font);
|
||||
Shader.loadShaders();
|
||||
if(this.shaders)
|
||||
Shader.loadShaders();
|
||||
this.textureManager.onReload();
|
||||
this.modelManager.onReload();
|
||||
this.renderItem.onReload();
|
||||
|
@ -859,19 +866,21 @@ public class Client implements IThreadListener {
|
|||
this.textureManager = new TextureManager();
|
||||
this.textureManager.onReload();
|
||||
this.soundManager = new SoundManager(this);
|
||||
Log.RENDER.debug("Maximale Texturgröße: %d", GL46.glGetInteger(GL46.GL_MAX_TEXTURE_SIZE));
|
||||
Log.RENDER.debug("Maximale Texturgröße: %d", GL15.glGetInteger(GL15.GL_MAX_TEXTURE_SIZE));
|
||||
Log.RENDER.debug("Shader verfügbar: %s", (this.shaders = GL.getCapabilities().OpenGL20) ? "Ja (OpenGL 2.0+)" : "Nein (OpenGL 1.5)");
|
||||
Log.RENDER.debug("Mipmaps verfügbar: %s", (this.mipmaps = GL.getCapabilities().OpenGL30) ? "Ja (OpenGL 3.0+)" : "Nein (OpenGL 1.5-2.1)");
|
||||
GlState.enableTexture2D();
|
||||
GlState.shadeModel(GL46.GL_SMOOTH);
|
||||
GL46.glClearDepth(1.0D);
|
||||
GlState.shadeModel(GL15.GL_SMOOTH);
|
||||
GL15.glClearDepth(1.0D);
|
||||
GlState.enableDepth();
|
||||
GlState.depthFunc(GL46.GL_LEQUAL);
|
||||
GlState.depthFunc(GL15.GL_LEQUAL);
|
||||
GlState.enableAlpha();
|
||||
GlState.alphaFunc(GL46.GL_GREATER, 0.1F);
|
||||
GlState.cullFace(GL46.GL_BACK);
|
||||
GlState.alphaFunc(GL15.GL_GREATER, 0.1F);
|
||||
GlState.cullFace(GL15.GL_BACK);
|
||||
GlState.enableCull();
|
||||
GL46.glMatrixMode(GL46.GL_PROJECTION);
|
||||
GL46.glLoadIdentity();
|
||||
GL46.glMatrixMode(GL46.GL_MODELVIEW);
|
||||
GL15.glMatrixMode(GL15.GL_PROJECTION);
|
||||
GL15.glLoadIdentity();
|
||||
GL15.glMatrixMode(GL15.GL_MODELVIEW);
|
||||
this.textureMap = new TextureMap();
|
||||
this.textureManager.loadTexture(TextureMap.BLOCKS, this.textureMap);
|
||||
this.updateTexture();
|
||||
|
@ -1000,7 +1009,7 @@ public class Client implements IThreadListener {
|
|||
{
|
||||
this.controller.update();
|
||||
}
|
||||
this.textureMap.update();
|
||||
this.textureMap.update(this.mipmaps && this.mipmapType != MipmapType.NONE);
|
||||
if (this.open != null)
|
||||
{
|
||||
this.open.updateScreen();
|
||||
|
@ -1100,13 +1109,13 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
|
||||
public void render() {
|
||||
GlState.tryBlendFuncSeparate(GL46.GL_SRC_ALPHA, GL46.GL_ONE_MINUS_SRC_ALPHA, GL46.GL_SRC_ALPHA, GL46.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlState.tryBlendFuncSeparate(GL15.GL_SRC_ALPHA, GL15.GL_ONE_MINUS_SRC_ALPHA, GL15.GL_SRC_ALPHA, GL15.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlState.enableDepth();
|
||||
GlState.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL46.glClear(GL46.GL_COLOR_BUFFER_BIT | GL46.GL_DEPTH_BUFFER_BIT);
|
||||
GL15.glClear(GL15.GL_COLOR_BUFFER_BIT | GL15.GL_DEPTH_BUFFER_BIT);
|
||||
if(this.wireframe) {
|
||||
GL46.glLineWidth(1.0f);
|
||||
GL46.glPolygonMode(GL46.GL_FRONT_AND_BACK, GL46.GL_LINE);
|
||||
GL15.glLineWidth(1.0f);
|
||||
GL15.glPolygonMode(GL15.GL_FRONT_AND_BACK, GL15.GL_LINE);
|
||||
}
|
||||
if(this.open == null) {
|
||||
if(this.player != null && this.viewEntity == this.player)
|
||||
|
@ -1119,18 +1128,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;
|
||||
GL46.glPushMatrix();
|
||||
GL46.glClear(16640);
|
||||
GL15.glPushMatrix();
|
||||
GL15.glClear(GL15.GL_COLOR_BUFFER_BIT | GL15.GL_DEPTH_BUFFER_BIT);
|
||||
GlState.enableTexture2D();
|
||||
if(this.world != null)
|
||||
this.renderer.renderWorld((float)this.tickFraction, System.nanoTime() - this.tickStart);
|
||||
GL46.glPopMatrix();
|
||||
GL15.glPopMatrix();
|
||||
|
||||
GlState.disableTexture2D();
|
||||
GlState.disableCull();
|
||||
GlState.enableBlend();
|
||||
if(this.wireframe)
|
||||
GL46.glPolygonMode(GL46.GL_FRONT_AND_BACK, GL46.GL_FILL);
|
||||
GL15.glPolygonMode(GL15.GL_FRONT_AND_BACK, GL15.GL_FILL);
|
||||
}
|
||||
|
||||
private int drawStat(int x, int y, String name, int value, int max, int color) {
|
||||
|
@ -1327,17 +1336,17 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
|
||||
GlState.bindTexture(0);
|
||||
GlState.setActiveTexture(GL46.GL_TEXTURE0);
|
||||
GlState.setActiveTexture(GL15.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);
|
||||
GL15.glPushMatrix();
|
||||
GL15.glTranslatef(0.0f, (float)by, 0.0f);
|
||||
if(this.scaleHotbar)
|
||||
GL46.glScalef(2.0f, 2.0f, 2.0f);
|
||||
GL15.glScalef(2.0f, 2.0f, 2.0f);
|
||||
|
||||
int xPos = xoff;
|
||||
for(int index = 0; index < size; ++index) {
|
||||
|
@ -1345,12 +1354,12 @@ public class Client implements IThreadListener {
|
|||
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);
|
||||
GL15.glEnable(GL15.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);
|
||||
GL15.glDisable(GL15.GL_SCISSOR_TEST);
|
||||
}
|
||||
xPos += width >= 20 || selected == index || selected == index + 1 ? 20 : width;
|
||||
}
|
||||
|
@ -1362,16 +1371,16 @@ public class Client implements IThreadListener {
|
|||
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);
|
||||
GL15.glPopMatrix();
|
||||
GL15.glPushMatrix();
|
||||
GL15.glTranslatef((float)(this.fbX / 2 - 180 + 4 + 1), (float)(this.hudMargin + 20 + 1), 0.0f);
|
||||
GL15.glScalef(2.0f, 2.0f, 2.0f);
|
||||
GlState.enableDepth();
|
||||
this.renderItem.renderItemAndEffectIntoGUI(new ItemStack(item), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
GL46.glPopMatrix();
|
||||
GL15.glPopMatrix();
|
||||
ItemRenderer.disableStandardItemLighting();
|
||||
GlState.disableRescaleNormal();
|
||||
GlState.disableBlend();
|
||||
|
@ -1440,8 +1449,8 @@ public class Client implements IThreadListener {
|
|||
"Tickrate: %s%.2f" + Color.RESET + " %s [" + Color.GREEN + "%.1f" + Color.RESET + "], %.3f ms, E %d ms" +
|
||||
"%s%s"
|
||||
,
|
||||
GL46.glGetString(GL46.GL_VERSION),
|
||||
GL46.glGetString(GL46.GL_RENDERER), GL46.glGetString(GL46.GL_VENDOR),
|
||||
GL15.glGetString(GL15.GL_VERSION),
|
||||
GL15.glGetString(GL15.GL_RENDERER), GL15.glGetString(GL15.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,
|
||||
|
@ -2125,7 +2134,7 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
|
||||
private void fbsize(int x, int y) {
|
||||
GL46.glViewport(0, 0, x, y);
|
||||
GL15.glViewport(0, 0, x, y);
|
||||
this.fbRawX = x;
|
||||
this.fbRawY = y;
|
||||
this.rescale();
|
||||
|
@ -2308,22 +2317,22 @@ public class Client implements IThreadListener {
|
|||
|
||||
public void setupOverlay() {
|
||||
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.tryBlendFuncSeparate(GL15.GL_SRC_ALPHA, GL15.GL_ONE_MINUS_SRC_ALPHA, GL15.GL_ONE, GL15.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlState.setActiveTexture(GL15.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);
|
||||
GL15.glClear(GL15.GL_DEPTH_BUFFER_BIT);
|
||||
GL15.glMatrixMode(GL15.GL_PROJECTION);
|
||||
GL15.glLoadIdentity();
|
||||
GL15.glOrtho(0.0D, (double)this.fbRawX, (double)this.fbRawY, 0.0D, 1000.0D, 3000.0D);
|
||||
GL15.glMatrixMode(GL15.GL_MODELVIEW);
|
||||
GL15.glLoadIdentity();
|
||||
GL15.glTranslatef(0.0F, 0.0F, -2000.0F);
|
||||
if(this.scale != 1)
|
||||
GL46.glScalef((float)this.scale, (float)this.scale, 1.0f);
|
||||
GL15.glScalef((float)this.scale, (float)this.scale, 1.0f);
|
||||
}
|
||||
|
||||
public void scissor(int x, int y, int width, int height) {
|
||||
GL46.glScissor(x * this.scale, y * this.scale, width * this.scale, height * this.scale);
|
||||
GL15.glScissor(x * this.scale, y * this.scale, width * this.scale, height * this.scale);
|
||||
}
|
||||
|
||||
private void addFrame(long runningTime)
|
||||
|
@ -2363,13 +2372,13 @@ public class Client implements IThreadListener {
|
|||
if(!Window.createWindow(VERSION, System.getProperty("opengl.debug") != null))
|
||||
System.exit(1);
|
||||
GL.createCapabilities();
|
||||
if(!GL.getCapabilities().OpenGL46) {
|
||||
if(!GL.getCapabilities().OpenGL15) {
|
||||
Window.destroyWindow();
|
||||
Util.panic("Inkompatible OpenGL-Version", "OpenGL 4.6 oder höher ist erforderlich, um dieses Programm auszuführen.");
|
||||
Util.panic("Inkompatible OpenGL-Version", "OpenGL 1.5 oder höher ist erforderlich, um dieses Programm auszuführen.");
|
||||
}
|
||||
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("OpenGL %s", GL15.glGetString(GL15.GL_VERSION));
|
||||
Log.SYSTEM.info("GL_VENDOR: %s", GL15.glGetString(GL15.GL_VENDOR));
|
||||
Log.SYSTEM.info("GL_RENDERER: %s", GL15.glGetString(GL15.GL_RENDERER));
|
||||
Log.SYSTEM.info("Starte ...");
|
||||
|
||||
this.init();
|
||||
|
@ -2379,9 +2388,10 @@ public class Client implements IThreadListener {
|
|||
Font.loadFonts();
|
||||
Font.select(this.font);
|
||||
GlState.enableBlend();
|
||||
GlState.blendFunc(GL46.GL_SRC_ALPHA, GL46.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlState.blendFunc(GL15.GL_SRC_ALPHA, GL15.GL_ONE_MINUS_SRC_ALPHA);
|
||||
this.initConsole();
|
||||
Shader.loadShaders();
|
||||
if(this.shaders)
|
||||
Shader.loadShaders();
|
||||
this.startSound(true);
|
||||
this.vidMode = Window.getDisplayMode();
|
||||
if(this.vidMode != null && (this.vidMode.width() < MIN_WIDTH || this.vidMode.height() < MIN_HEIGHT))
|
||||
|
@ -2410,7 +2420,7 @@ public class Client implements IThreadListener {
|
|||
Bind.updateBinds();
|
||||
this.input();
|
||||
Bind.enableInput();
|
||||
GlState.setActiveTexture(GL46.GL_TEXTURE0);
|
||||
GlState.setActiveTexture(GL15.GL_TEXTURE0);
|
||||
GlState.bindTexture(0);
|
||||
this.inputGui();
|
||||
if(this.open != null)
|
||||
|
@ -2427,7 +2437,7 @@ public class Client implements IThreadListener {
|
|||
this.finish();
|
||||
PerfSection.SWAP.enter();
|
||||
if(this.glFlush)
|
||||
GL46.glFlush();
|
||||
GL15.glFlush();
|
||||
Window.swapBuffers();
|
||||
PerfSection.EVENTS.enter();
|
||||
Log.flushLog();
|
||||
|
@ -2451,7 +2461,8 @@ public class Client implements IThreadListener {
|
|||
Log.flushLog();
|
||||
this.save();
|
||||
Font.unloadFonts();
|
||||
Shader.unloadShaders();
|
||||
if(this.shaders)
|
||||
Shader.unloadShaders();
|
||||
Window.destroyWindow();
|
||||
Log.SYSTEM.info("Beendet.");
|
||||
}
|
||||
|
@ -2522,7 +2533,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());
|
||||
GL46.glReadPixels(0, 0, this.fbRawX, this.fbRawY, GL46.GL_RGB, GL46.GL_UNSIGNED_BYTE, data);
|
||||
GL15.glReadPixels(0, 0, this.fbRawX, this.fbRawY, GL15.GL_RGB, GL15.GL_UNSIGNED_BYTE, data);
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
byte[] pixels = new byte[stride * Client.this.fbRawY];
|
||||
|
@ -2710,7 +2721,9 @@ public class Client implements IThreadListener {
|
|||
if(Util.DEVMODE)
|
||||
this.registerDebug(Keysym.L, "Maximale Helligkeit umschalten", new DebugRunner() {
|
||||
public void execute(Keysym key) {
|
||||
Client.this.logFeed("Maximale Helligkeit: %s", (Client.this.setGamma ^= true) ? "an" : "aus");
|
||||
Client.this.setGamma ^= true;
|
||||
Client.this.renderer.loadRenderers();
|
||||
Client.this.logFeed("Maximale Helligkeit: %s", Client.this.setGamma ? "an" : "aus");
|
||||
}
|
||||
});
|
||||
this.registerDebug(Keysym.J, "JVM GC ausführen", new DebugRunner() {
|
||||
|
@ -3262,17 +3275,17 @@ public class Client implements IThreadListener {
|
|||
|
||||
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.tryBlendFuncSeparate(GL15.GL_SRC_ALPHA, GL15.GL_ONE_MINUS_SRC_ALPHA, GL15.GL_ONE, GL15.GL_ZERO);
|
||||
GL15.glLineWidth(1.0F);
|
||||
GlState.disableTexture2D();
|
||||
GlState.depthMask(false);
|
||||
GL46.glPushMatrix();
|
||||
GL46.glTranslatef((float)(this.fbX / 2), (float)(this.fbY / 2), 0.0F);
|
||||
GL15.glPushMatrix();
|
||||
GL15.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();
|
||||
GL15.glPopMatrix();
|
||||
GlState.depthMask(true);
|
||||
GlState.enableTexture2D();
|
||||
GlState.disableBlend();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue