Started on VBOs

This commit is contained in:
peytonplayz585 2023-08-27 10:06:02 -05:00
parent 03b447610c
commit 8dbf01a344
6 changed files with 101 additions and 6 deletions

View File

@ -0,0 +1,30 @@
package net.PeytonPlayz585.shadow.opengl;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums;
public class OpenGLManager {
public static void setClientActiveTexture(int lightmaptexunit) {
PlatformOpenGL._wglActiveTexture(lightmaptexunit);
}
public static void glBindBuffer(int glArrayBuffer, IBufferGL vbo) {
PlatformOpenGL._wglBindBuffer(glArrayBuffer, vbo);
}
public static void glBufferData(int glArrayBuffer, ByteBuffer p_181722_1_, int i) {
PlatformOpenGL._wglBufferData(glArrayBuffer, p_181722_1_, i);
}
public static void glDrawArrays(int glTriangles, int i, int j) {
PlatformOpenGL._wglDrawArrays(RealOpenGLEnums.GL_TRIANGLES, 0, 6);
}
public static void glEnableClientState(int i) {
//PlatformOpenGL._wglEnableVertexAttribArray(i);
}
}

View File

@ -0,0 +1,34 @@
package net.PeytonPlayz585.shadow.opengl;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.GL_COMPILE;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums;
import net.lax1dude.eaglercraft.v1_8.opengl.VertexFormat;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
public class VertexBuffer {
//private IBufferGL vbo = null;
public void bindBuffer(IBufferGL vbo) {
OpenGLManager.glBindBuffer(RealOpenGLEnums.GL_ARRAY_BUFFER, vbo);
}
public void func_181722_a(WorldRenderer p_181722_1_, int parInt1) {
if(p_181722_1_.getVertexCount() > 0) {
EaglercraftGPU.glNewList(parInt1, GL_COMPILE);
VertexFormat fmt = p_181722_1_.getVertexFormat();
ByteBuffer buf = p_181722_1_.getByteBuffer();
EaglercraftGPU.renderBuffer(buf.position(0).compact().limit(p_181722_1_.getVertexCount() * fmt.attribStride), fmt.eaglercraftAttribBits, 7, p_181722_1_.getVertexCount());
p_181722_1_.reset();
EaglercraftGPU.glEndList();
}
}
public void unbindBuffer(IBufferGL vbo) {
OpenGLManager.glBindBuffer(RealOpenGLEnums.GL_ARRAY_BUFFER, vbo);
}
}

View File

@ -0,0 +1,12 @@
package net.PeytonPlayz585.shadow.opengl;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
public class VertexBufferUploader {
private VertexBuffer vertexBuffer = new VertexBuffer();
public void func_181679_a(WorldRenderer p_181679_1_, int parInt1) {
this.vertexBuffer.func_181722_a(p_181679_1_, parInt1);
}
}

View File

@ -5,6 +5,7 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.LinkedList;
import java.util.List;
import net.PeytonPlayz585.shadow.opengl.VertexBufferUploader;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
@ -25,6 +26,7 @@ public class ChunkUpdateManager {
private static final Logger LOGGER = LogManager.getLogger();
private final WorldVertexBufferUploader worldVertexUploader;
private final VertexBufferUploader vertexUploader = new VertexBufferUploader();
private final RegionRenderCacheBuilder renderCache;
private int chunkUpdatesTotal = 0;
@ -192,11 +194,13 @@ public class ChunkUpdateManager {
}
}
public void uploadChunk(final EnumWorldBlockLayer player, final WorldRenderer chunkRenderer,
final RenderChunk compiledChunkIn, final CompiledChunk parCompiledChunk) {
this.uploadDisplayList(chunkRenderer,
((ListedRenderChunk) compiledChunkIn).getDisplayList(player, parCompiledChunk), compiledChunkIn);
chunkRenderer.setTranslation(0.0D, 0.0D, 0.0D);
public void uploadChunk(final EnumWorldBlockLayer player, final WorldRenderer p_178503_2_, final RenderChunk chunkRenderer, final CompiledChunk compiledChunkIn) {
if(Minecraft.getMinecraft().gameSettings.useVbo) {
this.uploadVertexBuffer(p_178503_2_, ((ListedRenderChunk) chunkRenderer).getDisplayList(player, compiledChunkIn));
} else {
this.uploadDisplayList(p_178503_2_, ((ListedRenderChunk) chunkRenderer).getDisplayList(player, compiledChunkIn), chunkRenderer);
}
p_178503_2_.setTranslation(0.0D, 0.0D, 0.0D);
}
private void uploadDisplayList(WorldRenderer chunkRenderer, int parInt1, RenderChunk parRenderChunk) {
@ -207,6 +211,10 @@ public class ChunkUpdateManager {
EaglercraftGPU.glEndList();
}
private void uploadVertexBuffer(WorldRenderer p_178506_1_, int parInt1) {
this.vertexUploader.func_181679_a(p_178506_1_, parInt1);
}
public boolean isAlreadyQueued(RenderChunk update) {
for(int i = 0, l = queue.size(); i < l; ++i) {
if(queue.get(i).getRenderChunk() == update) {

View File

@ -821,7 +821,7 @@ public class Minecraft implements IThreadListener {
.getValueMax() ? "inf" : Integer.valueOf(this.gameSettings.limitFramerate),
this.gameSettings.enableVsync ? " vsync" : "",
this.gameSettings.fancyGraphics ? "" : " fast", this.gameSettings.clouds == 0 ? ""
: (this.gameSettings.clouds == 1 ? " fast-clouds" : " fancy-clouds") });
: (this.gameSettings.clouds == 1 ? " fast-clouds" : " fancy-clouds"), gameSettings.useVbo ? " vbo" : "" });
RenderChunk.renderChunksUpdated = 0;
this.debugUpdateTime += 1000L;
this.fpsCounter = 0;

View File

@ -0,0 +1,11 @@
package net.minecraft.client.renderer.chunk;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class VboChunkFactory implements IRenderChunkFactory {
public RenderChunk makeRenderChunk(World worldIn, RenderGlobal globalRenderer, BlockPos pos, int index) {
return new RenderChunk(worldIn, globalRenderer, pos, index);
}
}