mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-27 23:46:01 +00:00
Add VAO's (#1126)
This commit is contained in:
1 parent
8bec433699
commit
a8107f97e8
8 files changed
+24
-26
No files matched your search
@@ -47,6 +47,11 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableVBOClouds;
|
||||
|
||||
@Config.Comment("Uses cached attributes for VBO rendering, resulting in less CPU overhead. Disable if you notice any graphical issues.")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableVAO;
|
||||
|
||||
@Config.Comment("Enable NotFine features")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.postprocessing.CustomFramebuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.postprocessing.SharedDepthFramebuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vao.VertexArrayBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
@@ -178,10 +179,7 @@ public class HUDCaching {
|
||||
if (quadWidth != width || quadHeight != height) {
|
||||
quadWidth = width;
|
||||
quadHeight = height;
|
||||
if (quadVAO != null) {
|
||||
quadVAO.close();
|
||||
}
|
||||
quadVAO = rebuildVAO(width, height);
|
||||
rebuildVAO(width, height);
|
||||
}
|
||||
GLStateManager.disableDepthTest();
|
||||
GLStateManager.enableTexture();
|
||||
@@ -190,7 +188,7 @@ public class HUDCaching {
|
||||
}
|
||||
|
||||
|
||||
private static VertexBuffer rebuildVAO(float width, float height) {
|
||||
private static void rebuildVAO(float width, float height) {
|
||||
final CapturingTessellator tessellator = TessellatorManager.startCapturingAndGet();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(0, height, 0.0, 0, 0);
|
||||
@@ -198,7 +196,7 @@ public class HUDCaching {
|
||||
tessellator.addVertexWithUV(width, 0, 0.0, 1, 1);
|
||||
tessellator.addVertexWithUV(0, 0, 0.0, 0, 1);
|
||||
tessellator.draw();
|
||||
return TessellatorManager.stopCapturingToVAO(DefaultVertexFormat.POSITION_TEXTURE);
|
||||
quadVAO = TessellatorManager.stopCapturingToVAO(quadVAO, DefaultVertexFormat.POSITION_TEXTURE);
|
||||
}
|
||||
|
||||
public static void disableHoloInventory() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.loading.ModelRegistry;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vao.VAOManager;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.bettercrashes.BetterCrashesCompat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -111,6 +112,9 @@ public class ClientProxy extends CommonProxy {
|
||||
FMLCommonHandler.instance().bus().register(Iris.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(Iris.INSTANCE);
|
||||
}
|
||||
if (!AngelicaConfig.enableVAO) {
|
||||
VAOManager.disableVao();
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
@@ -218,12 +218,11 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
}
|
||||
|
||||
private void build() {
|
||||
TessellatorManager.startCapturing();
|
||||
CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
CapturingTessellator tess = TessellatorManager.startCapturingAndGet();
|
||||
|
||||
vertices(tess);
|
||||
|
||||
this.vbo = TessellatorManager.stopCapturingToVBO(FORMAT);
|
||||
this.vbo = TessellatorManager.stopCapturingToVAO(FORMAT);
|
||||
}
|
||||
|
||||
private int fullCoord(double coord, int scale) { // Corrects misalignment of UV offset when on negative coords.
|
||||
|
||||
@@ -27,6 +27,7 @@ package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vao.VAOManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -126,7 +127,7 @@ public class ItemRenderListManager {
|
||||
private int expiry;
|
||||
|
||||
public CachedVBO() {
|
||||
this.vertexBuffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, GL11.GL_QUADS);
|
||||
this.vertexBuffer = VAOManager.createVAO(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, GL11.GL_QUADS);
|
||||
}
|
||||
|
||||
private void render(int elapsedTicks) {
|
||||
|
||||
@@ -66,8 +66,7 @@ public class BlockRenderer {
|
||||
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
|
||||
final LightPipeline lighter = this.lighters.getLighter(mode);
|
||||
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
final CapturingTessellator tess = TessellatorManager.startCapturingAndGet();
|
||||
tess.startDrawingQuads();
|
||||
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
|
||||
// is done in subchunk-relative coordinates
|
||||
@@ -101,8 +100,7 @@ public class BlockRenderer {
|
||||
final int emitted = block.getLightValue(world, pos.x, pos.y, pos.z);
|
||||
|
||||
try {
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
final CapturingTessellator tess = TessellatorManager.startCapturingAndGet();
|
||||
tess.startDrawingQuads();
|
||||
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
|
||||
// is done in subchunk-relative coordinates
|
||||
|
||||
@@ -52,17 +52,13 @@ public class HorizonRenderer {
|
||||
}
|
||||
|
||||
private void rebuildBuffer() {
|
||||
if (this.vertexBuffer != null) {
|
||||
this.vertexBuffer.close();
|
||||
}
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tessellator = (CapturingTessellator) TessellatorManager.get();
|
||||
final CapturingTessellator tessellator = TessellatorManager.startCapturingAndGet();
|
||||
|
||||
// Build the horizon quads into a buffer
|
||||
tessellator.startDrawingQuads(); //(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
|
||||
buildHorizon(currentRenderDistance * 16, tessellator);
|
||||
|
||||
this.vertexBuffer = TessellatorManager.stopCapturingToVBO(DefaultVertexFormat.POSITION);
|
||||
this.vertexBuffer = TessellatorManager.stopCapturingToVAO(vertexBuffer, DefaultVertexFormat.POSITION);
|
||||
}
|
||||
|
||||
private void buildQuad(Tessellator consumer, double x1, double z1, double x2, double z2) {
|
||||
@@ -155,12 +151,9 @@ public class HorizonRenderer {
|
||||
rebuildBuffer();
|
||||
}
|
||||
|
||||
vertexBuffer.bind();
|
||||
GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
|
||||
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
||||
vertexBuffer.setupState();
|
||||
vertexBuffer.draw(floatBuffer);
|
||||
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
|
||||
vertexBuffer.unbind();
|
||||
vertexBuffer.cleanupState();
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
||||
Reference in new issue
Block a user