From 879a4793531d10350ed3c3e2a542892f7c8d3373 Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:02:29 -0400 Subject: [PATCH] Added some more things to the OpenGL Emulator Added a BufferUtils class, and rewrote "glOrtho" to take in float & double parameters. --- .../minecraft/GlStateManager.java | 34 +++++++++++++++---- src/main/java/org/lwjgl/BufferUtils.java | 23 +++++++++++++ 2 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 src/main/java/org/lwjgl/BufferUtils.java diff --git a/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java b/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java index 9edb2bb..d1b58a0 100644 --- a/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java +++ b/src/main/java/net/PeytonPlayz585/minecraft/GlStateManager.java @@ -325,23 +325,43 @@ public class GlStateManager extends LWJGL { _wglClear(p1); } - public static final void glOrtho(float left, float right, float bottom, float top, float zNear, float zFar) { + public static final void glOrtho(double l, double r, double b, double t, double n, double f) { Matrix4f res = getMatrix(); - res.m00 = 2.0f / (right - left); + res.m00 = (float) (2.0f / (r - l)); res.m01 = 0.0f; res.m02 = 0.0f; res.m03 = 0.0f; res.m10 = 0.0f; - res.m11 = 2.0f / (top - bottom); + res.m11 = (float) (2.0f / (t - b)); res.m12 = 0.0f; res.m13 = 0.0f; res.m20 = 0.0f; res.m21 = 0.0f; - res.m22 = 2.0f / (zFar - zNear); + res.m22 = (float) (2.0f / (f - n)); res.m23 = 0.0f; - res.m30 = -(right + left) / (right - left); - res.m31 = -(top + bottom) / (top - bottom); - res.m32 = (zFar + zNear) / (zFar - zNear); + res.m30 = (float) (-(r + l) / (r - l)); + res.m31 = (float) (-(t + b) / (t - b)); + res.m32 = (float) ((f + n) / (f - n)); + res.m33 = 1.0f; + } + + public static final void glOrtho(float l, float r, float b, float t, float n, float f) { + Matrix4f res = getMatrix(); + res.m00 = 2.0f / (r - l); + res.m01 = 0.0f; + res.m02 = 0.0f; + res.m03 = 0.0f; + res.m10 = 0.0f; + res.m11 = 2.0f / (t - b); + res.m12 = 0.0f; + res.m13 = 0.0f; + res.m20 = 0.0f; + res.m21 = 0.0f; + res.m22 = 2.0f / (f - n); + res.m23 = 0.0f; + res.m30 = -(r + l) / (r - l); + res.m31 = -(t + b) / (t - b); + res.m32 = (f + n) / (f - n); res.m33 = 1.0f; } diff --git a/src/main/java/org/lwjgl/BufferUtils.java b/src/main/java/org/lwjgl/BufferUtils.java new file mode 100644 index 0000000..bdba91c --- /dev/null +++ b/src/main/java/org/lwjgl/BufferUtils.java @@ -0,0 +1,23 @@ +package org.lwjgl; + +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +import net.PeytonPlayz585.minecraft.GLAllocation; + +public class BufferUtils { + + public static ByteBuffer createByteBuffer(int parInt) { + return GLAllocation.createDirectByteBuffer(parInt); + } + + public static IntBuffer createIntBuffer(int parInt) { + return GLAllocation.createDirectIntBuffer(parInt); + } + + public static FloatBuffer createFloatBuffer(int parInt) { + return GLAllocation.createDirectFloatBuffer(parInt); + } + +}