From 1ed044d6dbefb31acbc76ed14b1c8b701ce6f637 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 2 Nov 2025 02:01:52 -0500 Subject: [PATCH 1/9] mac 2.1 compat, part 1 --- .../compile/task/ChunkBuilderMeshingTask.java | 1 + .../gradle/build/conventions/LWJGLHelper.java | 1 + .../impl/gl/buffer/GlBufferTarget.java | 5 +- .../impl/gl/device/GLRenderDevice.java | 46 +++++++++- .../render/chunk/ShaderChunkRenderer.java | 31 ++++++- .../blocks/block_layer_opaque_legacy.fsh | 84 +++++++++++++++++++ .../blocks/block_layer_opaque_legacy.vsh | 71 ++++++++++++++++ .../assets/sodium/shaders/include/fog.glsl | 10 ++- .../assets/sodium/shaders/include/legacy.glsl | 3 + forge122/build.gradle.kts | 11 ++- 10 files changed, 251 insertions(+), 12 deletions(-) create mode 100644 common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque_legacy.fsh create mode 100644 common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque_legacy.vsh create mode 100644 common/src/main/resources/assets/sodium/shaders/include/legacy.glsl diff --git a/babric/src/main/java/org/taumc/celeritas/impl/render/terrain/compile/task/ChunkBuilderMeshingTask.java b/babric/src/main/java/org/taumc/celeritas/impl/render/terrain/compile/task/ChunkBuilderMeshingTask.java index 8a0a78010..d7b8be9bb 100644 --- a/babric/src/main/java/org/taumc/celeritas/impl/render/terrain/compile/task/ChunkBuilderMeshingTask.java +++ b/babric/src/main/java/org/taumc/celeritas/impl/render/terrain/compile/task/ChunkBuilderMeshingTask.java @@ -3,6 +3,7 @@ package org.taumc.celeritas.impl.render.terrain.compile.task; import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap; import net.minecraft.block.Block; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.Minecraft; import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; import net.minecraft.world.WorldRegion; import net.minecraft.world.chunk.WorldChunk; diff --git a/buildSrc/src/main/java/org/embeddedt/embeddium/gradle/build/conventions/LWJGLHelper.java b/buildSrc/src/main/java/org/embeddedt/embeddium/gradle/build/conventions/LWJGLHelper.java index b079e2cd9..d21b79348 100644 --- a/buildSrc/src/main/java/org/embeddedt/embeddium/gradle/build/conventions/LWJGLHelper.java +++ b/buildSrc/src/main/java/org/embeddedt/embeddium/gradle/build/conventions/LWJGLHelper.java @@ -31,6 +31,7 @@ public class LWJGLHelper { deps.add(configurationName, "org.lwjgl:" + component + ":" + LWJGL3_VERSION); deps.add(configurationName, "org.lwjgl:" + component + ":" + LWJGL3_VERSION + ":natives-" + "linux"); deps.add(configurationName, "org.lwjgl:" + component + ":" + LWJGL3_VERSION + ":natives-" + "windows"); + deps.add(configurationName, "org.lwjgl:" + component + ":" + LWJGL3_VERSION + ":natives-" + "macos-arm64"); } } } diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/buffer/GlBufferTarget.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/buffer/GlBufferTarget.java index 62735ca93..771487c2a 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/buffer/GlBufferTarget.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/buffer/GlBufferTarget.java @@ -1,6 +1,7 @@ package org.embeddedt.embeddium.impl.gl.buffer; import org.lwjgl.opengl.GL20C; +import org.lwjgl.opengl.GL21C; import org.lwjgl.opengl.GL31C; import org.lwjgl.opengl.GL43C; @@ -9,7 +10,9 @@ public enum GlBufferTarget { ELEMENT_BUFFER(GL20C.GL_ELEMENT_ARRAY_BUFFER, GL20C.GL_ELEMENT_ARRAY_BUFFER_BINDING), COPY_READ_BUFFER(GL31C.GL_COPY_READ_BUFFER, GL31C.GL_COPY_READ_BUFFER), COPY_WRITE_BUFFER(GL31C.GL_COPY_WRITE_BUFFER, GL31C.GL_COPY_WRITE_BUFFER), - DRAW_INDIRECT_BUFFER(GL43C.GL_DRAW_INDIRECT_BUFFER, GL43C.GL_DRAW_INDIRECT_BUFFER_BINDING); + DRAW_INDIRECT_BUFFER(GL43C.GL_DRAW_INDIRECT_BUFFER, GL43C.GL_DRAW_INDIRECT_BUFFER_BINDING), + PIXEL_PACK_BUFFER(GL21C.GL_PIXEL_PACK_BUFFER, GL21C.GL_PIXEL_PACK_BUFFER_BINDING), + PIXEL_UNPACK_BUFFER(GL21C.GL_PIXEL_UNPACK_BUFFER, GL21C.GL_PIXEL_UNPACK_BUFFER_BINDING); public static final GlBufferTarget[] VALUES = GlBufferTarget.values(); public static final int COUNT = VALUES.length; diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java index f08e5d5f7..364f953cb 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java @@ -108,10 +108,27 @@ public class GLRenderDevice implements RenderDevice { @Override public void copyBufferSubData(GlBuffer src, GlBuffer dst, long readOffset, long writeOffset, long bytes) { - this.bindBuffer(GlBufferTarget.COPY_READ_BUFFER, src); - this.bindBuffer(GlBufferTarget.COPY_WRITE_BUFFER, dst); + if (GL.getCapabilities().OpenGL31 || GL.getCapabilities().GL_ARB_copy_buffer) { + this.bindBuffer(GlBufferTarget.COPY_READ_BUFFER, src); + this.bindBuffer(GlBufferTarget.COPY_WRITE_BUFFER, dst); + GL31C.glCopyBufferSubData(GL31C.GL_COPY_READ_BUFFER, GL31C.GL_COPY_WRITE_BUFFER, readOffset, writeOffset, bytes); + return; + } - GL31C.glCopyBufferSubData(GL31C.GL_COPY_READ_BUFFER, GL31C.GL_COPY_WRITE_BUFFER, readOffset, writeOffset, bytes); + this.bindBuffer(GlBufferTarget.ARRAY_BUFFER, src); + ByteBuffer srcData = GL15C.glMapBuffer(GL15C.GL_ARRAY_BUFFER, GL15C.GL_READ_ONLY, bytes, null); + srcData.position((int) readOffset); + + GL15C.glUnmapBuffer(GL15C.GL_ARRAY_BUFFER); + + this.bindBuffer(GlBufferTarget.ARRAY_BUFFER, dst); + ByteBuffer dstData = GL15C.glMapBuffer(GL15C.GL_ARRAY_BUFFER, GL15C.GL_WRITE_ONLY, null); + dstData.position((int) writeOffset); + + ByteBuffer srcSlice = srcData.slice(0, (int) bytes); + dstData.put(srcSlice); + + GL15C.glUnmapBuffer(GL15C.GL_ARRAY_BUFFER); } @Override @@ -201,7 +218,28 @@ public class GLRenderDevice implements RenderDevice { this.bindBuffer(GlBufferTarget.ARRAY_BUFFER, buffer); - ByteBuffer buf = GL32C.glMapBufferRange(GlBufferTarget.ARRAY_BUFFER.getTargetParameter(), offset, length, flags.getBitField()); + ByteBuffer buf; + if (GL.getCapabilities().OpenGL30 || GL.getCapabilities().GL_ARB_map_buffer_range) { + buf = GL32C.glMapBufferRange( + GlBufferTarget.ARRAY_BUFFER.getTargetParameter(), + offset, length, flags.getBitField() + ); + } else { + int access; + if (flags.contains(GlBufferMapFlags.WRITE) && flags.contains(GlBufferMapFlags.READ)) { + access = GL15C.GL_READ_WRITE; + } else if (flags.contains(GlBufferMapFlags.WRITE)) { + access = GL15C.GL_WRITE_ONLY; + } else { + access = GL15C.GL_READ_ONLY; + } + + buf = GL15C.glMapBuffer(GlBufferTarget.ARRAY_BUFFER.getTargetParameter(), access, null); + + buf = buf.position(Math.toIntExact(offset)) + .limit(Math.toIntExact(offset) + Math.toIntExact(length)) + .slice(); + } if (buf == null) { throw new RuntimeException("Failed to map buffer"); diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/render/chunk/ShaderChunkRenderer.java b/common/src/main/java/org/embeddedt/embeddium/impl/render/chunk/ShaderChunkRenderer.java index c45836036..727734b3c 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/render/chunk/ShaderChunkRenderer.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/render/chunk/ShaderChunkRenderer.java @@ -12,6 +12,9 @@ import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass; import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexType; import org.embeddedt.embeddium.impl.render.shader.ShaderLoader; import org.jetbrains.annotations.Nullable; +import org.lwjgl.opengl.GL; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL20; import java.util.ArrayList; import java.util.List; @@ -21,6 +24,26 @@ import java.util.Objects; public abstract class ShaderChunkRenderer implements ChunkRenderer { private static final Logger LOGGER = LogManager.getLogger(ShaderChunkRenderer.class); + private static final boolean USE_LEGACY_SHADERS; + + static { + boolean useLegacyShaders; + String glslVersion = GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION); + try { + glslVersion = glslVersion.replace(".", ""); + int versionNumber = Integer.parseInt(glslVersion); + useLegacyShaders = versionNumber < 130; + if (useLegacyShaders && !GL.getCapabilities().GL_EXT_gpu_shader4) { + throw new IllegalStateException("GLSL version " + glslVersion + " is too old and EXT_gpu_shader4 is not supported"); + } + } catch (NumberFormatException e) { + LOGGER.error("Failed to parse GLSL version {}", glslVersion, e); + useLegacyShaders = false; + } + + USE_LEGACY_SHADERS = useLegacyShaders; + } + private final Map> programs = new Object2ObjectOpenHashMap<>(); protected final RenderPassConfiguration renderPassConfiguration; @@ -39,7 +62,9 @@ public abstract class ShaderChunkRenderer implements ChunkRenderer { if (program == null && !this.programs.containsKey(options)) { try { - program = this.createShader("blocks/block_layer_opaque", options); + String path = "blocks/block_layer_opaque"; + if (USE_LEGACY_SHADERS) path += "_legacy"; + program = this.createShader(path, options); } catch(Exception e) { LOGGER.error("There was an error creating a chunk program. Terrain will not render until this is fixed.", e); } @@ -67,7 +92,9 @@ public abstract class ShaderChunkRenderer implements ChunkRenderer { for (var attr : options.pass().vertexType().getVertexFormat().getAttributes()) { builder.bindAttribute(attr.getName(), i++); } - builder.bindFragmentData("fragColor", ChunkShaderBindingPoints.FRAG_COLOR); + if (!USE_LEGACY_SHADERS) { + builder.bindFragmentData("fragColor", ChunkShaderBindingPoints.FRAG_COLOR); + } return builder.link((shader) -> new DefaultChunkShaderInterface(shader, options)); } finally { loadedShaders.forEach(GlShader::delete); diff --git a/common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque_legacy.fsh b/common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque_legacy.fsh new file mode 100644 index 000000000..f23bb2907 --- /dev/null +++ b/common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque_legacy.fsh @@ -0,0 +1,84 @@ +#version 120 +#import + +#import + +varying vec4 v_Color; +varying vec2 v_TexCoord; + +varying float v_ChunkAgeMs; + +varying float v_MaterialMipBias; +#ifdef USE_FRAGMENT_DISCARD +varying float v_MaterialAlphaCutoff; +#endif + +#if defined(USE_FOG_POSTMODERN) +varying float v_SphericalFragDistance; +varying float v_CylindricalFragDistance; +#elif defined(USE_FOG) +varying float v_FragDistance; +#endif + +uniform sampler2D u_BlockTex; // The block texture + +uniform vec4 u_FogColor; // The color of the shader fog + +#ifdef USE_FOG_SMOOTH +uniform float u_FogStart; // The starting position of the shader fog +uniform float u_FogEnd; // The ending position of the shader fog +#endif + +#ifdef USE_FOG_POSTMODERN +uniform float u_RenderDistFogStart; +uniform float u_RenderDistFogEnd; +uniform float u_EnvFogStart; +uniform float u_EnvFogEnd; +#endif + +#ifdef USE_FOG_EXP2 +uniform float u_FogDensity; // The density of the shader fog +#endif + +void main() { + vec4 diffuseColor = texture2D(u_BlockTex, v_TexCoord, v_MaterialMipBias); + +#ifdef USE_FRAGMENT_DISCARD + if (diffuseColor.a < v_MaterialAlphaCutoff) { + discard; + } +#endif + + vec4 m_color = v_Color; + +#ifdef USE_VANILLA_COLOR_FORMAT + // Apply per-vertex color. AO shade is applied ahead of time on the CPU. + diffuseColor *= m_color; +#else + // Apply per-vertex color + diffuseColor.rgb *= m_color.rgb; + + // Apply ambient occlusion "shade" + diffuseColor.rgb *= m_color.a; +#endif + +#ifdef USE_FOG +#if defined(CHUNK_FADE_IN_DURATION_MS) && CHUNK_FADE_IN_DURATION_MS > 0 + // Make chunk fade in over a short duration + diffuseColor = vec4(mix(u_FogColor.rgb, diffuseColor.rgb, (clamp(v_ChunkAgeMs, 0, CHUNK_FADE_IN_DURATION_MS) / CHUNK_FADE_IN_DURATION_MS)), diffuseColor.a); +#endif + +#ifdef USE_FOG_POSTMODERN + float fogValue = max(_linearFogValue(v_CylindricalFragDistance, u_RenderDistFogStart, u_RenderDistFogEnd), + _linearFogValue(v_SphericalFragDistance, u_EnvFogStart, u_EnvFogEnd)); + + gl_FragColor = vec4(mix(diffuseColor.rgb, u_FogColor.rgb, fogValue * u_FogColor.a), diffuseColor.a); +#elif defined(USE_FOG_EXP2) + gl_FragColor = _exp2Fog(diffuseColor, v_FragDistance, u_FogColor, u_FogDensity); +#elif defined(USE_FOG_SMOOTH) + gl_FragColor = _linearFog(diffuseColor, v_FragDistance, u_FogColor, u_FogStart, u_FogEnd); +#endif +#else + gl_FragColor = diffuseColor; +#endif +} diff --git a/common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque_legacy.vsh b/common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque_legacy.vsh new file mode 100644 index 000000000..25468da5b --- /dev/null +++ b/common/src/main/resources/assets/sodium/shaders/blocks/block_layer_opaque_legacy.vsh @@ -0,0 +1,71 @@ +#version 120 +#import + +#define in attribute +#import +#import +#import +#import + +varying vec4 v_Color; +varying vec2 v_TexCoord; + +varying float v_ChunkAgeMs; + +varying float v_MaterialMipBias; +#ifdef USE_FRAGMENT_DISCARD +varying float v_MaterialAlphaCutoff; +#endif + +#if defined(USE_FOG_POSTMODERN) +varying float v_SphericalFragDistance; +varying float v_CylindricalFragDistance; +#elif defined(USE_FOG) +varying float v_FragDistance; +#endif + +uniform int u_FogShape; + +uniform vec3 u_RegionOffset; + +#ifndef CELERITAS_NO_LIGHTMAP +uniform sampler2D u_LightTex; // The light map texture sampler + +vec4 _sample_lightmap(sampler2D lightMap, ivec2 uv) { + return texture2D(lightMap, clamp(uv / 256.0, vec2(0.5 / 16.0), vec2(15.5 / 16.0))); +} +#endif + +uniform float celeritas_ChunkAges[REGION_SIZE]; + +void main() { + _vert_init(); + + // Transform the chunk-local vertex position into world model space + vec3 translation = u_RegionOffset + _get_draw_translation(_draw_id); + vec3 position = _vert_position + translation; + +#if defined(USE_FOG_POSTMODERN) + v_SphericalFragDistance = getFragDistance(FOG_SHAPE_SPHERICAL, position); + v_CylindricalFragDistance = getFragDistance(FOG_SHAPE_CYLINDRICAL, position); +#elif defined(USE_FOG) + v_FragDistance = getFragDistance(u_FogShape, position); +#endif + + // Transform the vertex position into model-view-projection space + gl_Position = u_ProjectionMatrix * u_ModelViewMatrix * vec4(position, 1.0); + + // Add the light color to the vertex color, and pass the texture coordinates to the fragment shader +#ifdef CELERITAS_NO_LIGHTMAP + v_Color = _vert_color; +#else + v_Color = _vert_color * _sample_lightmap(u_LightTex, _vert_tex_light_coord); +#endif + v_TexCoord = _vert_tex_diffuse_coord; + + v_MaterialMipBias = _material_mip_bias(_material_params); +#ifdef USE_FRAGMENT_DISCARD + v_MaterialAlphaCutoff = _material_alpha_cutoff(_material_params); +#endif + v_ChunkAgeMs = celeritas_ChunkAges[_draw_id]; +} diff --git a/common/src/main/resources/assets/sodium/shaders/include/fog.glsl b/common/src/main/resources/assets/sodium/shaders/include/fog.glsl index 550746b5c..9bcddeca2 100644 --- a/common/src/main/resources/assets/sodium/shaders/include/fog.glsl +++ b/common/src/main/resources/assets/sodium/shaders/include/fog.glsl @@ -43,9 +43,11 @@ vec4 _exp2Fog(vec4 fragColor, float fragDistance, vec4 fogColor, float fogDensit float getFragDistance(int fogShape, vec3 position) { // Use the maximum of the horizontal and vertical distance to get cylindrical fog if fog shape is cylindrical - switch (fogShape) { - case FOG_SHAPE_SPHERICAL: return length(position); - case FOG_SHAPE_CYLINDRICAL: return max(length(position.xz), abs(position.y)); - default: return length(position); // This shouldn't be possible to get, but return a sane value just in case + if (fogShape == FOG_SHAPE_SPHERICAL) { + return length(position); + } else if (fogShape == FOG_SHAPE_CYLINDRICAL) { + return max(length(position.xz), abs(position.y)); + } else { + return length(position); // This shouldn't be possible to get, but return a sane value just in case } } \ No newline at end of file diff --git a/common/src/main/resources/assets/sodium/shaders/include/legacy.glsl b/common/src/main/resources/assets/sodium/shaders/include/legacy.glsl new file mode 100644 index 000000000..f8eb37c26 --- /dev/null +++ b/common/src/main/resources/assets/sodium/shaders/include/legacy.glsl @@ -0,0 +1,3 @@ +#extension GL_EXT_gpu_shader4 : require +#define LEGACY +#define uint unsigned int diff --git a/forge122/build.gradle.kts b/forge122/build.gradle.kts index b6e8786b6..4051c0865 100644 --- a/forge122/build.gradle.kts +++ b/forge122/build.gradle.kts @@ -79,10 +79,11 @@ repositories { includeGroup("com.gtnewhorizons") } } + maven("https://maven.gtceu.com") mavenLocal() } -val lwjgl3ifyVersion = "1.0.1-38-g6410323" +val lwjgl3ifyVersion = "1.0.1" val forgePatchDeps by configurations.creating { isCanBeResolved = true @@ -130,6 +131,14 @@ tasks.named("reobfJar").configure { enabled = false } +configurations.all { + resolutionStrategy.eachDependency { + if (requested.group == "net.java.dev.jna" && requested.name == "jna") { + useVersion("5.15.0") + } + } +} + tasks.register("celeritasRemapJar") { tsrgMappings = mcpTasks.srgFile("mcp-srg.srg") deobfMinecraftJar = mcpTasks.taskPackagePatchedMc.flatMap { it.archiveFile } -- 2.54.1 From d70456f1729187b1f3d8a5bf8fa36ea7ed9a3553 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 2 Nov 2025 11:40:22 -0500 Subject: [PATCH 2/9] VAO support via APPLE_vertex_array_object --- .../impl/gl/array/GlVertexArray.java | 6 +- .../impl/gl/device/GLRenderDevice.java | 5 +- .../impl/gl/util/APPLEVertexArrayObject.java | 69 +++++++++++ .../embeddium/impl/gl/util/VAOUtil.java | 115 ++++++++++++++++++ 4 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java create mode 100644 common/src/main/java/org/embeddedt/embeddium/impl/gl/util/VAOUtil.java diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/array/GlVertexArray.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/array/GlVertexArray.java index 0cc98fcbd..4dd5128b6 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/array/GlVertexArray.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/array/GlVertexArray.java @@ -1,7 +1,7 @@ package org.embeddedt.embeddium.impl.gl.array; import org.embeddedt.embeddium.impl.gl.GlObject; -import org.lwjgl.opengl.GL30C; +import org.embeddedt.embeddium.impl.gl.util.VAOUtil; /** * Provides Vertex Array functionality on supported platforms. @@ -10,11 +10,11 @@ public class GlVertexArray extends GlObject { public static final int NULL_ARRAY_ID = 0; public GlVertexArray() { - this.setHandle(GL30C.glGenVertexArrays()); + this.setHandle(VAOUtil.glGenVertexArrays()); } @Override protected void destroyInternal() { - GL30C.glDeleteVertexArrays(this.handle()); + VAOUtil.glDeleteVertexArrays(this.handle()); } } diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java index 364f953cb..f1f571832 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java @@ -7,6 +7,7 @@ import org.embeddedt.embeddium.impl.gl.state.GlStateTracker; import org.embeddedt.embeddium.impl.gl.sync.GlFence; import org.embeddedt.embeddium.impl.gl.tessellation.*; import org.embeddedt.embeddium.impl.gl.util.EnumBitField; +import org.embeddedt.embeddium.impl.gl.util.VAOUtil; import org.jetbrains.annotations.Nullable; import org.lwjgl.opengl.*; import java.nio.ByteBuffer; @@ -86,7 +87,7 @@ public class GLRenderDevice implements RenderDevice { @Override public void bindVertexArray(GlVertexArray array) { if (this.stateTracker.makeVertexArrayActive(array)) { - GL30C.glBindVertexArray(array.handle()); + VAOUtil.glBindVertexArray(array.handle()); } } @@ -141,7 +142,7 @@ public class GLRenderDevice implements RenderDevice { @Override public void unbindVertexArray() { if (this.stateTracker.makeVertexArrayActive(null)) { - GL30C.glBindVertexArray(GlVertexArray.NULL_ARRAY_ID); + VAOUtil.glBindVertexArray(GlVertexArray.NULL_ARRAY_ID); } } diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java new file mode 100644 index 000000000..8171591ce --- /dev/null +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java @@ -0,0 +1,69 @@ +package org.embeddedt.embeddium.impl.gl.util; + +import org.lwjgl.opengl.GL; +import org.lwjgl.system.JNI; +import org.lwjgl.system.MemoryStack; +import org.lwjgl.system.NativeType; + +import java.nio.IntBuffer; + +import static org.lwjgl.system.MemoryStack.stackGet; +import static org.lwjgl.system.MemoryUtil.memAddress; + +/** + * Native bindings to the APPLE_vertex_array_object extension. + */ +public class APPLEVertexArrayObject { + private static final long bindVertexArray = GL.getFunctionProvider().getFunctionAddress("glBindVertexArrayAPPLE"); + private static final long deleteVertexArrays = GL.getFunctionProvider().getFunctionAddress("glDeleteVertexArrays"); + private static final long genVertexArrays = GL.getFunctionProvider().getFunctionAddress("glGenVertexArraysAPPLE"); + private static final long isVertexArray = GL.getFunctionProvider().getFunctionAddress("glIsVertexArrayAPPLE"); + + public static final boolean supported = bindVertexArray != 0; + + public static void glBindVertexArray(@NativeType("GLuint") int array) { + JNI.callV(array, bindVertexArray); + } + + public static void nglDeleteVertexArrays(int n, long arrays) { + JNI.callPV(n, arrays, deleteVertexArrays); + } + + public static void glDeleteVertexArrays(@NativeType("GLuint const *") IntBuffer arrays) { + nglDeleteVertexArrays(arrays.remaining(), memAddress(arrays)); + } + + public static void glDeleteVertexArrays(@NativeType("GLuint const *") int array) { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer arrays = stack.callocInt(1); + arrays.put(0, array); + nglDeleteVertexArrays(1, memAddress(arrays)); + } finally { + stack.setPointer(stackPointer); + } + } + + public static void nglGenVertexArrays(int n, long arrays) { + JNI.callPV(n, arrays, genVertexArrays); + } + + public static void glGenVertexArrays(@NativeType("GLuint *") IntBuffer arrays) { + nglGenVertexArrays(arrays.remaining(), memAddress(arrays)); + } + + public static int glGenVertexArrays() { + MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); + try { + IntBuffer arrays = stack.callocInt(1); + nglGenVertexArrays(1, memAddress(arrays)); + return arrays.get(0); + } finally { + stack.setPointer(stackPointer); + } + } + + public static boolean glIsVertexArrayAPPLE(@NativeType("GLuint") int array) { + return JNI.callZ(array, isVertexArray); + } +} diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/VAOUtil.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/VAOUtil.java new file mode 100644 index 000000000..dc5591daa --- /dev/null +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/VAOUtil.java @@ -0,0 +1,115 @@ +package org.embeddedt.embeddium.impl.gl.util; + +import org.lwjgl.opengl.ARBVertexArrayObject; +import org.lwjgl.opengl.GL; +import org.lwjgl.opengl.GL30C; +import org.lwjgl.system.NativeType; + +import java.nio.IntBuffer; + +/** + * Provides an abstraction over various VAO implementations. + */ +public class VAOUtil { + public static final boolean coreSupported = GL.getCapabilities().OpenGL32; + public static final boolean arbSupported = GL.getCapabilities().GL_ARB_vertex_array_object; + public static final boolean appleSupported = APPLEVertexArrayObject.supported; + + public static final boolean supported = coreSupported || arbSupported || appleSupported; + + public static void glBindVertexArray(@NativeType("GLuint") int array) { + if (coreSupported) { + GL30C.glBindVertexArray(array); + } else if (arbSupported) { + ARBVertexArrayObject.glBindVertexArray(array); + } else if (appleSupported) { + APPLEVertexArrayObject.glBindVertexArray(array); + } else { + throw new UnsupportedOperationException("VAO not supported"); + } + } + + public static void nglDeleteVertexArrays(int n, long arrays) { + if (coreSupported) { + GL30C.nglDeleteVertexArrays(n, arrays); + } else if (arbSupported) { + ARBVertexArrayObject.nglDeleteVertexArrays(n, arrays); + } else if (appleSupported) { + APPLEVertexArrayObject.nglDeleteVertexArrays(n, arrays); + } else { + throw new UnsupportedOperationException("VAO not supported"); + } + } + + public static void glDeleteVertexArrays(@NativeType("GLuint const *") IntBuffer arrays) { + if (coreSupported) { + GL30C.glDeleteVertexArrays(arrays); + } else if (arbSupported) { + ARBVertexArrayObject.glDeleteVertexArrays(arrays); + } else if (appleSupported) { + APPLEVertexArrayObject.glDeleteVertexArrays(arrays); + } else { + throw new UnsupportedOperationException("VAO not supported"); + } + } + + public static void glDeleteVertexArrays(@NativeType("GLuint const *") int array) { + if (coreSupported) { + GL30C.glDeleteVertexArrays(array); + } else if (arbSupported) { + ARBVertexArrayObject.glDeleteVertexArrays(array); + } else if (appleSupported) { + APPLEVertexArrayObject.glDeleteVertexArrays(array); + } else { + throw new UnsupportedOperationException("VAO not supported"); + } + } + + public static void nglGenVertexArrays(int n, long arrays) { + if (coreSupported) { + GL30C.nglGenVertexArrays(n, arrays); + } else if (arbSupported) { + ARBVertexArrayObject.nglGenVertexArrays(n, arrays); + } else if (appleSupported) { + APPLEVertexArrayObject.nglGenVertexArrays(n, arrays); + } else { + throw new UnsupportedOperationException("VAO not supported"); + } + } + + public static void glGenVertexArrays(@NativeType("GLuint *") IntBuffer arrays) { + if (coreSupported) { + GL30C.glGenVertexArrays(arrays); + } else if (arbSupported) { + ARBVertexArrayObject.glGenVertexArrays(arrays); + } else if (appleSupported) { + APPLEVertexArrayObject.glGenVertexArrays(arrays); + } else { + throw new UnsupportedOperationException("VAO not supported"); + } + } + + public static int glGenVertexArrays() { + if (coreSupported) { + return GL30C.glGenVertexArrays(); + } else if (arbSupported) { + return ARBVertexArrayObject.glGenVertexArrays(); + } else if (appleSupported) { + return APPLEVertexArrayObject.glGenVertexArrays(); + } else { + throw new UnsupportedOperationException("VAO not supported"); + } + } + + public static boolean glIsVertexArray(@NativeType("GLuint") int array) { + if (coreSupported) { + return GL30C.glIsVertexArray(array); + } else if (arbSupported) { + return ARBVertexArrayObject.glIsVertexArray(array); + } else if (appleSupported) { + return APPLEVertexArrayObject.glIsVertexArrayAPPLE(array); + } else { + throw new UnsupportedOperationException("VAO not supported"); + } + } +} -- 2.54.1 From a6719412d479d9a6a858780e104ab443e8e2af17 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 2 Nov 2025 11:50:20 -0500 Subject: [PATCH 3/9] the world renders??? --- .../tessellation/GlAbstractTessellation.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/tessellation/GlAbstractTessellation.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/tessellation/GlAbstractTessellation.java index 7d467f0f8..242681bca 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/tessellation/GlAbstractTessellation.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/tessellation/GlAbstractTessellation.java @@ -2,8 +2,11 @@ package org.embeddedt.embeddium.impl.gl.tessellation; import org.embeddedt.embeddium.impl.gl.attribute.GlVertexAttributeBinding; import org.embeddedt.embeddium.impl.gl.device.CommandList; +import org.lwjgl.opengl.EXTGPUShader4; +import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL20C; import org.lwjgl.opengl.GL30C; +import org.lwjgl.opengl.GLCapabilities; public abstract class GlAbstractTessellation implements GlTessellation { protected final TessellationBinding[] bindings; @@ -17,14 +20,26 @@ public abstract class GlAbstractTessellation implements GlTessellation { commandList.bindBuffer(binding.target(), binding.buffer()); for (GlVertexAttributeBinding attrib : binding.attributeBindings()) { + int index = attrib.getIndex(); + int size = attrib.getCount(); + int type = attrib.getFormat().typeId(); + int stride = attrib.getStride(); + long pointer = attrib.getPointer(); + if (attrib.isIntType()) { - GL30C.glVertexAttribIPointer(attrib.getIndex(), attrib.getCount(), attrib.getFormat().typeId(), - attrib.getStride(), attrib.getPointer()); + GLCapabilities caps = GL.getCapabilities(); + + if (caps.OpenGL30) { + GL30C.glVertexAttribIPointer(index, size, type, stride, pointer); + } else if (caps.GL_EXT_gpu_shader4) { + EXTGPUShader4.glVertexAttribIPointerEXT(index, size, type, stride, pointer); + } else { + GL20C.glVertexAttribPointer(index, size, type, false, stride, pointer); + } } else { - GL20C.glVertexAttribPointer(attrib.getIndex(), attrib.getCount(), attrib.getFormat().typeId(), attrib.isNormalized(), - attrib.getStride(), attrib.getPointer()); + GL20C.glVertexAttribPointer(index, size, type, attrib.isNormalized(), stride, pointer); } - GL20C.glEnableVertexAttribArray(attrib.getIndex()); + GL20C.glEnableVertexAttribArray(index); } } } -- 2.54.1 From cd8d8ea5a568f3d6c78276451f1e55152abfcf53 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 2 Nov 2025 14:31:27 -0500 Subject: [PATCH 4/9] i think this is more correct... need somebody to check my work lol --- .../impl/gl/device/GLRenderDevice.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java index f1f571832..37328f544 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java @@ -10,6 +10,8 @@ import org.embeddedt.embeddium.impl.gl.util.EnumBitField; import org.embeddedt.embeddium.impl.gl.util.VAOUtil; import org.jetbrains.annotations.Nullable; import org.lwjgl.opengl.*; +import org.lwjgl.system.libc.LibCString; + import java.nio.ByteBuffer; public class GLRenderDevice implements RenderDevice { @@ -109,27 +111,26 @@ public class GLRenderDevice implements RenderDevice { @Override public void copyBufferSubData(GlBuffer src, GlBuffer dst, long readOffset, long writeOffset, long bytes) { - if (GL.getCapabilities().OpenGL31 || GL.getCapabilities().GL_ARB_copy_buffer) { + if(GL.getCapabilities().OpenGL31 || GL.getCapabilities().GL_ARB_copy_buffer) { this.bindBuffer(GlBufferTarget.COPY_READ_BUFFER, src); this.bindBuffer(GlBufferTarget.COPY_WRITE_BUFFER, dst); GL31C.glCopyBufferSubData(GL31C.GL_COPY_READ_BUFFER, GL31C.GL_COPY_WRITE_BUFFER, readOffset, writeOffset, bytes); return; } - this.bindBuffer(GlBufferTarget.ARRAY_BUFFER, src); - ByteBuffer srcData = GL15C.glMapBuffer(GL15C.GL_ARRAY_BUFFER, GL15C.GL_READ_ONLY, bytes, null); - srcData.position((int) readOffset); + this.bindBuffer(GlBufferTarget.PIXEL_PACK_BUFFER, src); + this.bindBuffer(GlBufferTarget.PIXEL_UNPACK_BUFFER, dst); - GL15C.glUnmapBuffer(GL15C.GL_ARRAY_BUFFER); + ByteBuffer a = GL15.glMapBuffer(GlBufferTarget.PIXEL_PACK_BUFFER.getTargetParameter(), GL15.GL_READ_ONLY); + ByteBuffer b = GL15.glMapBuffer(GlBufferTarget.PIXEL_UNPACK_BUFFER.getTargetParameter(), GL15.GL_WRITE_ONLY); - this.bindBuffer(GlBufferTarget.ARRAY_BUFFER, dst); - ByteBuffer dstData = GL15C.glMapBuffer(GL15C.GL_ARRAY_BUFFER, GL15C.GL_WRITE_ONLY, null); - dstData.position((int) writeOffset); + LibCString.memcpy( + b.position(Math.toIntExact(writeOffset)).limit(Math.toIntExact(writeOffset + bytes)), + a.position(Math.toIntExact(readOffset)).limit(Math.toIntExact(readOffset + bytes)) + ); - ByteBuffer srcSlice = srcData.slice(0, (int) bytes); - dstData.put(srcSlice); - - GL15C.glUnmapBuffer(GL15C.GL_ARRAY_BUFFER); + GL15.glUnmapBuffer(GlBufferTarget.PIXEL_PACK_BUFFER.getTargetParameter()); + GL15.glUnmapBuffer(GlBufferTarget.PIXEL_UNPACK_BUFFER.getTargetParameter()); } @Override -- 2.54.1 From 1f2a5584be3f4fd99f6c5918a11677f59bf78052 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 2 Nov 2025 14:43:55 -0500 Subject: [PATCH 5/9] undo forge 1.12 buildscript changes --- forge122/build.gradle.kts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/forge122/build.gradle.kts b/forge122/build.gradle.kts index 4051c0865..b6e8786b6 100644 --- a/forge122/build.gradle.kts +++ b/forge122/build.gradle.kts @@ -79,11 +79,10 @@ repositories { includeGroup("com.gtnewhorizons") } } - maven("https://maven.gtceu.com") mavenLocal() } -val lwjgl3ifyVersion = "1.0.1" +val lwjgl3ifyVersion = "1.0.1-38-g6410323" val forgePatchDeps by configurations.creating { isCanBeResolved = true @@ -131,14 +130,6 @@ tasks.named("reobfJar").configure { enabled = false } -configurations.all { - resolutionStrategy.eachDependency { - if (requested.group == "net.java.dev.jna" && requested.name == "jna") { - useVersion("5.15.0") - } - } -} - tasks.register("celeritasRemapJar") { tsrgMappings = mcpTasks.srgFile("mcp-srg.srg") deobfMinecraftJar = mcpTasks.taskPackagePatchedMc.flatMap { it.archiveFile } -- 2.54.1 From f2cc85236d763ba813f73a23aac0779efd673ee0 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 3 Nov 2025 13:26:42 -0500 Subject: [PATCH 6/9] fix APPLEVertexArrayObject --- .../impl/gl/util/APPLEVertexArrayObject.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java index 8171591ce..3850c6496 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java @@ -12,10 +12,23 @@ import static org.lwjgl.system.MemoryUtil.memAddress; /** * Native bindings to the APPLE_vertex_array_object extension. + *

This extension introduces named vertex array objects which encapsulate vertex array state on the client side. + * The main purpose of these objects is to keep pointers to static vertex data and provide a name for different sets of static vertex data.

+ * + *

By extending vertex array range functionality this extension allows multiple vertex array ranges to exist at one time, + * including their complete sets of state, in manner analogous to texture objects.

+ * + *

GenVertexArraysAPPLE creates a list of n number of vertex array object names. After creating a name, + * BindVertexArrayAPPLE associates the name with a vertex array object and selects this vertex array and its associated state as current. + * To get back to the default vertex array and its associated state the client should bind to vertex array named 0.

+ * + *

Once a client is done using a vertex array object it can be deleted with DeleteVertexArraysAPPLE. + * The client is responsible for allocating and deallocating the memory used by the vertex array data, + * while the DeleteVertexArraysAPPLE command deletes vertex array object names and associated state only.

*/ public class APPLEVertexArrayObject { private static final long bindVertexArray = GL.getFunctionProvider().getFunctionAddress("glBindVertexArrayAPPLE"); - private static final long deleteVertexArrays = GL.getFunctionProvider().getFunctionAddress("glDeleteVertexArrays"); + private static final long deleteVertexArrays = GL.getFunctionProvider().getFunctionAddress("glDeleteVertexArraysAPPLE"); private static final long genVertexArrays = GL.getFunctionProvider().getFunctionAddress("glGenVertexArraysAPPLE"); private static final long isVertexArray = GL.getFunctionProvider().getFunctionAddress("glIsVertexArrayAPPLE"); -- 2.54.1 From 06ca56d8e4236bedc1d0a37618388f1402e7c5e1 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:27:27 -0500 Subject: [PATCH 7/9] fix that one crash lol --- .../render/terrain/occlusion/ChunkOcclusionDataBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babric/src/main/java/org/taumc/celeritas/impl/render/terrain/occlusion/ChunkOcclusionDataBuilder.java b/babric/src/main/java/org/taumc/celeritas/impl/render/terrain/occlusion/ChunkOcclusionDataBuilder.java index c307ed00d..e1ecf77a9 100644 --- a/babric/src/main/java/org/taumc/celeritas/impl/render/terrain/occlusion/ChunkOcclusionDataBuilder.java +++ b/babric/src/main/java/org/taumc/celeritas/impl/render/terrain/occlusion/ChunkOcclusionDataBuilder.java @@ -44,7 +44,7 @@ public class ChunkOcclusionDataBuilder { } public void markClosed(int x, int y, int z) { - this.closed.set(pack(x, y, z), true); + this.closed.set(pack(x & 15, y & 15, z & 15), true); --this.openCount; } -- 2.54.1 From f096f73f3563013d41a3176441f95fe13864294c Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:13:24 -0500 Subject: [PATCH 8/9] unbind the buffers after using them --- .../org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java index 37328f544..f0970a029 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/device/GLRenderDevice.java @@ -131,6 +131,9 @@ public class GLRenderDevice implements RenderDevice { GL15.glUnmapBuffer(GlBufferTarget.PIXEL_PACK_BUFFER.getTargetParameter()); GL15.glUnmapBuffer(GlBufferTarget.PIXEL_UNPACK_BUFFER.getTargetParameter()); + + this.bindBuffer(GlBufferTarget.PIXEL_PACK_BUFFER, null); + this.bindBuffer(GlBufferTarget.PIXEL_UNPACK_BUFFER, null); } @Override -- 2.54.1 From 91dc080322de2b8af677795975eb9168898b98af Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Tue, 4 Nov 2025 16:40:10 -0500 Subject: [PATCH 9/9] include APPLE suffix in APPLEVertexArrayObject methods --- .../impl/gl/util/APPLEVertexArrayObject.java | 22 +++++++++---------- .../embeddium/impl/gl/util/VAOUtil.java | 14 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java index 3850c6496..d3412c431 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/APPLEVertexArrayObject.java @@ -34,42 +34,42 @@ public class APPLEVertexArrayObject { public static final boolean supported = bindVertexArray != 0; - public static void glBindVertexArray(@NativeType("GLuint") int array) { + public static void glBindVertexArrayAPPLE(@NativeType("GLuint") int array) { JNI.callV(array, bindVertexArray); } - public static void nglDeleteVertexArrays(int n, long arrays) { + public static void nglDeleteVertexArraysAPPLE(int n, long arrays) { JNI.callPV(n, arrays, deleteVertexArrays); } - public static void glDeleteVertexArrays(@NativeType("GLuint const *") IntBuffer arrays) { - nglDeleteVertexArrays(arrays.remaining(), memAddress(arrays)); + public static void glDeleteVertexArraysAPPLE(@NativeType("GLuint const *") IntBuffer arrays) { + nglDeleteVertexArraysAPPLE(arrays.remaining(), memAddress(arrays)); } - public static void glDeleteVertexArrays(@NativeType("GLuint const *") int array) { + public static void glDeleteVertexArraysAPPLE(@NativeType("GLuint const *") int array) { MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { IntBuffer arrays = stack.callocInt(1); arrays.put(0, array); - nglDeleteVertexArrays(1, memAddress(arrays)); + nglDeleteVertexArraysAPPLE(1, memAddress(arrays)); } finally { stack.setPointer(stackPointer); } } - public static void nglGenVertexArrays(int n, long arrays) { + public static void nglGenVertexArraysAPPLE(int n, long arrays) { JNI.callPV(n, arrays, genVertexArrays); } - public static void glGenVertexArrays(@NativeType("GLuint *") IntBuffer arrays) { - nglGenVertexArrays(arrays.remaining(), memAddress(arrays)); + public static void glGenVertexArraysAPPLE(@NativeType("GLuint *") IntBuffer arrays) { + nglGenVertexArraysAPPLE(arrays.remaining(), memAddress(arrays)); } - public static int glGenVertexArrays() { + public static int glGenVertexArraysAPPLE() { MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { IntBuffer arrays = stack.callocInt(1); - nglGenVertexArrays(1, memAddress(arrays)); + nglGenVertexArraysAPPLE(1, memAddress(arrays)); return arrays.get(0); } finally { stack.setPointer(stackPointer); diff --git a/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/VAOUtil.java b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/VAOUtil.java index dc5591daa..5cc8ef509 100644 --- a/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/VAOUtil.java +++ b/common/src/main/java/org/embeddedt/embeddium/impl/gl/util/VAOUtil.java @@ -23,7 +23,7 @@ public class VAOUtil { } else if (arbSupported) { ARBVertexArrayObject.glBindVertexArray(array); } else if (appleSupported) { - APPLEVertexArrayObject.glBindVertexArray(array); + APPLEVertexArrayObject.glBindVertexArrayAPPLE(array); } else { throw new UnsupportedOperationException("VAO not supported"); } @@ -35,7 +35,7 @@ public class VAOUtil { } else if (arbSupported) { ARBVertexArrayObject.nglDeleteVertexArrays(n, arrays); } else if (appleSupported) { - APPLEVertexArrayObject.nglDeleteVertexArrays(n, arrays); + APPLEVertexArrayObject.nglDeleteVertexArraysAPPLE(n, arrays); } else { throw new UnsupportedOperationException("VAO not supported"); } @@ -47,7 +47,7 @@ public class VAOUtil { } else if (arbSupported) { ARBVertexArrayObject.glDeleteVertexArrays(arrays); } else if (appleSupported) { - APPLEVertexArrayObject.glDeleteVertexArrays(arrays); + APPLEVertexArrayObject.glDeleteVertexArraysAPPLE(arrays); } else { throw new UnsupportedOperationException("VAO not supported"); } @@ -59,7 +59,7 @@ public class VAOUtil { } else if (arbSupported) { ARBVertexArrayObject.glDeleteVertexArrays(array); } else if (appleSupported) { - APPLEVertexArrayObject.glDeleteVertexArrays(array); + APPLEVertexArrayObject.glDeleteVertexArraysAPPLE(array); } else { throw new UnsupportedOperationException("VAO not supported"); } @@ -71,7 +71,7 @@ public class VAOUtil { } else if (arbSupported) { ARBVertexArrayObject.nglGenVertexArrays(n, arrays); } else if (appleSupported) { - APPLEVertexArrayObject.nglGenVertexArrays(n, arrays); + APPLEVertexArrayObject.nglGenVertexArraysAPPLE(n, arrays); } else { throw new UnsupportedOperationException("VAO not supported"); } @@ -83,7 +83,7 @@ public class VAOUtil { } else if (arbSupported) { ARBVertexArrayObject.glGenVertexArrays(arrays); } else if (appleSupported) { - APPLEVertexArrayObject.glGenVertexArrays(arrays); + APPLEVertexArrayObject.glGenVertexArraysAPPLE(arrays); } else { throw new UnsupportedOperationException("VAO not supported"); } @@ -95,7 +95,7 @@ public class VAOUtil { } else if (arbSupported) { return ARBVertexArrayObject.glGenVertexArrays(); } else if (appleSupported) { - return APPLEVertexArrayObject.glGenVertexArrays(); + return APPLEVertexArrayObject.glGenVertexArraysAPPLE(); } else { throw new UnsupportedOperationException("VAO not supported"); } -- 2.54.1