prefix all blaze/openGl objects

This commit is contained in:
James Seibel
2026-03-10 17:42:14 -05:00
parent ba977a29f0
commit 9e5be3ad21
70 changed files with 754 additions and 850 deletions
@@ -32,8 +32,8 @@ import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.common.render.blaze.helpers.UniformHandler;
import com.seibel.distanthorizons.common.render.blaze.util.DhBlazeVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -135,7 +135,7 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
private void createPipelines()
{
VertexFormat vertexFormat = VertexFormat.builder()
.add("vPosition", DhBlazeVertexFormatUtil.FLOAT_XYZ_POS)
.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
.build();
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
@@ -283,7 +283,7 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
.get()
;
this.uniformBuffer = UniformHandler.createBuffer("uniformBlock", uniformBufferSize, this.uniformBuffer);
this.uniformBuffer = BlazeUniformUtil.createBuffer("uniformBlock", uniformBufferSize, this.uniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.uniformBuffer, 0, uniformBufferSize);
commandEncoder.writeToBuffer(bufferSlice, buffer);
@@ -42,10 +42,10 @@ import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeG
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
import com.seibel.distanthorizons.common.render.blaze.helpers.BlazeGenericObjectVertexContainer;
import com.seibel.distanthorizons.common.render.blaze.util.DhBlazeVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.objects.BlazeGenericObjectVertexContainer;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
import com.seibel.distanthorizons.common.render.blaze.helpers.UniformHandler;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -128,9 +128,9 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
this.init = true;
this.vertexFormat = VertexFormat.builder()
.add("vPosition", DhBlazeVertexFormatUtil.FLOAT_XYZ_POS)
.add("aColor", DhBlazeVertexFormatUtil.RGBA_UBYTE_COLOR)
.add("aMaterial", DhBlazeVertexFormatUtil.IRIS_MATERIAL)
.add("vPosition", BlazeDhVertexFormatUtil.FLOAT_XYZ_POS)
.add("aColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
.add("aMaterial", BlazeDhVertexFormatUtil.IRIS_MATERIAL)
.build();
this.createPipelines();
@@ -480,7 +480,7 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
.get()
;
this.vertUniformBuffer = UniformHandler.createBuffer("vertUniformBlock", uniformBufferSize, this.vertUniformBuffer);
this.vertUniformBuffer = BlazeUniformUtil.createBuffer("vertUniformBlock", uniformBufferSize, this.vertUniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vertUniformBuffer, 0, uniformBufferSize);
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
@@ -1,6 +1,6 @@
package com.seibel.distanthorizons.common.render.blaze;
import com.seibel.distanthorizons.common.render.blaze.helpers.BlazeGenericObjectVertexContainer;
import com.seibel.distanthorizons.common.render.blaze.objects.BlazeGenericObjectVertexContainer;
import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeDhFarFadeRenderer;
import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeDhFogRenderer;
import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeDhSsaoRenderer;
@@ -8,7 +8,6 @@ import com.seibel.distanthorizons.common.render.blaze.postProcessing.BlazeVanill
import com.seibel.distanthorizons.common.render.blaze.test.BlazeDhTestTriangleRenderer;
import com.seibel.distanthorizons.common.render.blaze.wrappers.buffer.BlazeVertexBufferWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeLodUniformBufferWrapper;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
@@ -16,8 +16,8 @@ import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
import com.seibel.distanthorizons.common.render.blaze.helpers.*;
import com.seibel.distanthorizons.common.render.blaze.util.DhBlazeVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.uniform.BlazeLodUniformBufferWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.buffer.BlazeVertexBufferWrapper;
@@ -28,8 +28,8 @@ import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuad
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLEnums;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.QuadElementBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.enums.GLEnums;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GlQuadElementBuffer;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.util.RenderUtil;
import com.seibel.distanthorizons.core.util.math.Mat4f;
@@ -88,13 +88,13 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
VertexFormat vertexFormat = VertexFormat.builder()
.add("vPosition", DhBlazeVertexFormatUtil.SHORT_XYZ_POS)
.add("meta", DhBlazeVertexFormatUtil.META)
.add("vColor", DhBlazeVertexFormatUtil.RGBA_UBYTE_COLOR)
.add("irisMaterial", DhBlazeVertexFormatUtil.IRIS_MATERIAL)
.add("irisNormal", DhBlazeVertexFormatUtil.IRIS_NORMAL)
.add("paddingTwo", DhBlazeVertexFormatUtil.BYTE_PAD)
.add("paddingThree", DhBlazeVertexFormatUtil.BYTE_PAD) // padding is to make sure the format is a multiple of 4
.add("vPosition", BlazeDhVertexFormatUtil.SHORT_XYZ_POS)
.add("meta", BlazeDhVertexFormatUtil.META)
.add("vColor", BlazeDhVertexFormatUtil.RGBA_UBYTE_COLOR)
.add("irisMaterial", BlazeDhVertexFormatUtil.IRIS_MATERIAL)
.add("irisNormal", BlazeDhVertexFormatUtil.IRIS_NORMAL)
.add("paddingTwo", BlazeDhVertexFormatUtil.BYTE_PAD)
.add("paddingThree", BlazeDhVertexFormatUtil.BYTE_PAD) // padding is to make sure the format is a multiple of 4
.build();
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
@@ -207,7 +207,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
.putMat4f(combinedMatrix.createJomlMatrix()) // uCombinedMatrix
.get();
this.vertSharedUniformBuffer = UniformHandler.createBuffer("vertSharedUniformBlock", uniformBufferSize, this.vertSharedUniformBuffer);
this.vertSharedUniformBuffer = BlazeUniformUtil.createBuffer("vertSharedUniformBlock", uniformBufferSize, this.vertSharedUniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.vertSharedUniformBuffer, 0, uniformBufferSize);
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
@@ -249,7 +249,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
.get()
;
this.fragUniformBuffer = UniformHandler.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
@@ -260,7 +260,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
if (this.indexBuffer == null)
{
ByteBuffer buffer = MemoryUtil.memAlloc(LodQuadBuilder.getMaxBufferByteSize() * GLEnums.getTypeSize(GL32.GL_UNSIGNED_INT) * 6);
QuadElementBuffer.buildBuffer(LodQuadBuilder.getMaxBufferByteSize(), buffer, GL32.GL_UNSIGNED_INT);
GlQuadElementBuffer.buildBuffer(LodQuadBuilder.getMaxBufferByteSize(), buffer, GL32.GL_UNSIGNED_INT);
// create buffer if needed
@@ -31,7 +31,7 @@ import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.textures.*;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.common.render.blaze.util.DhBlazeVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -146,7 +146,7 @@ public class BlazeDhApplyRenderer
}
VertexFormat vertexFormat = VertexFormat.builder()
.add("vPosition", DhBlazeVertexFormatUtil.SCREEN_POS)
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
.build();
RenderPipeline.Builder pipelineBuilder = RenderPipeline.builder();
@@ -1,4 +1,4 @@
package com.seibel.distanthorizons.common.render.blaze.helpers;
package com.seibel.distanthorizons.common.render.blaze.objects;
import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.buffers.GpuBufferSlice;
@@ -8,7 +8,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLEnums;
import com.seibel.distanthorizons.common.render.openGl.glObject.enums.GLEnums;
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
import com.seibel.distanthorizons.core.render.renderer.RenderableBoxGroup;
@@ -33,10 +33,9 @@ import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhTerrainRenderer;
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
import com.seibel.distanthorizons.common.render.blaze.helpers.*;
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -184,7 +183,7 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
.get()
;
this.fragUniformBuffer = UniformHandler.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
@@ -38,13 +38,11 @@ import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhTerrainRenderer;
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
import com.seibel.distanthorizons.common.render.blaze.helpers.UniformHandler;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -302,7 +300,7 @@ public class BlazeDhFogRenderer implements IDhFogRenderer
.get()
;
this.fragUniformBuffer = UniformHandler.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
@@ -35,13 +35,11 @@ import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhTerrainRenderer;
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhApplyRenderer;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
import com.seibel.distanthorizons.common.render.blaze.helpers.UniformHandler;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -199,7 +197,7 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
.get()
;
this.fragUniformBuffer = UniformHandler.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
@@ -236,7 +234,7 @@ public class BlazeDhSsaoRenderer implements IDhSsaoRenderer
.get()
;
this.applyFragUniformBuffer = UniformHandler.createBuffer("applyFragUniformBlock", uniformBufferSize, this.applyFragUniformBuffer);
this.applyFragUniformBuffer = BlazeUniformUtil.createBuffer("applyFragUniformBlock", uniformBufferSize, this.applyFragUniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.applyFragUniformBuffer, 0, uniformBufferSize);
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
@@ -33,10 +33,9 @@ import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhMetaRenderer;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhTerrainRenderer;
import com.seibel.distanthorizons.common.render.blaze.apply.BlazeDhCopyRenderer;
import com.seibel.distanthorizons.common.render.blaze.helpers.*;
import com.seibel.distanthorizons.common.render.blaze.util.BlazePostProcessUtil;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureViewWrapper;
import com.seibel.distanthorizons.common.render.blaze.wrappers.texture.BlazeTextureWrapper;
import com.seibel.distanthorizons.core.config.Config;
@@ -48,7 +47,6 @@ import com.seibel.distanthorizons.core.util.RenderUtil;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.IDhVanillaFadeRenderer;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.Identifier;
@@ -214,7 +212,7 @@ public class BlazeVanillaFadeRenderer implements IDhVanillaFadeRenderer
.get()
;
this.fragUniformBuffer = UniformHandler.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
this.fragUniformBuffer = BlazeUniformUtil.createBuffer("fragUniformBlock", uniformBufferSize, this.fragUniformBuffer);
GpuBufferSlice bufferSlice = new GpuBufferSlice(this.fragUniformBuffer, 0, uniformBufferSize);
COMMAND_ENCODER.writeToBuffer(bufferSlice, buffer);
@@ -30,7 +30,7 @@ import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.textures.*;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.seibel.distanthorizons.common.render.blaze.util.DhBlazeVertexFormatUtil;
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.render.RenderParams;
@@ -84,8 +84,8 @@ public class BlazeDhTestTriangleRenderer implements IDhTestTriangleRenderer
VertexFormat vertexFormat = VertexFormat.builder()
.add("vPosition", DhBlazeVertexFormatUtil.SCREEN_POS)
.add("vColor", DhBlazeVertexFormatUtil.RGBA_FLOAT_COLOR)
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
.add("vColor", BlazeDhVertexFormatUtil.RGBA_FLOAT_COLOR)
.build();
//int breakpointOne = 0;
@@ -13,7 +13,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftCli
/**
* @see LodQuadBuilder
*/
public class DhBlazeVertexFormatUtil
public class BlazeDhVertexFormatUtil
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -63,7 +63,7 @@ public class BlazePostProcessUtil
public static VertexFormat createVertexFormat()
{
VertexFormat vertexFormat = VertexFormat.builder()
.add("vPosition", DhBlazeVertexFormatUtil.SCREEN_POS)
.add("vPosition", BlazeDhVertexFormatUtil.SCREEN_POS)
.build();
return vertexFormat;
}
@@ -1,12 +1,11 @@
package com.seibel.distanthorizons.common.render.blaze.helpers;
package com.seibel.distanthorizons.common.render.blaze.util;
import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.systems.CommandEncoder;
import com.mojang.blaze3d.systems.GpuDevice;
import com.mojang.blaze3d.systems.RenderSystem;
@Deprecated // TODO use Uniform Wrapper instead
public class UniformHandler
public class BlazeUniformUtil
{
private static final GpuDevice GPU_DEVICE = RenderSystem.getDevice();
private static final CommandEncoder COMMAND_ENCODER = GPU_DEVICE.createCommandEncoder();
@@ -8,7 +8,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodCont
import java.nio.ByteBuffer;
public class BlazeLodUniformBufferWrapper extends UniformBufferWrapper implements ILodContainerUniformBufferWrapper
public class BlazeLodUniformBufferWrapper extends BlazeUniformBufferWrapper implements ILodContainerUniformBufferWrapper
{
private boolean uploaded = false;
@@ -12,7 +12,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IUniform
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class UniformBufferWrapper implements IUniformBufferWrapper
public class BlazeUniformBufferWrapper implements IUniformBufferWrapper
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -35,7 +35,7 @@ public class UniformBufferWrapper implements IUniformBufferWrapper
//=============//
//region
public UniformBufferWrapper(String name) { this.name = name; }
public BlazeUniformBufferWrapper(String name) { this.name = name; }
//endregion
@@ -1,66 +0,0 @@
package com.seibel.distanthorizons.common.render.nativeGl;
import com.seibel.distanthorizons.common.render.nativeGl.generic.OpenGlGenericObjectRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.generic.OpenGlGenericObjectVertexContainer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.OpenGlDummyUniformData;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fade.DhFarFadeRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fade.VanillaFadeRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fog.DhFogRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ssao.DhSSAORenderer;
import com.seibel.distanthorizons.common.render.nativeGl.test.GlTestTriangleRenderer;
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodContainerUniformBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.*;
public class OpenGlDhRenderApiDefinition extends AbstractDhRenderApiDefinition
{
//=========//
// getters //
//=========//
//region
public String getApiName() { return "OpenGL"; }
//endregion
//============//
// singletons //
//============//
//region
@Override public IDhMetaRenderer getMetaRenderer() { return OpenGlDhMetaRenderer.INSTANCE; }
@Override public IDhTerrainRenderer getTerrainRenderer() { return DhTerrainShaderProgram.INSTANCE; }
@Override public IDhSsaoRenderer getSsaoRenderer() { return DhSSAORenderer.INSTANCE; }
@Override public IDhFogRenderer getFogRenderer() { return DhFogRenderer.INSTANCE; }
@Override public IDhFarFadeRenderer getFarFadeRenderer() { return DhFarFadeRenderer.INSTANCE; }
@Override public AbstractDebugWireframeRenderer getDebugWireframeRenderer() { return OpenGlDebugWireframeRenderer.INSTANCE; }
@Override public IDhVanillaFadeRenderer getVanillaFadeRenderer() { return VanillaFadeRenderer.INSTANCE; }
@Override public IDhTestTriangleRenderer getTestTriangleRenderer() { return GlTestTriangleRenderer.INSTANCE; }
//endregion
//===========//
// factories //
//===========//
//region
@Override public IDhGenericRenderer createGenericRenderer() { return OpenGlGenericObjectRenderer.INSTANCE; }
@Override public IVertexBufferWrapper createVboWrapper(String name) { return new GLVertexBuffer(); }
@Override public ILodContainerUniformBufferWrapper createLodContainerUniformWrapper() { return new OpenGlDummyUniformData(); }
@Override public IDhGenericObjectVertexBufferContainer createGenericVboContainer() { return new OpenGlGenericObjectVertexContainer(); }
//endregion
}
@@ -1,130 +0,0 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject.texture;
import org.lwjgl.opengl.GL11C;
import org.lwjgl.opengl.GL30C;
import org.lwjgl.opengl.GL31C;
import java.util.Locale;
import java.util.Optional;
public enum EDhInternalTextureFormat
{
RGBA(GL11C.GL_RGBA, EGlVersion.GL_11, EDhPixelFormat.RGBA),
// 8-bit normalized
R8(GL30C.GL_R8, EGlVersion.GL_30, EDhPixelFormat.RED),
RG8(GL30C.GL_RG8, EGlVersion.GL_30, EDhPixelFormat.RG),
RGB8(GL11C.GL_RGB8, EGlVersion.GL_11, EDhPixelFormat.RGB),
RGBA8(GL11C.GL_RGBA8, EGlVersion.GL_11, EDhPixelFormat.RGBA),
// 8-bit signed normalized
R8_SNORM(GL31C.GL_R8_SNORM, EGlVersion.GL_31, EDhPixelFormat.RED),
RG8_SNORM(GL31C.GL_RG8_SNORM, EGlVersion.GL_31, EDhPixelFormat.RG),
RGB8_SNORM(GL31C.GL_RGB8_SNORM, EGlVersion.GL_31, EDhPixelFormat.RGB),
RGBA8_SNORM(GL31C.GL_RGBA8_SNORM, EGlVersion.GL_31, EDhPixelFormat.RGBA),
// 16-bit normalized
R16(GL30C.GL_R16, EGlVersion.GL_30, EDhPixelFormat.RED),
RG16(GL30C.GL_RG16, EGlVersion.GL_30, EDhPixelFormat.RG),
RGB16(GL11C.GL_RGB16, EGlVersion.GL_11, EDhPixelFormat.RGB),
RGBA16(GL11C.GL_RGBA16, EGlVersion.GL_11, EDhPixelFormat.RGBA),
// 16-bit signed normalized
R16_SNORM(GL31C.GL_R16_SNORM, EGlVersion.GL_31, EDhPixelFormat.RED),
RG16_SNORM(GL31C.GL_RG16_SNORM, EGlVersion.GL_31, EDhPixelFormat.RG),
RGB16_SNORM(GL31C.GL_RGB16_SNORM, EGlVersion.GL_31, EDhPixelFormat.RGB),
RGBA16_SNORM(GL31C.GL_RGBA16_SNORM, EGlVersion.GL_31, EDhPixelFormat.RGBA),
// 16-bit float
R16F(GL30C.GL_R16F, EGlVersion.GL_30, EDhPixelFormat.RED),
RG16F(GL30C.GL_RG16F, EGlVersion.GL_30, EDhPixelFormat.RG),
RGB16F(GL30C.GL_RGB16F, EGlVersion.GL_30, EDhPixelFormat.RGB),
RGBA16F(GL30C.GL_RGBA16F, EGlVersion.GL_30, EDhPixelFormat.RGBA),
// 32-bit float
R32F(GL30C.GL_R32F, EGlVersion.GL_30, EDhPixelFormat.RED),
RG32F(GL30C.GL_RG32F, EGlVersion.GL_30, EDhPixelFormat.RG),
RGB32F(GL30C.GL_RGB32F, EGlVersion.GL_30, EDhPixelFormat.RGB),
RGBA32F(GL30C.GL_RGBA32F, EGlVersion.GL_30, EDhPixelFormat.RGBA),
// 8-bit integer
R8I(GL30C.GL_R8I, EGlVersion.GL_30, EDhPixelFormat.RED_INTEGER),
RG8I(GL30C.GL_RG8I, EGlVersion.GL_30, EDhPixelFormat.RG_INTEGER),
RGB8I(GL30C.GL_RGB8I, EGlVersion.GL_30, EDhPixelFormat.RGB_INTEGER),
RGBA8I(GL30C.GL_RGBA8I, EGlVersion.GL_30, EDhPixelFormat.RGBA_INTEGER),
// 8-bit unsigned integer
R8UI(GL30C.GL_R8UI, EGlVersion.GL_30, EDhPixelFormat.RED_INTEGER),
RG8UI(GL30C.GL_RG8UI, EGlVersion.GL_30, EDhPixelFormat.RG_INTEGER),
RGB8UI(GL30C.GL_RGB8UI, EGlVersion.GL_30, EDhPixelFormat.RGB_INTEGER),
RGBA8UI(GL30C.GL_RGBA8UI, EGlVersion.GL_30, EDhPixelFormat.RGBA_INTEGER),
// 16-bit integer
R16I(GL30C.GL_R16I, EGlVersion.GL_30, EDhPixelFormat.RED_INTEGER),
RG16I(GL30C.GL_RG16I, EGlVersion.GL_30, EDhPixelFormat.RG_INTEGER),
RGB16I(GL30C.GL_RGB16I, EGlVersion.GL_30, EDhPixelFormat.RGB_INTEGER),
RGBA16I(GL30C.GL_RGBA16I, EGlVersion.GL_30, EDhPixelFormat.RGBA_INTEGER),
// 16-bit unsigned integer
R16UI(GL30C.GL_R16UI, EGlVersion.GL_30, EDhPixelFormat.RED_INTEGER),
RG16UI(GL30C.GL_RG16UI, EGlVersion.GL_30, EDhPixelFormat.RG_INTEGER),
RGB16UI(GL30C.GL_RGB16UI, EGlVersion.GL_30, EDhPixelFormat.RGB_INTEGER),
RGBA16UI(GL30C.GL_RGBA16UI, EGlVersion.GL_30, EDhPixelFormat.RGBA_INTEGER),
// 32-bit integer
R32I(GL30C.GL_R32I, EGlVersion.GL_30, EDhPixelFormat.RED_INTEGER),
RG32I(GL30C.GL_RG32I, EGlVersion.GL_30, EDhPixelFormat.RG_INTEGER),
RGB32I(GL30C.GL_RGB32I, EGlVersion.GL_30, EDhPixelFormat.RGB_INTEGER),
RGBA32I(GL30C.GL_RGBA32I, EGlVersion.GL_30, EDhPixelFormat.RGBA_INTEGER),
// 32-bit unsigned integer
R32UI(GL30C.GL_R32UI, EGlVersion.GL_30, EDhPixelFormat.RED_INTEGER),
RG32UI(GL30C.GL_RG32UI, EGlVersion.GL_30, EDhPixelFormat.RG_INTEGER),
RGB32UI(GL30C.GL_RGB32UI, EGlVersion.GL_30, EDhPixelFormat.RGB_INTEGER),
RGBA32UI(GL30C.GL_RGBA32UI, EGlVersion.GL_30, EDhPixelFormat.RGBA_INTEGER),
// Mixed
R3_G3_B2(GL11C.GL_R3_G3_B2, EGlVersion.GL_11, EDhPixelFormat.RGB),
RGB5_A1(GL11C.GL_RGB5_A1, EGlVersion.GL_11, EDhPixelFormat.RGBA),
RGB10_A2(GL11C.GL_RGB10_A2, EGlVersion.GL_11, EDhPixelFormat.RGBA),
R11F_G11F_B10F(GL30C.GL_R11F_G11F_B10F, EGlVersion.GL_30, EDhPixelFormat.RGB),
RGB9_E5(GL30C.GL_RGB9_E5, EGlVersion.GL_30, EDhPixelFormat.RGB);
private final int glFormat;
private final EGlVersion minimumGlVersion;
private final EDhPixelFormat expectedPixelFormat;
EDhInternalTextureFormat(int glFormat, EGlVersion minimumGlVersion, EDhPixelFormat expectedPixelFormat)
{
this.glFormat = glFormat;
this.minimumGlVersion = minimumGlVersion;
this.expectedPixelFormat = expectedPixelFormat;
}
public static Optional<EDhInternalTextureFormat> fromString(String name)
{
try
{
return Optional.of(EDhInternalTextureFormat.valueOf(name.toUpperCase(Locale.US)));
}
catch (IllegalArgumentException e)
{
return Optional.empty();
}
}
public int getGlFormat() { return this.glFormat; }
public EDhPixelFormat getPixelFormat() { return this.expectedPixelFormat; }
public EGlVersion getMinimumGlVersion() { return this.minimumGlVersion; }
}
@@ -1,9 +0,0 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject.texture;
public enum EGlVersion
{
GL_11,
GL_12,
GL_30,
GL_31
}
@@ -1,72 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute;
import com.seibel.distanthorizons.coreapi.util.MathUtil;
import org.lwjgl.opengl.GL32;
public final class VertexPointer
{
public final int elementCount;
public final int glType;
public final boolean normalized;
public final int byteSize;
public final boolean useInteger;
// basic constructors //
public VertexPointer(int elementCount, int glType, boolean normalized, int byteSize, boolean useInteger)
{
this.elementCount = elementCount;
this.glType = glType;
this.normalized = normalized;
this.byteSize = byteSize;
this.useInteger = useInteger;
}
public VertexPointer(int elementCount, int glType, boolean normalized, int byteSize)
{
this(elementCount, glType, normalized, byteSize, false);
}
private static int _align(int bytes) { return MathUtil.ceilDiv(bytes, 4) * 4; }
// named constructors //
public static VertexPointer addFloatPointer(boolean normalized) { return new VertexPointer(1, GL32.GL_FLOAT, normalized, Float.BYTES); }
public static VertexPointer addVec2Pointer(boolean normalized) { return new VertexPointer(2, GL32.GL_FLOAT, normalized, Float.BYTES * 2); }
public static VertexPointer addVec3Pointer(boolean normalized) { return new VertexPointer(3, GL32.GL_FLOAT, normalized, Float.BYTES * 3); }
public static VertexPointer addVec4Pointer(boolean normalized) { return new VertexPointer(4, GL32.GL_FLOAT, normalized, Float.BYTES * 4); }
/** Always aligned to 4 bytes */
public static VertexPointer addUnsignedBytePointer(boolean normalized, boolean useInteger) { return new VertexPointer(1, GL32.GL_UNSIGNED_BYTE, normalized, 4, useInteger); }
/** aligned to 4 bytes */
public static VertexPointer addUnsignedBytesPointer(int elementCount, boolean normalized, boolean useInteger)
{ return new VertexPointer(elementCount, GL32.GL_UNSIGNED_BYTE, normalized, _align(elementCount), useInteger); }
public static VertexPointer addUnsignedShortsPointer(int elementCount, boolean normalized, boolean useInteger)
{ return new VertexPointer(elementCount, GL32.GL_UNSIGNED_SHORT, normalized, _align(elementCount * 2), useInteger); }
public static VertexPointer addShortsPointer(int elementCount, boolean normalized, boolean useInteger) { return new VertexPointer(elementCount, GL32.GL_SHORT, normalized, _align(elementCount * 2), useInteger); }
public static VertexPointer addIntPointer(boolean normalized, boolean useInteger) { return new VertexPointer(1, GL32.GL_INT, normalized, 4, useInteger); }
public static VertexPointer addIVec2Pointer(boolean normalized, boolean useInteger) { return new VertexPointer(2, GL32.GL_INT, normalized, 8, useInteger); }
public static VertexPointer addIVec3Pointer(boolean normalized, boolean useInteger) { return new VertexPointer(3, GL32.GL_INT, normalized, 12, useInteger); }
public static VertexPointer addIVec4Pointer(boolean normalized, boolean useInteger) { return new VertexPointer(4, GL32.GL_INT, normalized, 16, useInteger); }
}
@@ -1,72 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fog;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogFalloff;
import java.util.Objects;
/**
* Contains all configurable options related to fog.
*
* @version 2022-4-13
*/
public class FogSettings
{
/** a FogSetting object with 0 for every value */
public static final FogSettings EMPTY = new FogSettings(0, 0, 0, 0, 0, EDhApiFogFalloff.LINEAR);
public final double start;
public final double end;
public final double min;
public final double max;
public final double density;
public final EDhApiFogFalloff fogType;
public FogSettings(double start, double end, double min, double max, double density, EDhApiFogFalloff fogType)
{
this.start = start;
this.end = end;
this.min = min;
this.max = max;
this.density = density;
this.fogType = fogType;
}
@Override
public boolean equals(Object o)
{
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
FogSettings that = (FogSettings) o;
return Double.compare(that.start, start) == 0 && Double.compare(that.end, end) == 0 && Double.compare(that.min, min) == 0 && Double.compare(that.max, max) == 0 && Double.compare(that.density, density) == 0 && fogType == that.fogType;
}
@Override
public int hashCode()
{
return Objects.hash(start, end, min, max, density, fogType);
}
}
@@ -17,13 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl;
package com.seibel.distanthorizons.common.render.openGl;
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.GLElementBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.AbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.VertexPointer;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLElementBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlAbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlVertexPointer;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -39,9 +39,9 @@ import java.nio.ByteOrder;
* Handles rendering the wireframe particles
* that are used for seeing what the system's doing.
*/
public class OpenGlDebugWireframeRenderer extends AbstractDebugWireframeRenderer
public class GlDhDebugWireframeRenderer extends AbstractDebugWireframeRenderer
{
public static OpenGlDebugWireframeRenderer INSTANCE = new OpenGlDebugWireframeRenderer();
public static GlDhDebugWireframeRenderer INSTANCE = new GlDhDebugWireframeRenderer();
public static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -50,9 +50,9 @@ public class OpenGlDebugWireframeRenderer extends AbstractDebugWireframeRenderer
// rendering setup
private ShaderProgram basicShader;
private GlShaderProgram basicShader;
private GLElementBuffer outlineIndexBuffer;
private AbstractVertexAttribute va;
private GlAbstractVertexAttribute va;
private boolean init = false;
@@ -98,7 +98,7 @@ public class OpenGlDebugWireframeRenderer extends AbstractDebugWireframeRenderer
//=============//
//region
private OpenGlDebugWireframeRenderer() { }
private GlDhDebugWireframeRenderer() { }
public void init()
{
@@ -108,12 +108,12 @@ public class OpenGlDebugWireframeRenderer extends AbstractDebugWireframeRenderer
}
this.init = true;
this.va = AbstractVertexAttribute.create();
this.va = GlAbstractVertexAttribute.create();
this.va.bind();
// Pos
this.va.setVertexAttribute(0, 0, VertexPointer.addVec3Pointer(false));
this.va.setVertexAttribute(0, 0, GlVertexPointer.addVec3Pointer(false));
this.va.completeAndCheck(Float.BYTES * 3);
this.basicShader = new ShaderProgram(
this.basicShader = new GlShaderProgram(
"shaders/debug/vert.vert",
"shaders/debug/frag.frag",
"vPosition"
@@ -1,4 +1,4 @@
package com.seibel.distanthorizons.common.render.nativeGl;
package com.seibel.distanthorizons.common.render.openGl;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiFramebuffer;
@@ -6,10 +6,11 @@ import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiShader
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiTextureCreatedParam;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.QuadElementBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.texture.*;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.apply.DhApplyShader;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.openGl.glObject.GlDhFramebuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GlQuadElementBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.texture.*;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.apply.GlDhApplyShader;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
import com.seibel.distanthorizons.core.config.Config;
@@ -28,7 +29,7 @@ import com.seibel.distanthorizons.coreapi.DependencyInjection.OverrideInjector;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL32;
public class OpenGlDhMetaRenderer implements IDhMetaRenderer
public class GlDhMetaRenderer implements IDhMetaRenderer
{
public static final DhLogger LOGGER = new DhLoggerBuilder()
.fileLevelConfig(Config.Common.Logging.logRendererEventToFile)
@@ -39,7 +40,7 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
.maxCountPerSecond(4)
.build();
public static final OpenGlDhMetaRenderer INSTANCE = new OpenGlDhMetaRenderer();
public static final GlDhMetaRenderer INSTANCE = new GlDhMetaRenderer();
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
@@ -57,10 +58,10 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
private IDhApiFramebuffer framebuffer;
/** will be null if MC's framebuffer is being used since MC already has a color texture */
@Nullable
private DhColorTexture nullableColorTexture;
private DHDepthTexture depthTexture;
private GlDhColorTexture nullableColorTexture;
private GlDhDepthTexture depthTexture;
/**
* If true the {@link OpenGlDhMetaRenderer#framebuffer} is the same as MC's.
* If true the {@link GlDhMetaRenderer#framebuffer} is the same as MC's.
* This should only be true in the case of Optifine so LODs won't be overwritten when shaders are enabled.
*/
private boolean usingMcFramebuffer = false;
@@ -95,7 +96,7 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
this.renderObjectsCreated = true;
}
this.shaderProgramForThisFrame = DhTerrainShaderProgram.INSTANCE;
this.shaderProgramForThisFrame = GlDhTerrainShaderProgram.INSTANCE;
IDhApiShaderProgram lodShaderProgramOverride = OverrideInjector.INSTANCE.get(IDhApiShaderProgram.class);
if (lodShaderProgramOverride != null && this.shaderProgramForThisFrame.overrideThisFrame())
{
@@ -105,7 +106,7 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
this.setGLState(renderParams, firstPass);
DhTerrainShaderProgram.INSTANCE.quadIBO.bind();
GlDhTerrainShaderProgram.INSTANCE.quadIBO.bind();
this.bindLightmap(renderParams.lightmap);
}
private void setGLState(
@@ -213,7 +214,7 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
{
// Due to using MC/Optifine's framebuffer we need to re-bind the depth texture,
// otherwise we'll be writing to MC/Optifine's depth texture which causes rendering issues
framebuffer.addDepthAttachment(this.depthTexture.getTextureId(), EDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
framebuffer.addDepthAttachment(this.depthTexture.getTextureId(), EGlDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
// don't clear the color texture, that removes the sky
@@ -241,8 +242,8 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
LOGGER.info("Setting up renderer");
DhTerrainShaderProgram.INSTANCE.quadIBO = new QuadElementBuffer();
DhTerrainShaderProgram.INSTANCE.quadIBO.reserve(LodQuadBuilder.getMaxBufferByteSize());
GlDhTerrainShaderProgram.INSTANCE.quadIBO = new GlQuadElementBuffer();
GlDhTerrainShaderProgram.INSTANCE.quadIBO.reserve(LodQuadBuilder.getMaxBufferByteSize());
// create or get the frame buffer
@@ -250,13 +251,13 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
{
// use MC/Optifine's default Framebuffer so shaders won't remove the LODs
int currentFramebufferId = MC_RENDER.getTargetFramebuffer();
this.framebuffer = new DhFramebuffer(currentFramebufferId);
this.framebuffer = new GlDhFramebuffer(currentFramebufferId);
this.usingMcFramebuffer = true;
}
else
{
// normal use case
this.framebuffer = new DhFramebuffer();
this.framebuffer = new GlDhFramebuffer();
this.usingMcFramebuffer = false;
}
@@ -299,22 +300,22 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
IDhApiFramebuffer framebufferOverride = OverrideInjector.INSTANCE.get(IDhApiFramebuffer.class);
this.depthTexture = new DHDepthTexture(this.textureWidth, this.textureHeight, EDhDepthBufferFormat.DEPTH32F);
this.framebuffer.addDepthAttachment(this.depthTexture.getTextureId(), EDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
this.depthTexture = new GlDhDepthTexture(this.textureWidth, this.textureHeight, EGlDhDepthBufferFormat.DEPTH32F);
this.framebuffer.addDepthAttachment(this.depthTexture.getTextureId(), EGlDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
if (framebufferOverride != null)
{
framebufferOverride.addDepthAttachment(this.depthTexture.getTextureId(), EDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
framebufferOverride.addDepthAttachment(this.depthTexture.getTextureId(), EGlDhDepthBufferFormat.DEPTH32F.isCombinedStencil());
}
// if we are using MC's frame buffer, a color texture is already present and shouldn't need to be bound
if (!this.usingMcFramebuffer)
{
this.nullableColorTexture = DhColorTexture.builder()
this.nullableColorTexture = GlDhColorTexture.builder()
.setDimensions(this.textureWidth, this.textureHeight)
.setInternalFormat(EDhInternalTextureFormat.RGBA8)
.setPixelType(EDhPixelType.UNSIGNED_BYTE)
.setPixelFormat(EDhPixelFormat.RGBA)
.setInternalFormat(EGlDhInternalTextureFormat.RGBA8)
.setPixelType(EGlDhPixelType.UNSIGNED_BYTE)
.setPixelFormat(EGlDhPixelFormat.RGBA)
.build();
this.framebuffer.addColorAttachment(0, this.nullableColorTexture.getTextureId());
@@ -361,12 +362,12 @@ public class OpenGlDhMetaRenderer implements IDhMetaRenderer
this.unbindLightmap();
DhTerrainShaderProgram.INSTANCE.quadIBO.unbind();
GlDhTerrainShaderProgram.INSTANCE.quadIBO.unbind();
this.shaderProgramForThisFrame.unbind();
}
@Override
public void applyToMcTexture(RenderParams renderParams) { DhApplyShader.INSTANCE.render(renderParams); }
public void applyToMcTexture(RenderParams renderParams) { GlDhApplyShader.INSTANCE.render(renderParams); }
//endregion
@@ -0,0 +1,66 @@
package com.seibel.distanthorizons.common.render.openGl;
import com.seibel.distanthorizons.common.render.openGl.generic.GlGenericObjectRenderer;
import com.seibel.distanthorizons.common.render.openGl.generic.GlGenericObjectVertexContainer;
import com.seibel.distanthorizons.common.render.openGl.glObject.GlDummyUniformData;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.fade.GlDhFarFadeRenderer;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.fade.GlVanillaFadeRenderer;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.fog.GlDhFogRenderer;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.ssao.GlDhSSAORenderer;
import com.seibel.distanthorizons.common.render.openGl.test.GlTestTriangleRenderer;
import com.seibel.distanthorizons.core.render.renderer.AbstractDebugWireframeRenderer;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.AbstractDhRenderApiDefinition;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IDhGenericObjectVertexBufferContainer;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodContainerUniformBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.renderPass.*;
public class GlDhRenderApiDefinition extends AbstractDhRenderApiDefinition
{
//=========//
// getters //
//=========//
//region
public String getApiName() { return "OpenGL"; }
//endregion
//============//
// singletons //
//============//
//region
@Override public IDhMetaRenderer getMetaRenderer() { return GlDhMetaRenderer.INSTANCE; }
@Override public IDhTerrainRenderer getTerrainRenderer() { return GlDhTerrainShaderProgram.INSTANCE; }
@Override public IDhSsaoRenderer getSsaoRenderer() { return GlDhSSAORenderer.INSTANCE; }
@Override public IDhFogRenderer getFogRenderer() { return GlDhFogRenderer.INSTANCE; }
@Override public IDhFarFadeRenderer getFarFadeRenderer() { return GlDhFarFadeRenderer.INSTANCE; }
@Override public AbstractDebugWireframeRenderer getDebugWireframeRenderer() { return GlDhDebugWireframeRenderer.INSTANCE; }
@Override public IDhVanillaFadeRenderer getVanillaFadeRenderer() { return GlVanillaFadeRenderer.INSTANCE; }
@Override public IDhTestTriangleRenderer getTestTriangleRenderer() { return GlTestTriangleRenderer.INSTANCE; }
//endregion
//===========//
// factories //
//===========//
//region
@Override public IDhGenericRenderer createGenericRenderer() { return GlGenericObjectRenderer.INSTANCE; }
@Override public IVertexBufferWrapper createVboWrapper(String name) { return new GLVertexBuffer(); }
@Override public ILodContainerUniformBufferWrapper createLodContainerUniformWrapper() { return new GlDummyUniformData(); }
@Override public IDhGenericObjectVertexBufferContainer createGenericVboContainer() { return new GlGenericObjectVertexContainer(); }
//endregion
}
@@ -17,21 +17,21 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl;
package com.seibel.distanthorizons.common.render.openGl;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiShaderProgram;
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.QuadElementBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.AbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.VertexAttributePostGL43;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.VertexAttributePreGL43;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.VertexPointer;
import com.seibel.distanthorizons.common.render.nativeGl.util.vertexFormat.LodVertexFormat;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GlQuadElementBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlAbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlVertexAttributePostGL43;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlVertexAttributePreGL43;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlVertexPointer;
import com.seibel.distanthorizons.common.render.openGl.util.vertexFormat.GlLodVertexFormat;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
import com.seibel.distanthorizons.core.config.Config;
@@ -57,21 +57,21 @@ import org.lwjgl.opengl.GL32;
* Handles rendering the normal LOD terrain.
* @see LodQuadBuilder
*/
public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShaderProgram, IDhTerrainRenderer
public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiShaderProgram, IDhTerrainRenderer
{
public static final DhLogger LOGGER = new DhLoggerBuilder()
.fileLevelConfig(Config.Common.Logging.logRendererEventToFile)
.build();
public static final DhTerrainShaderProgram INSTANCE = new DhTerrainShaderProgram();
public static final GlDhTerrainShaderProgram INSTANCE = new GlDhTerrainShaderProgram();
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
public QuadElementBuffer quadIBO = null;
public final AbstractVertexAttribute vao;
public GlQuadElementBuffer quadIBO = null;
public final GlAbstractVertexAttribute vao;
// uniforms //
//region
@@ -106,7 +106,7 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade
//=============//
//region
private DhTerrainShaderProgram()
private GlDhTerrainShaderProgram()
{
super(
"shaders/standard.vert",
@@ -138,30 +138,30 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade
if (GLProxy.getInstance().vertexAttributeBufferBindingSupported)
{
this.vao = new VertexAttributePostGL43(); // also binds AbstractVertexAttribute
this.vao = new GlVertexAttributePostGL43(); // also binds AbstractVertexAttribute
}
else
{
this.vao = new VertexAttributePreGL43(); // also binds AbstractVertexAttribute
this.vao = new GlVertexAttributePreGL43(); // also binds AbstractVertexAttribute
}
this.vao.bind();
// short: x, y, z, meta
// meta: byte skylight, byte blocklight, byte microOffset
this.vao.setVertexAttribute(0, 0, VertexPointer.addUnsignedShortsPointer(4, false, true));
this.vao.setVertexAttribute(0, 0, GlVertexPointer.addUnsignedShortsPointer(4, false, true));
// byte: r, g, b, a
this.vao.setVertexAttribute(0, 1, VertexPointer.addUnsignedBytesPointer(4, true, false));
this.vao.setVertexAttribute(0, 1, GlVertexPointer.addUnsignedBytesPointer(4, true, false));
// byte: iris material ID, normal index, 2 spacers
this.vao.setVertexAttribute(0, 2, VertexPointer.addUnsignedBytesPointer(4, true, true));
this.vao.setVertexAttribute(0, 2, GlVertexPointer.addUnsignedBytesPointer(4, true, true));
try
{
int vertexByteCount = LodVertexFormat.DH_VERTEX_FORMAT.getByteSize();
int vertexByteCount = GlLodVertexFormat.DH_VERTEX_FORMAT.getByteSize();
this.vao.completeAndCheck(vertexByteCount);
}
catch (RuntimeException e)
{
System.out.println(LodVertexFormat.DH_VERTEX_FORMAT);
System.out.println(GlLodVertexFormat.DH_VERTEX_FORMAT);
throw e;
}
@@ -331,8 +331,8 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
OpenGlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bind();
OpenGlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.setModelOffsetPos(modelPos);
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bind();
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.setModelOffsetPos(modelPos);
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos));
}
@@ -355,7 +355,7 @@ public class DhTerrainShaderProgram extends ShaderProgram implements IDhApiShade
int indexCount = (int)(vbo.getVertexCount() * 1.5);
vbo.bind();
OpenGlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bindVertexBuffer(vbo.getId());
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bindVertexBuffer(vbo.getId());
GL32.glDrawElements(
GL32.GL_TRIANGLES,
indexCount,
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.generic;
package com.seibel.distanthorizons.common.render.openGl.generic;
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiBlockMaterial;
@@ -29,9 +29,9 @@ import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhAp
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.GLElementBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLElementBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
@@ -66,7 +66,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @see IDhApiCustomRenderRegister
* @see DhApiRenderableBox
*/
public class OpenGlGenericObjectRenderer implements IDhGenericRenderer
public class GlGenericObjectRenderer implements IDhGenericRenderer
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -76,7 +76,7 @@ public class OpenGlGenericObjectRenderer implements IDhGenericRenderer
private static final DhApiRenderableBoxGroupShading DEFAULT_SHADING = DhApiRenderableBoxGroupShading.getUnshaded();
public static final OpenGlGenericObjectRenderer INSTANCE = new OpenGlGenericObjectRenderer();
public static final GlGenericObjectRenderer INSTANCE = new GlGenericObjectRenderer();
/**
* Can be used to troubleshoot the renderer.
@@ -176,7 +176,7 @@ public class OpenGlGenericObjectRenderer implements IDhGenericRenderer
//=============//
//region
private OpenGlGenericObjectRenderer() { }
private GlGenericObjectRenderer() { }
public void init()
{
@@ -207,8 +207,8 @@ public class OpenGlGenericObjectRenderer implements IDhGenericRenderer
// startup the renderer //
//======================//
this.instancedShaderProgram = new GenericObjectShaderProgram(true);
this.directShaderProgram = new GenericObjectShaderProgram(false);
this.instancedShaderProgram = new GlGenericObjectShaderProgram(true);
this.directShaderProgram = new GlGenericObjectShaderProgram(false);
this.createBuffers();
@@ -478,7 +478,7 @@ public class OpenGlGenericObjectRenderer implements IDhGenericRenderer
boxGroup.tryUpdateInstancedDataAsync();
// skip groups that haven't been uploaded yet
if (boxGroup.vertexBufferContainer.getState() != OpenGlGenericObjectVertexContainer.EState.RENDER)
if (boxGroup.vertexBufferContainer.getState() != GlGenericObjectVertexContainer.EState.RENDER)
{
continue;
}
@@ -560,7 +560,7 @@ public class OpenGlGenericObjectRenderer implements IDhGenericRenderer
// Bind instance data //
profiler.popPush("binding");
OpenGlGenericObjectVertexContainer container = (OpenGlGenericObjectVertexContainer)(boxGroup.vertexBufferContainer);
GlGenericObjectVertexContainer container = (GlGenericObjectVertexContainer)(boxGroup.vertexBufferContainer);
GL32.glBindBuffer(GL32.GL_ARRAY_BUFFER, container.color);
GL32.glEnableVertexAttribArray(1);
@@ -1,4 +1,4 @@
package com.seibel.distanthorizons.common.render.nativeGl.generic;
package com.seibel.distanthorizons.common.render.openGl.generic;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiGenericObjectShaderProgram;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup;
@@ -7,23 +7,22 @@ import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.AbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.VertexPointer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlAbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlVertexPointer;
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import com.seibel.distanthorizons.core.util.math.Vec3f;
import com.seibel.distanthorizons.core.wrapperInterfaces.misc.ILightMapWrapper;
public class GenericObjectShaderProgram extends ShaderProgram implements IDhApiGenericObjectShaderProgram
public class GlGenericObjectShaderProgram extends GlShaderProgram implements IDhApiGenericObjectShaderProgram
{
public static final String VERTEX_SHADER_INSTANCED_PATH = "shaders/genericObject/instanced/vert.vert";
public static final String VERTEX_SHADER_DIRECT_PATH = "shaders/genericObject/direct/vert.vert";
public static final String FRAGMENT_SHADER_INSTANCED_PATH = "shaders/genericObject/instanced/frag.frag";
public static final String FRAGMENT_SHADER_DIRECT_PATH = "shaders/genericObject/direct/frag.frag";
public final AbstractVertexAttribute va;
public final GlAbstractVertexAttribute va;
// shader uniforms
@@ -53,7 +52,7 @@ public class GenericObjectShaderProgram extends ShaderProgram implements IDhApiG
// constructor //
//=============//
public GenericObjectShaderProgram(boolean useInstancedRendering)
public GlGenericObjectShaderProgram(boolean useInstancedRendering)
{
super(
useInstancedRendering ? VERTEX_SHADER_INSTANCED_PATH : VERTEX_SHADER_DIRECT_PATH,
@@ -61,10 +60,10 @@ public class GenericObjectShaderProgram extends ShaderProgram implements IDhApiG
"vPosition"
);
this.va = AbstractVertexAttribute.create();
this.va = GlAbstractVertexAttribute.create();
this.va.bind();
// Pos
this.va.setVertexAttribute(0, 0, VertexPointer.addVec3Pointer(false));
this.va.setVertexAttribute(0, 0, GlVertexPointer.addVec3Pointer(false));
this.va.completeAndCheck(Float.BYTES * 3);
this.directShaderTransformUniform = this.tryGetUniformLocation("uTransform");
@@ -1,4 +1,4 @@
package com.seibel.distanthorizons.common.render.nativeGl.generic;
package com.seibel.distanthorizons.common.render.openGl.generic;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
@@ -17,7 +17,7 @@ import java.util.List;
*
* @see RenderableBoxGroup
*/
public class OpenGlGenericObjectVertexContainer implements IDhGenericObjectVertexBufferContainer
public class GlGenericObjectVertexContainer implements IDhGenericObjectVertexBufferContainer
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -106,7 +106,7 @@ public class OpenGlGenericObjectVertexContainer implements IDhGenericObjectVerte
this.materialData[i] = box.material;
}
this.state = OpenGlGenericObjectVertexContainer.EState.READY_TO_UPLOAD;
this.state = GlGenericObjectVertexContainer.EState.READY_TO_UPLOAD;
}
public void uploadDataToGpu()
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject;
package com.seibel.distanthorizons.common.render.openGl.glObject;
import com.seibel.distanthorizons.api.enums.config.EDhApiGLErrorHandlingMode;
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
@@ -26,10 +26,8 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.jar.EPlatform;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.util.TimerUtil;
import com.seibel.distanthorizons.core.util.objects.GLMessages.*;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import com.seibel.distanthorizons.coreapi.ModInfo;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL;
@@ -40,9 +38,7 @@ import org.lwjgl.opengl.GLUtil;
import java.io.PrintStream;
import java.util.Collections;
import java.util.Set;
import java.util.Timer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* A singleton that holds references to different openGL contexts
@@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject;
package com.seibel.distanthorizons.common.render.openGl.glObject;
import com.seibel.distanthorizons.common.render.openGl.glObject.enums.GLEnums;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import org.lwjgl.opengl.GL32;
public class GLState implements AutoCloseable
@@ -1,12 +1,10 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject.texture;
package com.seibel.distanthorizons.common.render.openGl.glObject;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiFramebuffer;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import org.lwjgl.opengl.GL32;
public class DhFramebuffer implements IDhApiFramebuffer
public class GlDhFramebuffer implements IDhApiFramebuffer
{
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -19,10 +17,10 @@ public class DhFramebuffer implements IDhApiFramebuffer
//=============//
//region
public DhFramebuffer() { this.id = GL32.glGenFramebuffers(); }
public GlDhFramebuffer() { this.id = GL32.glGenFramebuffers(); }
/** For internal use by Iris, do not remove. */
public DhFramebuffer(int id) { this.id = id; }
public GlDhFramebuffer(int id) { this.id = id; }
//endregion
@@ -1,4 +1,4 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject;
package com.seibel.distanthorizons.common.render.openGl.glObject;
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodContainerUniformBufferWrapper;
@@ -7,7 +7,7 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.ILodCont
* With OpenGL all uniform data is uploaded during the rendering phase
* so nothing is needed here.
*/
public class OpenGlDummyUniformData implements ILodContainerUniformBufferWrapper
public class GlDummyUniformData implements ILodContainerUniformBufferWrapper
{
@Override public void createUniformData(LodBufferContainer bufferContainer) { }
@Override public void tryUpload() { }
@@ -17,13 +17,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer;
package com.seibel.distanthorizons.common.render.openGl.glObject.buffer;
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer;
package com.seibel.distanthorizons.common.render.openGl.glObject.buffer;
import org.lwjgl.opengl.GL32;
@@ -17,11 +17,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer;
package com.seibel.distanthorizons.common.render.openGl.glObject.buffer;
import java.nio.ByteBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.render.objects.IVertexBufferWrapper;
import org.lwjgl.opengl.GL32;
@@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer;
package com.seibel.distanthorizons.common.render.openGl.glObject.buffer;
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLEnums;
import com.seibel.distanthorizons.common.render.openGl.glObject.enums.GLEnums;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import org.lwjgl.opengl.GL32;
@@ -29,7 +29,7 @@ import org.lwjgl.system.MemoryUtil;
import java.nio.ByteBuffer;
/** AKA Index Buffer TODO RENAME */
public class QuadElementBuffer extends GLElementBuffer
public class GlQuadElementBuffer extends GLElementBuffer
{
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -40,7 +40,7 @@ public class QuadElementBuffer extends GLElementBuffer
//=============//
//region
public QuadElementBuffer() { super(false); }
public GlQuadElementBuffer() { super(false); }
public void reserve(int quadCount)
{
@@ -0,0 +1,9 @@
package com.seibel.distanthorizons.common.render.openGl.glObject.enums;
public enum EGlVersion
{
GL_11,
GL_12,
GL_30,
GL_31
}
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject;
package com.seibel.distanthorizons.common.render.openGl.glObject.enums;
import static org.lwjgl.opengl.GL46.*;
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.shader;
package com.seibel.distanthorizons.common.render.openGl.glObject.shader;
import java.io.BufferedReader;
import java.io.FileInputStream;
@@ -41,7 +41,7 @@ import org.lwjgl.system.NativeType;
* This object holds a OpenGL reference to a shader
* and allows for reading in and compiling a shader file.
*/
public class Shader
public class GlShader
{
private static final DhLogger LOGGER = new DhLoggerBuilder()
.fileLevelConfig(Config.Common.Logging.logRendererGLEventToFile)
@@ -66,7 +66,7 @@ public class Shader
* @param sourceString File path of the shader
* @throws RuntimeException if the shader fails to compile
*/
public Shader(int type, String sourceString)
public GlShader(int type, String sourceString)
{
LOGGER.info("Loading shader with type: ["+type+"]");
LOGGER.debug("Source: \n["+sourceString+"]");
@@ -154,7 +154,7 @@ public class Shader
}
else
{
in = Shader.class.getClassLoader().getResourceAsStream(path); // Note: path seperator should be '/'
in = GlShader.class.getClassLoader().getResourceAsStream(path); // Note: path seperator should be '/'
if (in == null)
{
throw new FileNotFoundException("Shader file not found in resource: " + path);
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.shader;
package com.seibel.distanthorizons.common.render.openGl.glObject.shader;
import java.awt.Color;
import java.nio.FloatBuffer;
@@ -36,7 +36,7 @@ import com.seibel.distanthorizons.core.util.math.Vec3f;
* The reason for many of these simple wrapper methods is as reminders of what
* can (and needs to be) done with a shader program.
*/
public class ShaderProgram
public class GlShaderProgram
{
/** Stores the handle of the program. */
public final int id;
@@ -48,25 +48,25 @@ public class ShaderProgram
//=============//
//region
public ShaderProgram(String vertResourcePath, String fragResourcePath, String attribute) { this(vertResourcePath, fragResourcePath, new String[]{ attribute }); }
public GlShaderProgram(String vertResourcePath, String fragResourcePath, String attribute) { this(vertResourcePath, fragResourcePath, new String[]{ attribute }); }
/**
* @param vertResourcePath the relative path the vertex shader should be found
* @param fragResourcePath the relative path the fragment shader should be found
*/
public ShaderProgram(String vertResourcePath, String fragResourcePath, String[] attributes)
public GlShaderProgram(String vertResourcePath, String fragResourcePath, String[] attributes)
{
this.id = GL32.glCreateProgram();
{
String shaderString = Shader.loadFile(vertResourcePath, false);
Shader vertShader = new Shader(GL32.GL_VERTEX_SHADER, shaderString);
String shaderString = GlShader.loadFile(vertResourcePath, false);
GlShader vertShader = new GlShader(GL32.GL_VERTEX_SHADER, shaderString);
GL32.glAttachShader(this.id, vertShader.id);
vertShader.free();
}
{
String shaderString = Shader.loadFile(fragResourcePath, false);
Shader fragShader = new Shader(GL32.GL_FRAGMENT_SHADER, shaderString);
String shaderString = GlShader.loadFile(fragResourcePath, false);
GlShader fragShader = new GlShader(GL32.GL_FRAGMENT_SHADER, shaderString);
GL32.glAttachShader(this.id, fragShader.id);
fragShader.free();
}
@@ -167,27 +167,27 @@ public class ShaderProgram
/** Requires a bound ShaderProgram. */
public void setUniform(int location, boolean value) { GL32.glUniform1i(location, value ? 1 : 0); }
/** @see ShaderProgram#setUniform(int, boolean) */
/** @see GlShaderProgram#setUniform(int, boolean) */
public void trySetUniform(int location, boolean value) { if (location != -1) { this.setUniform(location, value); } }
/** Requires a bound ShaderProgram. */
public void setUniform(int location, int value) { GL32.glUniform1i(location, value); }
/** @see ShaderProgram#setUniform(int, int) */
/** @see GlShaderProgram#setUniform(int, int) */
public void trySetUniform(int location, int value) { if (location != -1) { this.setUniform(location, value); } }
/** Requires a bound ShaderProgram. */
public void setUniform(int location, float value) { GL32.glUniform1f(location, value); }
/** @see ShaderProgram#setUniform(int, float) */
/** @see GlShaderProgram#setUniform(int, float) */
public void trySetUniform(int location, float value) { if (location != -1) { this.setUniform(location, value); } }
/** Requires a bound ShaderProgram. */
public void setUniform(int location, Vec3f value) { GL32.glUniform3f(location, value.x, value.y, value.z); }
/** @see ShaderProgram#setUniform(int, Vec3f) */
/** @see GlShaderProgram#setUniform(int, Vec3f) */
public void trySetUniform(int location, Vec3f value) { if (location != -1) { this.setUniform(location, value); } }
/** Requires a bound ShaderProgram. */
public void setUniform(int location, DhApiVec3i value) { GL32.glUniform3i(location, value.x, value.y, value.z); }
/** @see ShaderProgram#setUniform(int, Mat4f) */
/** @see GlShaderProgram#setUniform(int, Mat4f) */
public void trySetUniform(int location, DhApiVec3i value) { if (location != -1) { this.setUniform(location, value); } }
/** Requires a bound ShaderProgram. */
@@ -200,7 +200,7 @@ public class ShaderProgram
GL32.glUniformMatrix4fv(location, false, buffer);
}
}
/** @see ShaderProgram#setUniform(int, Mat4f) */
/** @see GlShaderProgram#setUniform(int, Mat4f) */
public void trySetUniform(int location, Mat4f value) { if (location != -1) { this.setUniform(location, value); } }
/**
@@ -215,7 +215,7 @@ public class ShaderProgram
value.getBlue() / 256.0f,
value.getAlpha() / 256.0f);
}
/** @see ShaderProgram#setUniform(int, Color) */
/** @see GlShaderProgram#setUniform(int, Color) */
public void trySetUniform(int location, Color value) { if (location != -1) { this.setUniform(location, value); } }
//endregion
@@ -1,10 +1,10 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject.texture;
package com.seibel.distanthorizons.common.render.openGl.glObject.texture;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL30C;
import org.lwjgl.opengl.GL43C;
public enum EDhDepthBufferFormat
public enum EGlDhDepthBufferFormat
{
DEPTH(false),
DEPTH16(false),
@@ -19,43 +19,43 @@ public enum EDhDepthBufferFormat
private final boolean combinedStencil;
EDhDepthBufferFormat(boolean combinedStencil) { this.combinedStencil = combinedStencil; }
EGlDhDepthBufferFormat(boolean combinedStencil) { this.combinedStencil = combinedStencil; }
@Nullable
public static EDhDepthBufferFormat fromGlEnum(int glenum)
public static EGlDhDepthBufferFormat fromGlEnum(int glenum)
{
switch (glenum)
{
case GL30C.GL_DEPTH_COMPONENT:
return EDhDepthBufferFormat.DEPTH;
return EGlDhDepthBufferFormat.DEPTH;
case GL30C.GL_DEPTH_COMPONENT16:
return EDhDepthBufferFormat.DEPTH16;
return EGlDhDepthBufferFormat.DEPTH16;
case GL30C.GL_DEPTH_COMPONENT24:
return EDhDepthBufferFormat.DEPTH24;
return EGlDhDepthBufferFormat.DEPTH24;
case GL30C.GL_DEPTH_COMPONENT32:
return EDhDepthBufferFormat.DEPTH32;
return EGlDhDepthBufferFormat.DEPTH32;
case GL30C.GL_DEPTH_COMPONENT32F:
return EDhDepthBufferFormat.DEPTH32F;
return EGlDhDepthBufferFormat.DEPTH32F;
case GL30C.GL_DEPTH_STENCIL:
return EDhDepthBufferFormat.DEPTH_STENCIL;
return EGlDhDepthBufferFormat.DEPTH_STENCIL;
case GL30C.GL_DEPTH24_STENCIL8:
return EDhDepthBufferFormat.DEPTH24_STENCIL8;
return EGlDhDepthBufferFormat.DEPTH24_STENCIL8;
case GL30C.GL_DEPTH32F_STENCIL8:
return EDhDepthBufferFormat.DEPTH32F_STENCIL8;
return EGlDhDepthBufferFormat.DEPTH32F_STENCIL8;
default:
return null;
}
}
public static EDhDepthBufferFormat fromGlEnumOrDefault(int glenum)
public static EGlDhDepthBufferFormat fromGlEnumOrDefault(int glenum)
{
EDhDepthBufferFormat format = fromGlEnum(glenum);
EGlDhDepthBufferFormat format = fromGlEnum(glenum);
if (format == null)
{
// yolo, just assume it's GL_DEPTH_COMPONENT
return EDhDepthBufferFormat.DEPTH;
return EGlDhDepthBufferFormat.DEPTH;
}
return format;
}
@@ -0,0 +1,131 @@
package com.seibel.distanthorizons.common.render.openGl.glObject.texture;
import com.seibel.distanthorizons.common.render.openGl.glObject.enums.EGlVersion;
import org.lwjgl.opengl.GL11C;
import org.lwjgl.opengl.GL30C;
import org.lwjgl.opengl.GL31C;
import java.util.Locale;
import java.util.Optional;
public enum EGlDhInternalTextureFormat
{
RGBA(GL11C.GL_RGBA, EGlVersion.GL_11, EGlDhPixelFormat.RGBA),
// 8-bit normalized
R8(GL30C.GL_R8, EGlVersion.GL_30, EGlDhPixelFormat.RED),
RG8(GL30C.GL_RG8, EGlVersion.GL_30, EGlDhPixelFormat.RG),
RGB8(GL11C.GL_RGB8, EGlVersion.GL_11, EGlDhPixelFormat.RGB),
RGBA8(GL11C.GL_RGBA8, EGlVersion.GL_11, EGlDhPixelFormat.RGBA),
// 8-bit signed normalized
R8_SNORM(GL31C.GL_R8_SNORM, EGlVersion.GL_31, EGlDhPixelFormat.RED),
RG8_SNORM(GL31C.GL_RG8_SNORM, EGlVersion.GL_31, EGlDhPixelFormat.RG),
RGB8_SNORM(GL31C.GL_RGB8_SNORM, EGlVersion.GL_31, EGlDhPixelFormat.RGB),
RGBA8_SNORM(GL31C.GL_RGBA8_SNORM, EGlVersion.GL_31, EGlDhPixelFormat.RGBA),
// 16-bit normalized
R16(GL30C.GL_R16, EGlVersion.GL_30, EGlDhPixelFormat.RED),
RG16(GL30C.GL_RG16, EGlVersion.GL_30, EGlDhPixelFormat.RG),
RGB16(GL11C.GL_RGB16, EGlVersion.GL_11, EGlDhPixelFormat.RGB),
RGBA16(GL11C.GL_RGBA16, EGlVersion.GL_11, EGlDhPixelFormat.RGBA),
// 16-bit signed normalized
R16_SNORM(GL31C.GL_R16_SNORM, EGlVersion.GL_31, EGlDhPixelFormat.RED),
RG16_SNORM(GL31C.GL_RG16_SNORM, EGlVersion.GL_31, EGlDhPixelFormat.RG),
RGB16_SNORM(GL31C.GL_RGB16_SNORM, EGlVersion.GL_31, EGlDhPixelFormat.RGB),
RGBA16_SNORM(GL31C.GL_RGBA16_SNORM, EGlVersion.GL_31, EGlDhPixelFormat.RGBA),
// 16-bit float
R16F(GL30C.GL_R16F, EGlVersion.GL_30, EGlDhPixelFormat.RED),
RG16F(GL30C.GL_RG16F, EGlVersion.GL_30, EGlDhPixelFormat.RG),
RGB16F(GL30C.GL_RGB16F, EGlVersion.GL_30, EGlDhPixelFormat.RGB),
RGBA16F(GL30C.GL_RGBA16F, EGlVersion.GL_30, EGlDhPixelFormat.RGBA),
// 32-bit float
R32F(GL30C.GL_R32F, EGlVersion.GL_30, EGlDhPixelFormat.RED),
RG32F(GL30C.GL_RG32F, EGlVersion.GL_30, EGlDhPixelFormat.RG),
RGB32F(GL30C.GL_RGB32F, EGlVersion.GL_30, EGlDhPixelFormat.RGB),
RGBA32F(GL30C.GL_RGBA32F, EGlVersion.GL_30, EGlDhPixelFormat.RGBA),
// 8-bit integer
R8I(GL30C.GL_R8I, EGlVersion.GL_30, EGlDhPixelFormat.RED_INTEGER),
RG8I(GL30C.GL_RG8I, EGlVersion.GL_30, EGlDhPixelFormat.RG_INTEGER),
RGB8I(GL30C.GL_RGB8I, EGlVersion.GL_30, EGlDhPixelFormat.RGB_INTEGER),
RGBA8I(GL30C.GL_RGBA8I, EGlVersion.GL_30, EGlDhPixelFormat.RGBA_INTEGER),
// 8-bit unsigned integer
R8UI(GL30C.GL_R8UI, EGlVersion.GL_30, EGlDhPixelFormat.RED_INTEGER),
RG8UI(GL30C.GL_RG8UI, EGlVersion.GL_30, EGlDhPixelFormat.RG_INTEGER),
RGB8UI(GL30C.GL_RGB8UI, EGlVersion.GL_30, EGlDhPixelFormat.RGB_INTEGER),
RGBA8UI(GL30C.GL_RGBA8UI, EGlVersion.GL_30, EGlDhPixelFormat.RGBA_INTEGER),
// 16-bit integer
R16I(GL30C.GL_R16I, EGlVersion.GL_30, EGlDhPixelFormat.RED_INTEGER),
RG16I(GL30C.GL_RG16I, EGlVersion.GL_30, EGlDhPixelFormat.RG_INTEGER),
RGB16I(GL30C.GL_RGB16I, EGlVersion.GL_30, EGlDhPixelFormat.RGB_INTEGER),
RGBA16I(GL30C.GL_RGBA16I, EGlVersion.GL_30, EGlDhPixelFormat.RGBA_INTEGER),
// 16-bit unsigned integer
R16UI(GL30C.GL_R16UI, EGlVersion.GL_30, EGlDhPixelFormat.RED_INTEGER),
RG16UI(GL30C.GL_RG16UI, EGlVersion.GL_30, EGlDhPixelFormat.RG_INTEGER),
RGB16UI(GL30C.GL_RGB16UI, EGlVersion.GL_30, EGlDhPixelFormat.RGB_INTEGER),
RGBA16UI(GL30C.GL_RGBA16UI, EGlVersion.GL_30, EGlDhPixelFormat.RGBA_INTEGER),
// 32-bit integer
R32I(GL30C.GL_R32I, EGlVersion.GL_30, EGlDhPixelFormat.RED_INTEGER),
RG32I(GL30C.GL_RG32I, EGlVersion.GL_30, EGlDhPixelFormat.RG_INTEGER),
RGB32I(GL30C.GL_RGB32I, EGlVersion.GL_30, EGlDhPixelFormat.RGB_INTEGER),
RGBA32I(GL30C.GL_RGBA32I, EGlVersion.GL_30, EGlDhPixelFormat.RGBA_INTEGER),
// 32-bit unsigned integer
R32UI(GL30C.GL_R32UI, EGlVersion.GL_30, EGlDhPixelFormat.RED_INTEGER),
RG32UI(GL30C.GL_RG32UI, EGlVersion.GL_30, EGlDhPixelFormat.RG_INTEGER),
RGB32UI(GL30C.GL_RGB32UI, EGlVersion.GL_30, EGlDhPixelFormat.RGB_INTEGER),
RGBA32UI(GL30C.GL_RGBA32UI, EGlVersion.GL_30, EGlDhPixelFormat.RGBA_INTEGER),
// Mixed
R3_G3_B2(GL11C.GL_R3_G3_B2, EGlVersion.GL_11, EGlDhPixelFormat.RGB),
RGB5_A1(GL11C.GL_RGB5_A1, EGlVersion.GL_11, EGlDhPixelFormat.RGBA),
RGB10_A2(GL11C.GL_RGB10_A2, EGlVersion.GL_11, EGlDhPixelFormat.RGBA),
R11F_G11F_B10F(GL30C.GL_R11F_G11F_B10F, EGlVersion.GL_30, EGlDhPixelFormat.RGB),
RGB9_E5(GL30C.GL_RGB9_E5, EGlVersion.GL_30, EGlDhPixelFormat.RGB);
private final int glFormat;
private final EGlVersion minimumGlVersion;
private final EGlDhPixelFormat expectedPixelFormat;
EGlDhInternalTextureFormat(int glFormat, EGlVersion minimumGlVersion, EGlDhPixelFormat expectedPixelFormat)
{
this.glFormat = glFormat;
this.minimumGlVersion = minimumGlVersion;
this.expectedPixelFormat = expectedPixelFormat;
}
public static Optional<EGlDhInternalTextureFormat> fromString(String name)
{
try
{
return Optional.of(EGlDhInternalTextureFormat.valueOf(name.toUpperCase(Locale.US)));
}
catch (IllegalArgumentException e)
{
return Optional.empty();
}
}
public int getGlFormat() { return this.glFormat; }
public EGlDhPixelFormat getPixelFormat() { return this.expectedPixelFormat; }
public EGlVersion getMinimumGlVersion() { return this.minimumGlVersion; }
}
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject.texture;
package com.seibel.distanthorizons.common.render.openGl.glObject.texture;
import com.seibel.distanthorizons.common.render.openGl.glObject.enums.EGlVersion;
import org.lwjgl.opengl.GL11C;
import org.lwjgl.opengl.GL12C;
import org.lwjgl.opengl.GL30C;
@@ -7,7 +8,7 @@ import org.lwjgl.opengl.GL30C;
import java.util.Locale;
import java.util.Optional;
public enum EDhPixelFormat
public enum EGlDhPixelFormat
{
RED(GL11C.GL_RED, EGlVersion.GL_11, false),
RG(GL30C.GL_RG, EGlVersion.GL_30, false),
@@ -30,7 +31,7 @@ public enum EDhPixelFormat
EDhPixelFormat(int glFormat, EGlVersion minimumGlVersion, boolean isInteger)
EGlDhPixelFormat(int glFormat, EGlVersion minimumGlVersion, boolean isInteger)
{
this.glFormat = glFormat;
this.minimumGlVersion = minimumGlVersion;
@@ -39,11 +40,11 @@ public enum EDhPixelFormat
public static Optional<EDhPixelFormat> fromString(String name)
public static Optional<EGlDhPixelFormat> fromString(String name)
{
try
{
return Optional.of(EDhPixelFormat.valueOf(name.toUpperCase(Locale.US)));
return Optional.of(EGlDhPixelFormat.valueOf(name.toUpperCase(Locale.US)));
}
catch (IllegalArgumentException e)
{
@@ -1,5 +1,6 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject.texture;
package com.seibel.distanthorizons.common.render.openGl.glObject.texture;
import com.seibel.distanthorizons.common.render.openGl.glObject.enums.EGlVersion;
import org.lwjgl.opengl.GL11C;
import org.lwjgl.opengl.GL12C;
import org.lwjgl.opengl.GL30C;
@@ -7,7 +8,7 @@ import org.lwjgl.opengl.GL30C;
import java.util.Locale;
import java.util.Optional;
public enum EDhPixelType
public enum EGlDhPixelType
{
BYTE(GL11C.GL_BYTE, EGlVersion.GL_11),
SHORT(GL11C.GL_SHORT, EGlVersion.GL_11),
@@ -37,7 +38,7 @@ public enum EDhPixelType
EDhPixelType(int glFormat, EGlVersion minimumGlVersion)
EGlDhPixelType(int glFormat, EGlVersion minimumGlVersion)
{
this.glFormat = glFormat;
this.minimumGlVersion = minimumGlVersion;
@@ -45,11 +46,11 @@ public enum EDhPixelType
public static Optional<EDhPixelType> fromString(String name)
public static Optional<EGlDhPixelType> fromString(String name)
{
try
{
return Optional.of(EDhPixelType.valueOf(name.toUpperCase(Locale.US)));
return Optional.of(EGlDhPixelType.valueOf(name.toUpperCase(Locale.US)));
}
catch (IllegalArgumentException e)
{
@@ -1,4 +1,4 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject.texture;
package com.seibel.distanthorizons.common.render.openGl.glObject.texture;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import org.joml.Vector2i;
@@ -8,14 +8,14 @@ import org.lwjgl.opengl.GL43C;
import java.nio.ByteBuffer;
public class DhColorTexture
public class GlDhColorTexture
{
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
private final EDhInternalTextureFormat internalFormat;
private final EDhPixelFormat format;
private final EDhPixelType type;
private final EGlDhInternalTextureFormat internalFormat;
private final EGlDhPixelFormat format;
private final EGlDhPixelType type;
private int width;
private int height;
@@ -31,7 +31,7 @@ public class DhColorTexture
// constructor //
//=============//
public DhColorTexture(Builder builder)
public GlDhColorTexture(Builder builder)
{
this.isValid = true;
@@ -91,7 +91,7 @@ public class DhColorTexture
this.resizeTexture(this.id, width, height);
}
public EDhInternalTextureFormat getInternalFormat() { return this.internalFormat; }
public EGlDhInternalTextureFormat getInternalFormat() { return this.internalFormat; }
public int getTextureId()
{
@@ -130,18 +130,18 @@ public class DhColorTexture
public static class Builder
{
private EDhInternalTextureFormat internalFormat = EDhInternalTextureFormat.RGBA8;
private EGlDhInternalTextureFormat internalFormat = EGlDhInternalTextureFormat.RGBA8;
private int width = 0;
private int height = 0;
private EDhPixelFormat format = EDhPixelFormat.RGBA;
private EDhPixelType type = EDhPixelType.UNSIGNED_BYTE;
private EGlDhPixelFormat format = EGlDhPixelFormat.RGBA;
private EGlDhPixelType type = EGlDhPixelType.UNSIGNED_BYTE;
private Builder()
{
// No-op
}
public Builder setInternalFormat(EDhInternalTextureFormat format)
public Builder setInternalFormat(EGlDhInternalTextureFormat format)
{
this.internalFormat = format;
return this;
@@ -165,19 +165,19 @@ public class DhColorTexture
return this;
}
public Builder setPixelFormat(EDhPixelFormat pixelFormat)
public Builder setPixelFormat(EGlDhPixelFormat pixelFormat)
{
this.format = pixelFormat;
return this;
}
public Builder setPixelType(EDhPixelType pixelType)
public Builder setPixelType(EGlDhPixelType pixelType)
{
this.type = pixelType;
return this;
}
public DhColorTexture build() { return new DhColorTexture(this); }
public GlDhColorTexture build() { return new GlDhColorTexture(this); }
}
}
@@ -1,4 +1,4 @@
package com.seibel.distanthorizons.common.render.nativeGl.glObject.texture;
package com.seibel.distanthorizons.common.render.openGl.glObject.texture;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import org.lwjgl.opengl.GL11C;
@@ -7,13 +7,13 @@ import org.lwjgl.opengl.GL43C;
import java.nio.ByteBuffer;
public class DHDepthTexture
public class GlDhDepthTexture
{
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
private int id;
public DHDepthTexture(int width, int height, EDhDepthBufferFormat format)
public GlDhDepthTexture(int width, int height, EGlDhDepthBufferFormat format)
{
this.id = GL43C.glGenTextures();
@@ -32,9 +32,9 @@ public class DHDepthTexture
}
// For internal use by Iris for copying data. Do not use this in DH.
public DHDepthTexture(int id) { this.id = id; }
public GlDhDepthTexture(int id) { this.id = id; }
public void resize(int width, int height, EDhDepthBufferFormat format)
public void resize(int width, int height, EGlDhDepthBufferFormat format)
{
GL43C.glBindTexture(GL43C.GL_TEXTURE_2D, this.getTextureId());
GL43C.glTexImage2D(GL11C.GL_TEXTURE_2D, 0, format.getGlInternalFormat(), width, height, 0,
@@ -17,18 +17,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute;
package com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLProxy;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLProxy;
import org.lwjgl.opengl.GL32;
/**
* Base for binding/unbinding Vertex Attribute objects (VAO's).
*
* @see VertexAttributePostGL43
* @see VertexAttributePreGL43
* @see GlVertexAttributePostGL43
* @see GlVertexAttributePreGL43
*/
public abstract class AbstractVertexAttribute
public abstract class GlAbstractVertexAttribute
{
/** Stores the handle of the AbstractVertexAttribute. */
public final int id;
@@ -40,21 +40,21 @@ public abstract class AbstractVertexAttribute
//==============//
// This will bind AbstractVertexAttribute
protected AbstractVertexAttribute()
protected GlAbstractVertexAttribute()
{
this.id = GL32.glGenVertexArrays();
GL32.glBindVertexArray(this.id);
}
public static AbstractVertexAttribute create()
public static GlAbstractVertexAttribute create()
{
if (GLProxy.getInstance().vertexAttributeBufferBindingSupported)
{
return new VertexAttributePostGL43();
return new GlVertexAttributePostGL43();
}
else
{
return new VertexAttributePreGL43();
return new GlVertexAttributePreGL43();
}
}
@@ -85,7 +85,7 @@ public abstract class AbstractVertexAttribute
/** Requires both AbstractVertexAttribute to be bound */
public abstract void unbindBuffersFromBindingPoint(int bindingPoint);
/** Requires both AbstractVertexAttribute to be bound */
public abstract void setVertexAttribute(int bindingPoint, int attributeIndex, VertexPointer attribute);
public abstract void setVertexAttribute(int bindingPoint, int attributeIndex, GlVertexPointer attribute);
/** Requires both AbstractVertexAttribute to be bound */
public abstract void completeAndCheck(int expectedStrideSize);
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute;
package com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -33,7 +33,7 @@ import org.lwjgl.opengl.GL43;
* Since I no longer need to implement binding points, I also no
* longer needs to keep track of Pointers.
*/
public final class VertexAttributePostGL43 extends AbstractVertexAttribute
public final class GlVertexAttributePostGL43 extends GlAbstractVertexAttribute
{
private static final DhLogger LOGGER = new DhLoggerBuilder()
.fileLevelConfig(Config.Common.Logging.logRendererGLEventToFile)
@@ -50,8 +50,8 @@ public final class VertexAttributePostGL43 extends AbstractVertexAttribute
// constructor //
//=============//
/** This will bind the {@link AbstractVertexAttribute} */
public VertexAttributePostGL43()
/** This will bind the {@link GlAbstractVertexAttribute} */
public GlVertexAttributePostGL43()
{
super(); // also bind AbstractVertexAttribute
}
@@ -110,7 +110,7 @@ public final class VertexAttributePostGL43 extends AbstractVertexAttribute
/** Requires AbstractVertexAttribute to be bound */
@Override
public void setVertexAttribute(int bindingPoint, int attributeIndex, VertexPointer attribute)
public void setVertexAttribute(int bindingPoint, int attributeIndex, GlVertexPointer attribute)
{
if (attribute.useInteger)
{
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute;
package com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute;
import java.util.ArrayList;
import java.util.Iterator;
@@ -30,7 +30,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import org.lwjgl.opengl.GL32;
public final class VertexAttributePreGL43 extends AbstractVertexAttribute
public final class GlVertexAttributePreGL43 extends GlAbstractVertexAttribute
{
private static final DhLogger LOGGER = new DhLoggerBuilder()
.fileLevelConfig(Config.Common.Logging.logRendererGLEventToFile)
@@ -42,11 +42,11 @@ public final class VertexAttributePreGL43 extends AbstractVertexAttribute
// happen every frame, and the speed directly affects fps
int strideSize = 0;
int[][] bindingPointsToIndex;
VertexPointer[] pointers;
GlVertexPointer[] pointers;
int[] pointersOffset;
TreeMap<Integer, TreeSet<Integer>> bindingPointsToIndexBuilder;
ArrayList<VertexPointer> pointersBuilder;
ArrayList<GlVertexPointer> pointersBuilder;
@@ -54,8 +54,8 @@ public final class VertexAttributePreGL43 extends AbstractVertexAttribute
// constructor //
//=============//
/** This will bind the {@link AbstractVertexAttribute} */
public VertexAttributePreGL43()
/** This will bind the {@link GlAbstractVertexAttribute} */
public GlVertexAttributePreGL43()
{
super(); // also bind AbstractVertexAttribute
this.bindingPointsToIndexBuilder = new TreeMap<>();
@@ -79,7 +79,7 @@ public final class VertexAttributePreGL43 extends AbstractVertexAttribute
for (int i = 0; i < this.pointers.length; i++)
{
VertexPointer pointer = this.pointers[i];
GlVertexPointer pointer = this.pointers[i];
if (pointer == null)
{
continue;
@@ -111,7 +111,7 @@ public final class VertexAttributePreGL43 extends AbstractVertexAttribute
for (int bindingPointIndex : bindingPointIndexes)
{
VertexPointer pointer = this.pointers[bindingPointIndex];
GlVertexPointer pointer = this.pointers[bindingPointIndex];
if (pointer == null)
{
continue;
@@ -166,7 +166,7 @@ public final class VertexAttributePreGL43 extends AbstractVertexAttribute
/** Requires AbstractVertexAttribute to be bound */
@Override
public void setVertexAttribute(int bindingPoint, int attributeIndex, VertexPointer attribute)
public void setVertexAttribute(int bindingPoint, int attributeIndex, GlVertexPointer attribute)
{
TreeSet<Integer> intArray = this.bindingPointsToIndexBuilder.computeIfAbsent(bindingPoint, k -> new TreeSet<>());
intArray.add(attributeIndex);
@@ -203,7 +203,7 @@ public final class VertexAttributePreGL43 extends AbstractVertexAttribute
}
});
this.pointers = this.pointersBuilder.toArray(new VertexPointer[this.pointersBuilder.size()]);
this.pointers = this.pointersBuilder.toArray(new GlVertexPointer[this.pointersBuilder.size()]);
this.pointersOffset = new int[this.pointers.length];
this.pointersBuilder = null; // Release the builder
this.bindingPointsToIndexBuilder = null; // Release the builder
@@ -212,7 +212,7 @@ public final class VertexAttributePreGL43 extends AbstractVertexAttribute
int currentOffset = 0;
for (int i = 0; i < this.pointers.length; i++)
{
VertexPointer pointer = this.pointers[i];
GlVertexPointer pointer = this.pointers[i];
if (pointer == null)
{
LOGGER.warn("Vertex Attribute index " + i + " is not set! No index should be skipped normally!");
@@ -236,7 +236,7 @@ public final class VertexAttributePreGL43 extends AbstractVertexAttribute
for (int i = 0; i < this.pointers.length; i++)
{
VertexPointer pointer = this.pointers[i];
GlVertexPointer pointer = this.pointers[i];
if (pointer == null)
{
LOGGER.debug(i + ": Null!!!!");
@@ -0,0 +1,72 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute;
import com.seibel.distanthorizons.coreapi.util.MathUtil;
import org.lwjgl.opengl.GL32;
public final class GlVertexPointer
{
public final int elementCount;
public final int glType;
public final boolean normalized;
public final int byteSize;
public final boolean useInteger;
// basic constructors //
public GlVertexPointer(int elementCount, int glType, boolean normalized, int byteSize, boolean useInteger)
{
this.elementCount = elementCount;
this.glType = glType;
this.normalized = normalized;
this.byteSize = byteSize;
this.useInteger = useInteger;
}
public GlVertexPointer(int elementCount, int glType, boolean normalized, int byteSize)
{
this(elementCount, glType, normalized, byteSize, false);
}
private static int _align(int bytes) { return MathUtil.ceilDiv(bytes, 4) * 4; }
// named constructors //
public static GlVertexPointer addFloatPointer(boolean normalized) { return new GlVertexPointer(1, GL32.GL_FLOAT, normalized, Float.BYTES); }
public static GlVertexPointer addVec2Pointer(boolean normalized) { return new GlVertexPointer(2, GL32.GL_FLOAT, normalized, Float.BYTES * 2); }
public static GlVertexPointer addVec3Pointer(boolean normalized) { return new GlVertexPointer(3, GL32.GL_FLOAT, normalized, Float.BYTES * 3); }
public static GlVertexPointer addVec4Pointer(boolean normalized) { return new GlVertexPointer(4, GL32.GL_FLOAT, normalized, Float.BYTES * 4); }
/** Always aligned to 4 bytes */
public static GlVertexPointer addUnsignedBytePointer(boolean normalized, boolean useInteger) { return new GlVertexPointer(1, GL32.GL_UNSIGNED_BYTE, normalized, 4, useInteger); }
/** aligned to 4 bytes */
public static GlVertexPointer addUnsignedBytesPointer(int elementCount, boolean normalized, boolean useInteger)
{ return new GlVertexPointer(elementCount, GL32.GL_UNSIGNED_BYTE, normalized, _align(elementCount), useInteger); }
public static GlVertexPointer addUnsignedShortsPointer(int elementCount, boolean normalized, boolean useInteger)
{ return new GlVertexPointer(elementCount, GL32.GL_UNSIGNED_SHORT, normalized, _align(elementCount * 2), useInteger); }
public static GlVertexPointer addShortsPointer(int elementCount, boolean normalized, boolean useInteger) { return new GlVertexPointer(elementCount, GL32.GL_SHORT, normalized, _align(elementCount * 2), useInteger); }
public static GlVertexPointer addIntPointer(boolean normalized, boolean useInteger) { return new GlVertexPointer(1, GL32.GL_INT, normalized, 4, useInteger); }
public static GlVertexPointer addIVec2Pointer(boolean normalized, boolean useInteger) { return new GlVertexPointer(2, GL32.GL_INT, normalized, 8, useInteger); }
public static GlVertexPointer addIVec3Pointer(boolean normalized, boolean useInteger) { return new GlVertexPointer(3, GL32.GL_INT, normalized, 12, useInteger); }
public static GlVertexPointer addIVec4Pointer(boolean normalized, boolean useInteger) { return new GlVertexPointer(4, GL32.GL_INT, normalized, 16, useInteger); }
}
@@ -17,12 +17,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing;
package com.seibel.distanthorizons.common.render.openGl.postProcessing;
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.AbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.VertexPointer;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlAbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlVertexPointer;
import org.lwjgl.opengl.GL32;
import org.lwjgl.system.MemoryUtil;
@@ -32,9 +32,9 @@ import java.nio.ByteBuffer;
* Renders a full-screen textured quad to the screen.
* Used in composite / deferred rendering (IE fog).
*/
public class ScreenQuad
public class GlScreenQuad
{
public static ScreenQuad INSTANCE = new ScreenQuad();
public static GlScreenQuad INSTANCE = new GlScreenQuad();
private static final float[] BOX_VERTICES = {
-1, -1,
@@ -47,7 +47,7 @@ public class ScreenQuad
};
private GLVertexBuffer boxBuffer;
private AbstractVertexAttribute va;
private GlAbstractVertexAttribute va;
private boolean init = false;
@@ -57,18 +57,18 @@ public class ScreenQuad
//=============//
//region
private ScreenQuad() { }
private GlScreenQuad() { }
public void init()
{
if (this.init) return;
this.init = true;
this.va = AbstractVertexAttribute.create();
this.va = GlAbstractVertexAttribute.create();
this.va.bind();
// Pos
this.va.setVertexAttribute(0, 0, VertexPointer.addVec2Pointer(false));
this.va.setVertexAttribute(0, 0, GlVertexPointer.addVec2Pointer(false));
this.va.completeAndCheck(Float.BYTES * 2);
// Framebuffer
@@ -17,25 +17,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.apply;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.apply;
import com.seibel.distanthorizons.common.render.nativeGl.DhTerrainShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLState;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ScreenQuad;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.GlScreenQuad;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.common.render.nativeGl.util.AbstractShaderRenderer;
import com.seibel.distanthorizons.common.render.openGl.util.GlAbstractShaderRenderer;
import com.seibel.distanthorizons.core.logging.DhLogger;
import org.lwjgl.opengl.GL32;
/**
* Copies {@link com.seibel.distanthorizons.core.render.renderer.LodRenderer}'s currently active color and depth texture to Minecraft's framebuffer.
*/
public class DhApplyShader extends AbstractShaderRenderer
public class GlDhApplyShader extends GlAbstractShaderRenderer
{
public static DhApplyShader INSTANCE = new DhApplyShader();
public static GlDhApplyShader INSTANCE = new GlDhApplyShader();
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -52,12 +51,12 @@ public class DhApplyShader extends AbstractShaderRenderer
//=======//
//region
private DhApplyShader() { }
private GlDhApplyShader() { }
@Override
public void onInit()
{
this.shader = new ShaderProgram(
this.shader = new GlShaderProgram(
"shaders/quadApply.vert",
"shaders/apply.frag",
"vPosition"
@@ -115,17 +114,17 @@ public class DhApplyShader extends AbstractShaderRenderer
//GLMC.glBlendFunc(GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
GLMC.glBindTexture(OpenGlDhMetaRenderer.INSTANCE.getActiveColorTextureId());
GLMC.glBindTexture(GlDhMetaRenderer.INSTANCE.getActiveColorTextureId());
GL32.glUniform1i(this.gDhColorTextureUniform, 0);
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
GLMC.glBindTexture(OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GLMC.glBindTexture(GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GL32.glUniform1i(this.gDepthMapUniform, 1);
// Copy to MC's framebuffer
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, targetFrameBuffer);
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
}
// everything's been restored, except at this point the MC framebuffer should now be used instead
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, targetFrameBuffer);
@@ -139,7 +138,7 @@ public class DhApplyShader extends AbstractShaderRenderer
return;
}
int dhFrameBufferId = OpenGlDhMetaRenderer.INSTANCE.getActiveFramebufferId();
int dhFrameBufferId = GlDhMetaRenderer.INSTANCE.getActiveFramebufferId();
if (dhFrameBufferId == -1)
{
return;
@@ -163,11 +162,11 @@ public class DhApplyShader extends AbstractShaderRenderer
GLMC.disableBlend();
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
GLMC.glBindTexture(OpenGlDhMetaRenderer.INSTANCE.getActiveColorTextureId());
GLMC.glBindTexture(GlDhMetaRenderer.INSTANCE.getActiveColorTextureId());
GL32.glUniform1i(this.gDhColorTextureUniform, 0);
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
GLMC.glBindTexture(OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GLMC.glBindTexture(GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GL32.glUniform1i(this.gDepthMapUniform, 1);
@@ -177,7 +176,7 @@ public class DhApplyShader extends AbstractShaderRenderer
// Copy to MC's texture via MC's framebuffer
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, dhFrameBufferId);
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
}
// everything's been restored, except at this point the MC framebuffer should now be used instead
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, mcFrameBufferId);
@@ -17,12 +17,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fade;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fade;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ScreenQuad;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.GlScreenQuad;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.common.render.nativeGl.util.AbstractShaderRenderer;
import com.seibel.distanthorizons.common.render.openGl.util.GlAbstractShaderRenderer;
import com.seibel.distanthorizons.core.render.RenderParams;
import org.lwjgl.opengl.GL32;
@@ -30,12 +30,12 @@ import org.lwjgl.opengl.GL32;
* Draws the Fade texture onto Minecraft's FrameBuffer. <br><br>
*
* See Also: <br>
* {@link VanillaFadeRenderer} - Parent to this shader. <br>
* {@link VanillaFadeShader} - draws the Fade texture. <br>
* {@link GlVanillaFadeRenderer} - Parent to this shader. <br>
* {@link GlDhVanillaFadeShader} - draws the Fade texture. <br>
*/
public class DhFarFadeApplyShader extends AbstractShaderRenderer
public class GlDhFarFadeApplyShader extends GlAbstractShaderRenderer
{
public static DhFarFadeApplyShader INSTANCE = new DhFarFadeApplyShader();
public static GlDhFarFadeApplyShader INSTANCE = new GlDhFarFadeApplyShader();
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -58,7 +58,7 @@ public class DhFarFadeApplyShader extends AbstractShaderRenderer
@Override
public void onInit()
{
this.shader = new ShaderProgram(
this.shader = new GlShaderProgram(
"shaders/quadApply.vert",
"shaders/fade/apply.frag",
"vPosition"
@@ -105,7 +105,7 @@ public class DhFarFadeApplyShader extends AbstractShaderRenderer
GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, this.readFramebuffer);
GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, this.drawFramebuffer);
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
GLMC.enableDepthTest();
@@ -17,10 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fade;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fade;
import com.seibel.distanthorizons.common.render.nativeGl.DhTerrainShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
@@ -34,15 +33,15 @@ import org.lwjgl.opengl.GL43C;
import java.nio.ByteBuffer;
/**
* Handles fading MC and DH together via {@link DhFarFadeShader} and {@link DhFarFadeApplyShader}. <br><br>
* Handles fading MC and DH together via {@link GlDhFarFadeShader} and {@link GlDhFarFadeApplyShader}. <br><br>
*
* {@link DhFarFadeShader} - draws the Fade to a texture. <br>
* {@link DhFarFadeApplyShader} - draws the Fade texture to DH's framebuffer. <br>
* {@link GlDhFarFadeShader} - draws the Fade to a texture. <br>
* {@link GlDhFarFadeApplyShader} - draws the Fade texture to DH's framebuffer. <br>
*/
public class DhFarFadeRenderer implements IDhFarFadeRenderer
public class GlDhFarFadeRenderer implements IDhFarFadeRenderer
{
public static DhFarFadeRenderer INSTANCE = new DhFarFadeRenderer();
public static GlDhFarFadeRenderer INSTANCE = new GlDhFarFadeRenderer();
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
@@ -64,15 +63,15 @@ public class DhFarFadeRenderer implements IDhFarFadeRenderer
//=============//
//region
private DhFarFadeRenderer() { }
private GlDhFarFadeRenderer() { }
public void init()
{
if (this.init) return;
this.init = true;
DhFarFadeShader.INSTANCE.init();
DhFarFadeApplyShader.INSTANCE.init();
GlDhFarFadeShader.INSTANCE.init();
GlDhFarFadeApplyShader.INSTANCE.init();
}
private void createFramebuffer(int width, int height)
@@ -138,16 +137,16 @@ public class DhFarFadeRenderer implements IDhFarFadeRenderer
}
DhFarFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
DhFarFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
DhFarFadeShader.INSTANCE.render(renderParams);
GlDhFarFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
GlDhFarFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
GlDhFarFadeShader.INSTANCE.render(renderParams);
//profiler.popPush("Fade Apply");
DhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
DhFarFadeApplyShader.INSTANCE.readFramebuffer = DhFarFadeShader.INSTANCE.frameBuffer;
DhFarFadeApplyShader.INSTANCE.drawFramebuffer = OpenGlDhMetaRenderer.INSTANCE.getActiveFramebufferId();
DhFarFadeApplyShader.INSTANCE.render(renderParams);
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
GlDhFarFadeApplyShader.INSTANCE.readFramebuffer = GlDhFarFadeShader.INSTANCE.frameBuffer;
GlDhFarFadeApplyShader.INSTANCE.drawFramebuffer = GlDhMetaRenderer.INSTANCE.getActiveFramebufferId();
GlDhFarFadeApplyShader.INSTANCE.render(renderParams);
}
catch (Exception e)
{
@@ -17,25 +17,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fade;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fade;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.nativeGl.DhTerrainShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ScreenQuad;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.GlScreenQuad;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.common.render.nativeGl.util.AbstractShaderRenderer;
import com.seibel.distanthorizons.common.render.openGl.util.GlAbstractShaderRenderer;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.util.RenderUtil;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import org.lwjgl.opengl.GL32;
public class DhFarFadeShader extends AbstractShaderRenderer
public class GlDhFarFadeShader extends GlAbstractShaderRenderer
{
public static DhFarFadeShader INSTANCE = new DhFarFadeShader();
public static GlDhFarFadeShader INSTANCE = new GlDhFarFadeShader();
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -64,12 +63,12 @@ public class DhFarFadeShader extends AbstractShaderRenderer
// constructor //
//=============//
public DhFarFadeShader() { }
public GlDhFarFadeShader() { }
@Override
public void onInit()
{
this.shader = new ShaderProgram(
this.shader = new GlShaderProgram(
"shaders/quadApply.vert",
"shaders/fade/dhFade.frag",
"vPosition"
@@ -130,8 +129,8 @@ public class DhFarFadeShader extends AbstractShaderRenderer
@Override
protected void onRender()
{
int depthTextureId = OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId();
int colorTextureId = OpenGlDhMetaRenderer.INSTANCE.getActiveColorTextureId();
int depthTextureId = GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId();
int colorTextureId = GlDhMetaRenderer.INSTANCE.getActiveColorTextureId();
if (depthTextureId == -1
|| colorTextureId == -1)
@@ -162,7 +161,7 @@ public class DhFarFadeShader extends AbstractShaderRenderer
GL32.glUniform1i(this.uDhColorTexture, 2);
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
}
}
@@ -17,26 +17,25 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fade;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fade;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.nativeGl.DhTerrainShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ScreenQuad;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.GlScreenQuad;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.common.render.nativeGl.util.AbstractShaderRenderer;
import com.seibel.distanthorizons.common.render.openGl.util.GlAbstractShaderRenderer;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.util.RenderUtil;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import org.lwjgl.opengl.GL32;
public class VanillaFadeShader extends AbstractShaderRenderer
public class GlDhVanillaFadeShader extends GlAbstractShaderRenderer
{
public static VanillaFadeShader INSTANCE = new VanillaFadeShader();
public static GlDhVanillaFadeShader INSTANCE = new GlDhVanillaFadeShader();
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -72,12 +71,12 @@ public class VanillaFadeShader extends AbstractShaderRenderer
//=============//
//region
public VanillaFadeShader() { }
public GlDhVanillaFadeShader() { }
@Override
public void onInit()
{
this.shader = new ShaderProgram(
this.shader = new GlShaderProgram(
"shaders/quadApply.vert",
"shaders/fade/vanillaFade.frag",
"vPosition"
@@ -167,8 +166,8 @@ public class VanillaFadeShader extends AbstractShaderRenderer
@Override
protected void onRender()
{
int depthTextureId = OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId();
int colorTextureId = OpenGlDhMetaRenderer.INSTANCE.getActiveColorTextureId();
int depthTextureId = GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId();
int colorTextureId = GlDhMetaRenderer.INSTANCE.getActiveColorTextureId();
if (depthTextureId == -1
|| colorTextureId == -1)
@@ -202,7 +201,7 @@ public class VanillaFadeShader extends AbstractShaderRenderer
GL32.glUniform1i(this.uDhColorTexture, 3);
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
}
//endregion
@@ -17,10 +17,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fade;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fade;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLState;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -35,14 +35,14 @@ import org.lwjgl.opengl.GL32;
import java.nio.ByteBuffer;
/**
* Handles fading MC and DH together via {@link VanillaFadeShader} and {@link DhFarFadeApplyShader}. <br><br>
* Handles fading MC and DH together via {@link GlDhVanillaFadeShader} and {@link GlDhFarFadeApplyShader}. <br><br>
*
* {@link VanillaFadeShader} - draws the Fade to a texture. <br>
* {@link DhFarFadeApplyShader} - draws the Fade texture to MC's FrameBuffer. <br>
* {@link GlDhVanillaFadeShader} - draws the Fade to a texture. <br>
* {@link GlDhFarFadeApplyShader} - draws the Fade texture to MC's FrameBuffer. <br>
*/
public class VanillaFadeRenderer implements IDhVanillaFadeRenderer
public class GlVanillaFadeRenderer implements IDhVanillaFadeRenderer
{
public static VanillaFadeRenderer INSTANCE = new VanillaFadeRenderer();
public static GlVanillaFadeRenderer INSTANCE = new GlVanillaFadeRenderer();
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
@@ -66,15 +66,15 @@ public class VanillaFadeRenderer implements IDhVanillaFadeRenderer
//=============//
//region
private VanillaFadeRenderer() { }
private GlVanillaFadeRenderer() { }
public void init()
{
if (this.init) return;
this.init = true;
VanillaFadeShader.INSTANCE.init();
DhFarFadeApplyShader.INSTANCE.init();
GlDhVanillaFadeShader.INSTANCE.init();
GlDhFarFadeApplyShader.INSTANCE.init();
}
private void createFramebuffer(int width, int height)
@@ -124,7 +124,7 @@ public class VanillaFadeRenderer implements IDhVanillaFadeRenderer
@Override
public void render(RenderParams renderParams)
{
int depthTextureId = OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId();
int depthTextureId = GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId();
if (depthTextureId == -1)
{
// the renderer hasn't been set up yet
@@ -156,10 +156,10 @@ public class VanillaFadeRenderer implements IDhVanillaFadeRenderer
}
VanillaFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
VanillaFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
VanillaFadeShader.INSTANCE.setLevelMaxHeight(renderParams.clientLevelWrapper.getMaxHeight());
VanillaFadeShader.INSTANCE.render(renderParams);
GlDhVanillaFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
GlDhVanillaFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
GlDhVanillaFadeShader.INSTANCE.setLevelMaxHeight(renderParams.clientLevelWrapper.getMaxHeight());
GlDhVanillaFadeShader.INSTANCE.render(renderParams);
// Applying the fade texture is only needed if MC is drawing to their own frame buffer,
// otherwise we can directly render to their texture
@@ -167,10 +167,10 @@ public class VanillaFadeRenderer implements IDhVanillaFadeRenderer
{
profiler.popPush("Vanilla Fade Apply");
DhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
DhFarFadeApplyShader.INSTANCE.readFramebuffer = DhFarFadeShader.INSTANCE.frameBuffer;
DhFarFadeApplyShader.INSTANCE.drawFramebuffer = MC_RENDER.getTargetFramebuffer();
DhFarFadeApplyShader.INSTANCE.render(renderParams);
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
GlDhFarFadeApplyShader.INSTANCE.readFramebuffer = GlDhFarFadeShader.INSTANCE.frameBuffer;
GlDhFarFadeApplyShader.INSTANCE.drawFramebuffer = MC_RENDER.getTargetFramebuffer();
GlDhFarFadeApplyShader.INSTANCE.render(renderParams);
}
profiler.pop();
@@ -192,8 +192,8 @@ public class VanillaFadeRenderer implements IDhVanillaFadeRenderer
public void free()
{
VanillaFadeShader.INSTANCE.free();
DhFarFadeApplyShader.INSTANCE.free();
GlDhVanillaFadeShader.INSTANCE.free();
GlDhFarFadeApplyShader.INSTANCE.free();
}
//endregion
@@ -17,14 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fog;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
import com.seibel.distanthorizons.common.render.nativeGl.DhTerrainShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ScreenQuad;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.GlScreenQuad;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.common.render.nativeGl.util.AbstractShaderRenderer;
import com.seibel.distanthorizons.common.render.openGl.util.GlAbstractShaderRenderer;
import com.seibel.distanthorizons.core.render.RenderParams;
import org.lwjgl.opengl.GL32;
@@ -32,12 +31,12 @@ import org.lwjgl.opengl.GL32;
* Draws the Fog texture onto DH's FrameBuffer. <br><br>
*
* See Also: <br>
* {@link DhFogRenderer} - Parent to this shader. <br>
* {@link FogShader} - draws the Fog texture. <br>
* {@link GlDhFogRenderer} - Parent to this shader. <br>
* {@link GlDhFogShader} - draws the Fog texture. <br>
*/
public class FogApplyShader extends AbstractShaderRenderer
public class GlDhFogApplyShader extends GlAbstractShaderRenderer
{
public static FogApplyShader INSTANCE = new FogApplyShader();
public static GlDhFogApplyShader INSTANCE = new GlDhFogApplyShader();
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -57,7 +56,7 @@ public class FogApplyShader extends AbstractShaderRenderer
@Override
public void onInit()
{
this.shader = new ShaderProgram(
this.shader = new GlShaderProgram(
"shaders/quadApply.vert",
"shaders/fog/apply.frag",
"vPosition"
@@ -83,7 +82,7 @@ public class FogApplyShader extends AbstractShaderRenderer
GL32.glUniform1i(this.colorTextureUniform, 0);
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
GLMC.glBindTexture(OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GLMC.glBindTexture(GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GL32.glUniform1i(this.depthTextureUniform, 1);
}
@@ -108,10 +107,10 @@ public class FogApplyShader extends AbstractShaderRenderer
// apply the rendered Fog to DH's framebuffer
GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, FogShader.INSTANCE.frameBuffer);
GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, OpenGlDhMetaRenderer.INSTANCE.getActiveFramebufferId());
GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, GlDhFogShader.INSTANCE.frameBuffer);
GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, GlDhMetaRenderer.INSTANCE.getActiveFramebufferId());
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, 0);
}
@@ -17,10 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fog;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLState;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.render.RenderParams;
@@ -32,14 +31,14 @@ import org.lwjgl.opengl.GL43C;
import java.nio.ByteBuffer;
/**
* Handles adding SSAO via {@link FogShader} and {@link FogApplyShader}. <br><br>
* Handles adding SSAO via {@link GlDhFogShader} and {@link GlDhFogApplyShader}. <br><br>
*
* {@link FogShader} - draws the Fog to a texture. <br>
* {@link FogApplyShader} - draws the Fog texture to DH's FrameBuffer. <br>
* {@link GlDhFogShader} - draws the Fog to a texture. <br>
* {@link GlDhFogApplyShader} - draws the Fog texture to DH's FrameBuffer. <br>
*/
public class DhFogRenderer implements IDhFogRenderer
public class GlDhFogRenderer implements IDhFogRenderer
{
public static DhFogRenderer INSTANCE = new DhFogRenderer();
public static GlDhFogRenderer INSTANCE = new GlDhFogRenderer();
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -59,15 +58,15 @@ public class DhFogRenderer implements IDhFogRenderer
// constructor //
//=============//
private DhFogRenderer() { }
private GlDhFogRenderer() { }
public void init()
{
if (this.init) return;
this.init = true;
FogShader.INSTANCE.init();
FogApplyShader.INSTANCE.init();
GlDhFogShader.INSTANCE.init();
GlDhFogApplyShader.INSTANCE.init();
}
private void createFramebuffer(int width, int height)
@@ -126,12 +125,12 @@ public class DhFogRenderer implements IDhFogRenderer
this.createFramebuffer(width, height);
}
FogShader.INSTANCE.frameBuffer = this.fogFramebuffer;
FogShader.INSTANCE.setProjectionMatrix(renderParams.dhMvmProjMatrix);
FogShader.INSTANCE.render(renderParams);
GlDhFogShader.INSTANCE.frameBuffer = this.fogFramebuffer;
GlDhFogShader.INSTANCE.setProjectionMatrix(renderParams.dhMvmProjMatrix);
GlDhFogShader.INSTANCE.render(renderParams);
FogApplyShader.INSTANCE.fogTexture = this.fogTexture;
FogApplyShader.INSTANCE.render(renderParams);
GlDhFogApplyShader.INSTANCE.fogTexture = this.fogTexture;
GlDhFogApplyShader.INSTANCE.render(renderParams);
}
}
@@ -146,8 +145,8 @@ public class DhFogRenderer implements IDhFogRenderer
public void free()
{
FogShader.INSTANCE.free();
FogApplyShader.INSTANCE.free();
GlDhFogShader.INSTANCE.free();
GlDhFogApplyShader.INSTANCE.free();
}
//endregion
@@ -17,20 +17,19 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.fog;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.fog;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogColorMode;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogDirection;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiHeightFogMixMode;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.nativeGl.DhTerrainShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ScreenQuad;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.GlScreenQuad;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.common.render.nativeGl.util.AbstractShaderRenderer;
import com.seibel.distanthorizons.common.render.openGl.util.GlAbstractShaderRenderer;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.util.LodUtil;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
@@ -40,9 +39,9 @@ import org.lwjgl.opengl.GL32;
import java.awt.*;
public class FogShader extends AbstractShaderRenderer
public class GlDhFogShader extends GlAbstractShaderRenderer
{
public static final FogShader INSTANCE = new FogShader();
public static final GlDhFogShader INSTANCE = new GlDhFogShader();
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -104,12 +103,12 @@ public class FogShader extends AbstractShaderRenderer
//=============//
//region
public FogShader() { }
public GlDhFogShader() { }
@Override
public void onInit()
{
this.shader = new ShaderProgram(
this.shader = new GlShaderProgram(
"shaders/quadApply.vert",
"shaders/fog/fog.frag",
"vPosition"
@@ -277,7 +276,7 @@ public class FogShader extends AbstractShaderRenderer
GLMC.disableBlend();
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
GLMC.glBindTexture(OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GLMC.glBindTexture(GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GL32.glUniform1i(this.uDepthMap, 0);
// this is necessary for MC 1.16 (IE Legacy OpenGL)
@@ -293,7 +292,7 @@ public class FogShader extends AbstractShaderRenderer
}
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
}
//endregion
@@ -17,14 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ssao;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.ssao;
import com.seibel.distanthorizons.common.render.nativeGl.DhTerrainShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ScreenQuad;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.GlScreenQuad;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.common.render.nativeGl.util.AbstractShaderRenderer;
import com.seibel.distanthorizons.common.render.openGl.util.GlAbstractShaderRenderer;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.util.RenderUtil;
import org.lwjgl.opengl.GL32;
@@ -33,12 +32,12 @@ import org.lwjgl.opengl.GL32;
* Draws the SSAO texture onto DH's FrameBuffer. <br><br>
*
* See Also: <br>
* {@link DhSSAORenderer} - Parent to this shader. <br>
* {@link SSAOShader} - draws the SSAO texture. <br>
* {@link GlDhSSAORenderer} - Parent to this shader. <br>
* {@link GlDhSSAOShader} - draws the SSAO texture. <br>
*/
public class SSAOApplyShader extends AbstractShaderRenderer
public class GlDhSSAOApplyShader extends GlAbstractShaderRenderer
{
public static SSAOApplyShader INSTANCE = new SSAOApplyShader();
public static GlDhSSAOApplyShader INSTANCE = new GlDhSSAOApplyShader();
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -62,7 +61,7 @@ public class SSAOApplyShader extends AbstractShaderRenderer
@Override
public void onInit()
{
this.shader = new ShaderProgram(
this.shader = new GlShaderProgram(
"shaders/quadApply.vert",
"shaders/ssao/apply.frag",
"vPosition"
@@ -87,7 +86,7 @@ public class SSAOApplyShader extends AbstractShaderRenderer
protected void onApplyUniforms(RenderParams renderParams)
{
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
GLMC.glBindTexture(OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GLMC.glBindTexture(GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GL32.glUniform1i(this.gDepthMapUniform, 0);
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
@@ -135,11 +134,11 @@ public class SSAOApplyShader extends AbstractShaderRenderer
GLMC.disableDepthTest();
// apply the rendered SSAO to the LODs
GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, SSAOShader.INSTANCE.frameBuffer);
GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, OpenGlDhMetaRenderer.INSTANCE.getActiveFramebufferId());
GLMC.glBindFramebuffer(GL32.GL_READ_FRAMEBUFFER, GlDhSSAOShader.INSTANCE.frameBuffer);
GLMC.glBindFramebuffer(GL32.GL_DRAW_FRAMEBUFFER, GlDhMetaRenderer.INSTANCE.getActiveFramebufferId());
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
}
@@ -17,10 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ssao;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.ssao;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLState;
import com.seibel.distanthorizons.common.render.openGl.glObject.GLState;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.render.RenderParams;
@@ -32,14 +31,14 @@ import org.lwjgl.opengl.GL43C;
import java.nio.ByteBuffer;
/**
* Handles adding SSAO via {@link SSAOShader} and {@link SSAOApplyShader}. <br><br>
* Handles adding SSAO via {@link GlDhSSAOShader} and {@link GlDhSSAOApplyShader}. <br><br>
*
* {@link SSAOShader} - draws the SSAO to a texture. <br>
* {@link SSAOApplyShader} - draws the SSAO texture to DH's FrameBuffer. <br>
* {@link GlDhSSAOShader} - draws the SSAO to a texture. <br>
* {@link GlDhSSAOApplyShader} - draws the SSAO texture to DH's FrameBuffer. <br>
*/
public class DhSSAORenderer implements IDhSsaoRenderer
public class GlDhSSAORenderer implements IDhSsaoRenderer
{
public static DhSSAORenderer INSTANCE = new DhSSAORenderer();
public static GlDhSSAORenderer INSTANCE = new GlDhSSAORenderer();
private static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -59,15 +58,15 @@ public class DhSSAORenderer implements IDhSsaoRenderer
// constructor //
//=============//
private DhSSAORenderer() { }
private GlDhSSAORenderer() { }
public void init()
{
if (this.init) return;
this.init = true;
SSAOShader.INSTANCE.init();
SSAOApplyShader.INSTANCE.init();
GlDhSSAOShader.INSTANCE.init();
GlDhSSAOApplyShader.INSTANCE.init();
}
private void createFramebuffer(int width, int height)
@@ -126,12 +125,12 @@ public class DhSSAORenderer implements IDhSsaoRenderer
this.createFramebuffer(width, height);
}
SSAOShader.INSTANCE.frameBuffer = this.ssaoFramebuffer;
SSAOShader.INSTANCE.setProjectionMatrix(renderParams.dhProjectionMatrix);
SSAOShader.INSTANCE.render(renderParams);
GlDhSSAOShader.INSTANCE.frameBuffer = this.ssaoFramebuffer;
GlDhSSAOShader.INSTANCE.setProjectionMatrix(renderParams.dhProjectionMatrix);
GlDhSSAOShader.INSTANCE.render(renderParams);
SSAOApplyShader.INSTANCE.ssaoTexture = this.ssaoTexture;
SSAOApplyShader.INSTANCE.render(renderParams);
GlDhSSAOApplyShader.INSTANCE.ssaoTexture = this.ssaoTexture;
GlDhSSAOApplyShader.INSTANCE.render(renderParams);
}
}
@@ -146,8 +145,8 @@ public class DhSSAORenderer implements IDhSsaoRenderer
public void free()
{
SSAOShader.INSTANCE.free();
SSAOApplyShader.INSTANCE.free();
GlDhSSAOShader.INSTANCE.free();
GlDhSSAOApplyShader.INSTANCE.free();
}
//endregion
@@ -17,15 +17,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ssao;
package com.seibel.distanthorizons.common.render.openGl.postProcessing.ssao;
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
import com.seibel.distanthorizons.common.render.nativeGl.DhTerrainShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.ScreenQuad;
import com.seibel.distanthorizons.common.render.openGl.GlDhMetaRenderer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.GlScreenQuad;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.common.render.nativeGl.util.AbstractShaderRenderer;
import com.seibel.distanthorizons.common.render.openGl.util.GlAbstractShaderRenderer;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.util.math.Mat4f;
import org.lwjgl.opengl.GL32;
@@ -34,12 +33,12 @@ import org.lwjgl.opengl.GL32;
* Draws the SSAO to a texture. <br><br>
*
* See Also: <br>
* {@link DhSSAORenderer} - Parent to this shader. <br>
* {@link SSAOApplyShader} - draws the SSAO texture to DH's FrameBuffer. <br>
* {@link GlDhSSAORenderer} - Parent to this shader. <br>
* {@link GlDhSSAOApplyShader} - draws the SSAO texture to DH's FrameBuffer. <br>
*/
public class SSAOShader extends AbstractShaderRenderer
public class GlDhSSAOShader extends GlAbstractShaderRenderer
{
public static SSAOShader INSTANCE = new SSAOShader();
public static GlDhSSAOShader INSTANCE = new GlDhSSAOShader();
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
@@ -70,7 +69,7 @@ public class SSAOShader extends AbstractShaderRenderer
@Override
public void onInit()
{
this.shader = new ShaderProgram(
this.shader = new GlShaderProgram(
"shaders/quadApply.vert",
"shaders/ssao/ao.frag",
"vPosition"
@@ -135,9 +134,9 @@ public class SSAOShader extends AbstractShaderRenderer
GLMC.disableBlend();
GLMC.glActiveTexture(GL32.GL_TEXTURE0);
GLMC.glBindTexture(OpenGlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
GLMC.glBindTexture(GlDhMetaRenderer.INSTANCE.getActiveDepthTextureId());
ScreenQuad.INSTANCE.render();
GlScreenQuad.INSTANCE.render();
}
@@ -17,18 +17,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.test;
package com.seibel.distanthorizons.common.render.openGl.test;
import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod;
import com.seibel.distanthorizons.common.render.nativeGl.postProcessing.apply.DhApplyShader;
import com.seibel.distanthorizons.common.render.openGl.postProcessing.apply.GlDhApplyShader;
import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftGLWrapper;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.logging.DhLogger;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.AbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.vertexAttribute.VertexPointer;
import com.seibel.distanthorizons.common.render.openGl.glObject.buffer.GLVertexBuffer;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlAbstractVertexAttribute;
import com.seibel.distanthorizons.common.render.openGl.glObject.vertexAttribute.GlVertexPointer;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
@@ -63,9 +63,9 @@ public class GlTestTriangleRenderer implements IDhTestTriangleRenderer
ShaderProgram basicShader;
GlShaderProgram basicShader;
GLVertexBuffer vbo;
AbstractVertexAttribute va;
GlAbstractVertexAttribute va;
boolean init = false;
@@ -86,14 +86,14 @@ public class GlTestTriangleRenderer implements IDhTestTriangleRenderer
LOGGER.info("init");
this.init = true;
this.va = AbstractVertexAttribute.create();
this.va = GlAbstractVertexAttribute.create();
this.va.bind();
// Pos
this.va.setVertexAttribute(0, 0, VertexPointer.addVec2Pointer(false));
this.va.setVertexAttribute(0, 0, GlVertexPointer.addVec2Pointer(false));
// Color
this.va.setVertexAttribute(0, 1, VertexPointer.addVec4Pointer(false));
this.va.setVertexAttribute(0, 1, GlVertexPointer.addVec4Pointer(false));
this.va.completeAndCheck(Float.BYTES * 6);
this.basicShader = new ShaderProgram(
this.basicShader = new GlShaderProgram(
"shaders/test/vert.vert",
"shaders/test/frag.frag",
new String[]{"vPosition", "color"});
@@ -136,7 +136,7 @@ public class GlTestTriangleRenderer implements IDhTestTriangleRenderer
GL32.glDrawArrays(GL32.GL_TRIANGLES, 0, 3);
DhApplyShader.INSTANCE.render(renderParams);
GlDhApplyShader.INSTANCE.render(renderParams);
}
//endregion
@@ -17,20 +17,20 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.util;
package com.seibel.distanthorizons.common.render.openGl.util;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.shader.ShaderProgram;
import com.seibel.distanthorizons.common.render.openGl.glObject.shader.GlShaderProgram;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.render.RenderParams;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import org.lwjgl.opengl.GL32;
public abstract class AbstractShaderRenderer
public abstract class GlAbstractShaderRenderer
{
protected static final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
protected ShaderProgram shader;
protected GlShaderProgram shader;
protected boolean init = false;
@@ -39,7 +39,7 @@ public abstract class AbstractShaderRenderer
//=======//
//region
protected AbstractShaderRenderer() {}
protected GlAbstractShaderRenderer() {}
public void init()
{
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.util.vertexFormat;
package com.seibel.distanthorizons.common.render.openGl.util.vertexFormat;
import java.util.stream.Collectors;
@@ -37,22 +37,22 @@ import it.unimi.dsi.fastutil.ints.IntList;
* @author James Seibel
* @version 12-9-2021
*/
public class LodVertexFormat
public class GlLodVertexFormat
{
/** the format of data stored in the GPU buffers */
public static final LodVertexFormat DH_VERTEX_FORMAT = VertexFormats.POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT_MATERIAL_ID_NORMAL_INDEX;
public static final GlLodVertexFormat DH_VERTEX_FORMAT = GlVertexFormats.POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT_MATERIAL_ID_NORMAL_INDEX;
private final ImmutableList<LodVertexFormatElement> elements;
private final ImmutableList<GlLodVertexFormatElement> elements;
private final IntList offsets = new IntArrayList();
private final int byteSize;
public LodVertexFormat(ImmutableList<LodVertexFormatElement> elementList)
public GlLodVertexFormat(ImmutableList<GlLodVertexFormatElement> elementList)
{
this.elements = elementList;
int i = 0;
for (LodVertexFormatElement LodVertexFormatElement : elementList)
for (GlLodVertexFormatElement LodVertexFormatElement : elementList)
{
this.offsets.add(i);
i += LodVertexFormatElement.getByteSize();
@@ -66,7 +66,7 @@ public class LodVertexFormat
return this.byteSize;
}
public ImmutableList<LodVertexFormatElement> getElements()
public ImmutableList<GlLodVertexFormatElement> getElements()
{
return this.elements;
}
@@ -93,7 +93,7 @@ public class LodVertexFormat
}
else if (obj != null && this.getClass() == obj.getClass())
{
LodVertexFormat vertexFormat = (LodVertexFormat) obj;
GlLodVertexFormat vertexFormat = (GlLodVertexFormat) obj;
return this.byteSize == vertexFormat.byteSize && this.elements.equals(vertexFormat.elements);
}
else
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.util.vertexFormat;
package com.seibel.distanthorizons.common.render.openGl.util.vertexFormat;
import org.lwjgl.opengl.GL32;
@@ -32,16 +32,16 @@ import org.lwjgl.opengl.GL32;
* @author James Seibel
* @version 11-13-2021
*/
public class LodVertexFormatElement
public class GlLodVertexFormatElement
{
private final LodVertexFormatElement.DataType dataType;
private final GlLodVertexFormatElement.DataType dataType;
/** James isn't sure what index is for */
private final int index;
private final int count;
private final int byteSize;
private final boolean isPadding;
public LodVertexFormatElement(int newIndex, LodVertexFormatElement.DataType newType, int newCount, boolean isPadding)
public GlLodVertexFormatElement(int newIndex, GlLodVertexFormatElement.DataType newType, int newCount, boolean isPadding)
{
this.dataType = newType;
this.index = newIndex;
@@ -55,7 +55,7 @@ public class LodVertexFormatElement
return isPadding;
}
public final LodVertexFormatElement.DataType getType()
public final GlLodVertexFormatElement.DataType getType()
{
return this.dataType;
}
@@ -141,7 +141,7 @@ public class LodVertexFormatElement
}
else if (obj != null && this.getClass() == obj.getClass())
{
LodVertexFormatElement LodVertexFormatElement = (LodVertexFormatElement) obj;
GlLodVertexFormatElement LodVertexFormatElement = (GlLodVertexFormatElement) obj;
if (this.count != LodVertexFormatElement.count)
{
return false;
@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.common.render.nativeGl.util.vertexFormat;
package com.seibel.distanthorizons.common.render.openGl.util.vertexFormat;
import com.google.common.collect.ImmutableList;
@@ -25,18 +25,18 @@ import com.google.common.collect.ImmutableList;
* A (almost) exact copy of MC's
* DefaultVertexFormats class.
*/
public class VertexFormats
public class GlVertexFormats
{
public static final LodVertexFormatElement ELEMENT_POSITION = new LodVertexFormatElement(3, LodVertexFormatElement.DataType.USHORT, 3, false);
public static final LodVertexFormatElement ELEMENT_COLOR = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.UBYTE, 4, false);
public static final LodVertexFormatElement ELEMENT_BYTE_PADDING = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 1, true);
public static final GlLodVertexFormatElement ELEMENT_POSITION = new GlLodVertexFormatElement(3, GlLodVertexFormatElement.DataType.USHORT, 3, false);
public static final GlLodVertexFormatElement ELEMENT_COLOR = new GlLodVertexFormatElement(0, GlLodVertexFormatElement.DataType.UBYTE, 4, false);
public static final GlLodVertexFormatElement ELEMENT_BYTE_PADDING = new GlLodVertexFormatElement(0, GlLodVertexFormatElement.DataType.BYTE, 1, true);
public static final LodVertexFormatElement ELEMENT_LIGHT = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.UBYTE, 1, false);
public static final LodVertexFormatElement ELEMENT_IRIS_MATERIAL_INDEX = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 1, false);
public static final LodVertexFormatElement ELEMENT_IRIS_NORMAL_INDEX = new LodVertexFormatElement(0, LodVertexFormatElement.DataType.BYTE, 1, false);
public static final GlLodVertexFormatElement ELEMENT_LIGHT = new GlLodVertexFormatElement(0, GlLodVertexFormatElement.DataType.UBYTE, 1, false);
public static final GlLodVertexFormatElement ELEMENT_IRIS_MATERIAL_INDEX = new GlLodVertexFormatElement(0, GlLodVertexFormatElement.DataType.BYTE, 1, false);
public static final GlLodVertexFormatElement ELEMENT_IRIS_NORMAL_INDEX = new GlLodVertexFormatElement(0, GlLodVertexFormatElement.DataType.BYTE, 1, false);
public static final LodVertexFormat POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT_MATERIAL_ID_NORMAL_INDEX = new LodVertexFormat(ImmutableList.<LodVertexFormatElement>builder()
public static final GlLodVertexFormat POSITION_COLOR_BLOCK_LIGHT_SKY_LIGHT_MATERIAL_ID_NORMAL_INDEX = new GlLodVertexFormat(ImmutableList.<GlLodVertexFormatElement>builder()
.add(ELEMENT_POSITION)
.add(ELEMENT_BYTE_PADDING)
.add(ELEMENT_LIGHT)
@@ -22,7 +22,7 @@ package com.seibel.distanthorizons.common.wrappers;
import com.seibel.distanthorizons.api.enums.config.EDhApiRenderApi;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiCustomRenderObjectFactory;
import com.seibel.distanthorizons.common.render.blaze.BlazeDhRenderApiDefinition;
import com.seibel.distanthorizons.common.render.nativeGl.OpenGlDhRenderApiDefinition;
import com.seibel.distanthorizons.common.render.openGl.GlDhRenderApiDefinition;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.render.renderer.GenericRenderObjectFactory;
import com.seibel.distanthorizons.common.wrappers.gui.ClassicConfigGUI;
@@ -97,7 +97,7 @@ public class DependencySetup
AbstractDhRenderApiDefinition renderDefinition;
if (renderingApiEnum == EDhApiRenderApi.OPEN_GL)
{
renderDefinition = new OpenGlDhRenderApiDefinition();
renderDefinition = new GlDhRenderApiDefinition();
}
else if (renderingApiEnum == EDhApiRenderApi.BLAZE_3D)
{
@@ -24,7 +24,6 @@ import java.io.File;
import com.mojang.blaze3d.platform.Window;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
import com.seibel.distanthorizons.common.render.nativeGl.glObject.GLProxy;
import com.seibel.distanthorizons.core.render.RenderThreadTaskHandler;
import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper;
import com.seibel.distanthorizons.coreapi.ModInfo;