mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2026-08-22 10:55:17 -06:00
Replace JOGL with LWJGL 3 + forked rlawt; HD mode now works on macOS
HD rendering previously required JOGL, whose macOS support was broken two
ways: the bundled natives are x86_64-only (UnsatisfiedLinkError on Apple
Silicon), and its AWT/CALayer presentation path never composites the GL
output (black window), on top of requesting a GL3bc profile macOS does not
offer. This replaces the whole windowing/GL layer:
* rlawt (RuneLite's AWT-GL bridge, BSD-2) vendored under rlawt/ with two
macOS patches: request the Legacy (2.1 compatibility) profile instead of
GL4 core, since this renderer is fixed-function + ARB assembly programs,
and attach a GL_DEPTH_COMPONENT24 renderbuffer to the IOSurface-backed
framebuffers (RuneLite renders depth-free; this client needs a Z-buffer).
Universal arm64+x86_64 dylib built by rlawt/build-macos.sh; Windows/Linux
ship unmodified upstream rlawt natives, whose contexts are already
compatibility-profile.
* New rt4.GL2 shim exposes JOGL's GL2 instance API over LWJGL 3 statics, so
the ~950 existing gl.glXxx call sites across 26 renderer files stay
untouched (they only lose their com.jogamp import). The shim bridges the
API differences: array+offset overloads, heap-buffer uploads copied to a
scratch direct buffer, glTexStorage2D emulation on pre-4.2 contexts,
glGenerateMipmap EXT fallback, extension queries, and vsync control.
* GlRenderer context lifecycle rewritten on AWTContext: synchronous init,
and the rotated IOSurface back-FBO is re-bound after every swap on macOS.
The old createAndDestroyContext JOGL surface-reset hack is now a no-op.
* The CS2 detail-mode auto-revert ("The change of detail mode has been
cancelled") no longer triggers: it raced JOGL's slow retry-looped init,
and rlawt's init completes synchronously before the script's readback.
Verified in-game on Apple Silicon with a native arm64 JVM (no Rosetta):
SD unchanged, HD switches and renders with no black screen and no revert.
Windows/Linux are compile-checked; runtime behavior should match JOGL's
(same GL calls on a compatibility context) but has not been re-tested.
Also lifts the old "Java 15 or lower" JOGL/WGL restriction on Windows.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PDSjdSB4Hwa53cmLg47pq3
This commit is contained in:
parent
ab2a28db8c
commit
a5f1dfeb20
69 changed files with 3523 additions and 165 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
|
|||
769
client/src/main/java/rt4/GL2.java
Normal file
769
client/src/main/java/rt4/GL2.java
Normal file
|
|
@ -0,0 +1,769 @@
|
|||
package rt4;
|
||||
|
||||
import org.lwjgl.opengl.ARBFragmentProgram;
|
||||
import org.lwjgl.opengl.ARBVertexProgram;
|
||||
import org.lwjgl.opengl.EXTFramebufferObject;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GLCapabilities;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Drop-in replacement for JOGL's {@code com.jogamp.opengl.GL2} instance API,
|
||||
* backed by LWJGL 3's static bindings. The rest of the renderer keeps calling
|
||||
* {@code gl.glXxx(...)} exactly as it did under JOGL; this class adapts the
|
||||
* differing conventions:
|
||||
* <ul>
|
||||
* <li>JOGL's array+offset overloads (LWJGL arrays have no offset)</li>
|
||||
* <li>heap (non-direct) NIO buffers, which JOGL copied internally but LWJGL
|
||||
* rejects — only ever passed to upload-style calls that copy at call
|
||||
* time, so a shared scratch buffer is safe</li>
|
||||
* <li>{@code isExtensionAvailable}/{@code setSwapInterval}, which have no
|
||||
* LWJGL equivalent on a raw context</li>
|
||||
* </ul>
|
||||
*/
|
||||
public final class GL2 {
|
||||
|
||||
public static final GL2 INSTANCE = new GL2();
|
||||
|
||||
private static GLCapabilities caps;
|
||||
private static Set<String> extensions = Collections.emptySet();
|
||||
|
||||
private GL2() {
|
||||
}
|
||||
|
||||
/** Called by GlRenderer right after GL.createCapabilities(). */
|
||||
static void init(GLCapabilities capabilities) {
|
||||
caps = capabilities;
|
||||
Set<String> exts = new HashSet<>();
|
||||
// Compatibility contexts (the only kind this renderer runs on) still
|
||||
// support the aggregate GL_EXTENSIONS string on every platform.
|
||||
String all = GL11.glGetString(GL11.GL_EXTENSIONS);
|
||||
if (all != null) {
|
||||
exts.addAll(Arrays.asList(all.split(" ")));
|
||||
}
|
||||
extensions = exts;
|
||||
}
|
||||
|
||||
static void shutdown() {
|
||||
caps = null;
|
||||
extensions = Collections.emptySet();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Constants (values taken from LWJGL so they cannot drift)
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
public static final int GL_ADD = GL11.GL_ADD;
|
||||
public static final int GL_ADD_SIGNED = GL13.GL_ADD_SIGNED;
|
||||
public static final int GL_ALPHA = GL11.GL_ALPHA;
|
||||
public static final int GL_ALPHA_TEST = GL11.GL_ALPHA_TEST;
|
||||
public static final int GL_AMBIENT = GL11.GL_AMBIENT;
|
||||
public static final int GL_AMBIENT_AND_DIFFUSE = GL11.GL_AMBIENT_AND_DIFFUSE;
|
||||
public static final int GL_ARRAY_BUFFER = GL15.GL_ARRAY_BUFFER;
|
||||
public static final int GL_BACK = GL11.GL_BACK;
|
||||
public static final int GL_BACK_LEFT = GL11.GL_BACK_LEFT;
|
||||
public static final int GL_BGRA = GL12.GL_BGRA;
|
||||
public static final int GL_BLEND = GL11.GL_BLEND;
|
||||
public static final int GL_C4UB_V3F = GL11.GL_C4UB_V3F;
|
||||
public static final int GL_CLAMP_TO_EDGE = GL12.GL_CLAMP_TO_EDGE;
|
||||
public static final int GL_COLOR = GL11.GL_COLOR;
|
||||
public static final int GL_COLOR_ARRAY = GL11.GL_COLOR_ARRAY;
|
||||
public static final int GL_COLOR_BUFFER_BIT = GL11.GL_COLOR_BUFFER_BIT;
|
||||
public static final int GL_COLOR_MATERIAL = GL11.GL_COLOR_MATERIAL;
|
||||
public static final int GL_COMBINE = GL13.GL_COMBINE;
|
||||
public static final int GL_COMBINE_ALPHA = GL13.GL_COMBINE_ALPHA;
|
||||
public static final int GL_COMBINE_RGB = GL13.GL_COMBINE_RGB;
|
||||
public static final int GL_COMPILE = GL11.GL_COMPILE;
|
||||
public static final int GL_CONSTANT = GL13.GL_CONSTANT;
|
||||
public static final int GL_CONSTANT_ATTENUATION = GL11.GL_CONSTANT_ATTENUATION;
|
||||
public static final int GL_CULL_FACE = GL11.GL_CULL_FACE;
|
||||
public static final int GL_DEPTH_BUFFER_BIT = GL11.GL_DEPTH_BUFFER_BIT;
|
||||
public static final int GL_DEPTH_TEST = GL11.GL_DEPTH_TEST;
|
||||
public static final int GL_DIFFUSE = GL11.GL_DIFFUSE;
|
||||
public static final int GL_DRAW_BUFFER = GL11.GL_DRAW_BUFFER;
|
||||
public static final int GL_DST_COLOR = GL11.GL_DST_COLOR;
|
||||
public static final int GL_ELEMENT_ARRAY_BUFFER = GL15.GL_ELEMENT_ARRAY_BUFFER;
|
||||
public static final int GL_ENABLE_BIT = GL11.GL_ENABLE_BIT;
|
||||
public static final int GL_EYE_LINEAR = GL11.GL_EYE_LINEAR;
|
||||
public static final int GL_EYE_PLANE = GL11.GL_EYE_PLANE;
|
||||
public static final int GL_FASTEST = GL11.GL_FASTEST;
|
||||
public static final int GL_FILL = GL11.GL_FILL;
|
||||
public static final int GL_FLOAT = GL11.GL_FLOAT;
|
||||
public static final int GL_FOG = GL11.GL_FOG;
|
||||
public static final int GL_FOG_BIT = GL11.GL_FOG_BIT;
|
||||
public static final int GL_FOG_COLOR = GL11.GL_FOG_COLOR;
|
||||
public static final int GL_FOG_DENSITY = GL11.GL_FOG_DENSITY;
|
||||
public static final int GL_FOG_END = GL11.GL_FOG_END;
|
||||
public static final int GL_FOG_HINT = GL11.GL_FOG_HINT;
|
||||
public static final int GL_FOG_MODE = GL11.GL_FOG_MODE;
|
||||
public static final int GL_FOG_START = GL11.GL_FOG_START;
|
||||
public static final int GL_FRAGMENT_PROGRAM_ARB = ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB;
|
||||
public static final int GL_FRONT = GL11.GL_FRONT;
|
||||
public static final int GL_FRONT_LEFT = GL11.GL_FRONT_LEFT;
|
||||
public static final int GL_GENERATE_MIPMAP = GL14.GL_GENERATE_MIPMAP;
|
||||
public static final int GL_GREATER = GL11.GL_GREATER;
|
||||
public static final int GL_INTERPOLATE = GL13.GL_INTERPOLATE;
|
||||
public static final int GL_LEQUAL = GL11.GL_LEQUAL;
|
||||
public static final int GL_LIGHT_MODEL_AMBIENT = GL11.GL_LIGHT_MODEL_AMBIENT;
|
||||
public static final int GL_LIGHT0 = GL11.GL_LIGHT0;
|
||||
public static final int GL_LIGHT1 = GL11.GL_LIGHT1;
|
||||
public static final int GL_LIGHTING = GL11.GL_LIGHTING;
|
||||
public static final int GL_LINE_LOOP = GL11.GL_LINE_LOOP;
|
||||
public static final int GL_LINEAR = GL11.GL_LINEAR;
|
||||
public static final int GL_LINEAR_ATTENUATION = GL11.GL_LINEAR_ATTENUATION;
|
||||
public static final int GL_LINEAR_MIPMAP_LINEAR = GL11.GL_LINEAR_MIPMAP_LINEAR;
|
||||
public static final int GL_LINES = GL11.GL_LINES;
|
||||
public static final int GL_LUMINANCE_ALPHA = GL11.GL_LUMINANCE_ALPHA;
|
||||
public static final int GL_MAX_TEXTURE_COORDS = GL20.GL_MAX_TEXTURE_COORDS;
|
||||
public static final int GL_MAX_TEXTURE_IMAGE_UNITS = GL20.GL_MAX_TEXTURE_IMAGE_UNITS;
|
||||
public static final int GL_MAX_TEXTURE_UNITS = GL13.GL_MAX_TEXTURE_UNITS;
|
||||
public static final int GL_MODELVIEW = GL11.GL_MODELVIEW;
|
||||
public static final int GL_MODULATE = GL11.GL_MODULATE;
|
||||
public static final int GL_NEAREST = GL11.GL_NEAREST;
|
||||
public static final int GL_NORMAL_ARRAY = GL11.GL_NORMAL_ARRAY;
|
||||
public static final int GL_NORMAL_MAP = GL13.GL_NORMAL_MAP;
|
||||
public static final int GL_OBJECT_LINEAR = GL11.GL_OBJECT_LINEAR;
|
||||
public static final int GL_OBJECT_PLANE = GL11.GL_OBJECT_PLANE;
|
||||
public static final int GL_ONE = GL11.GL_ONE;
|
||||
public static final int GL_ONE_MINUS_SRC_ALPHA = GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
public static final int GL_OPERAND0_RGB = GL13.GL_OPERAND0_RGB;
|
||||
public static final int GL_OPERAND1_RGB = GL13.GL_OPERAND1_RGB;
|
||||
public static final int GL_POINT_DISTANCE_ATTENUATION = GL14.GL_POINT_DISTANCE_ATTENUATION;
|
||||
public static final int GL_POINT_SIZE_MAX = GL14.GL_POINT_SIZE_MAX;
|
||||
public static final int GL_POINT_SIZE_MIN = GL14.GL_POINT_SIZE_MIN;
|
||||
public static final int GL_POSITION = GL11.GL_POSITION;
|
||||
public static final int GL_PREVIOUS = GL13.GL_PREVIOUS;
|
||||
public static final int GL_PRIMARY_COLOR = GL13.GL_PRIMARY_COLOR;
|
||||
public static final int GL_PROGRAM_ERROR_POSITION_ARB = ARBVertexProgram.GL_PROGRAM_ERROR_POSITION_ARB;
|
||||
public static final int GL_PROGRAM_FORMAT_ASCII_ARB = ARBVertexProgram.GL_PROGRAM_FORMAT_ASCII_ARB;
|
||||
public static final int GL_PROJECTION = GL11.GL_PROJECTION;
|
||||
public static final int GL_Q = GL11.GL_Q;
|
||||
public static final int GL_QUADRATIC_ATTENUATION = GL11.GL_QUADRATIC_ATTENUATION;
|
||||
public static final int GL_R = GL11.GL_R;
|
||||
public static final int GL_READ_BUFFER = GL11.GL_READ_BUFFER;
|
||||
public static final int GL_RENDERER = GL11.GL_RENDERER;
|
||||
public static final int GL_REPEAT = GL11.GL_REPEAT;
|
||||
public static final int GL_REPLACE = GL11.GL_REPLACE;
|
||||
public static final int GL_RGB_SCALE = GL13.GL_RGB_SCALE;
|
||||
public static final int GL_RGBA = GL11.GL_RGBA;
|
||||
public static final int GL_RGBA8 = GL11.GL_RGBA8;
|
||||
public static final int GL_S = GL11.GL_S;
|
||||
public static final int GL_SCISSOR_TEST = GL11.GL_SCISSOR_TEST;
|
||||
public static final int GL_SMOOTH = GL11.GL_SMOOTH;
|
||||
public static final int GL_SRC_ALPHA = GL11.GL_SRC_ALPHA;
|
||||
public static final int GL_SRC_COLOR = GL11.GL_SRC_COLOR;
|
||||
public static final int GL_SRC0_ALPHA = GL15.GL_SRC0_ALPHA;
|
||||
public static final int GL_SRC0_RGB = GL15.GL_SRC0_RGB;
|
||||
public static final int GL_SRC1_ALPHA = GL15.GL_SRC1_ALPHA;
|
||||
public static final int GL_SRC1_RGB = GL15.GL_SRC1_RGB;
|
||||
public static final int GL_SRC2_ALPHA = GL15.GL_SRC2_ALPHA;
|
||||
public static final int GL_SRC2_RGB = GL15.GL_SRC2_RGB;
|
||||
public static final int GL_STATIC_DRAW = GL15.GL_STATIC_DRAW;
|
||||
public static final int GL_STREAM_DRAW = GL15.GL_STREAM_DRAW;
|
||||
public static final int GL_SUBTRACT = GL13.GL_SUBTRACT;
|
||||
public static final int GL_T = GL11.GL_T;
|
||||
public static final int GL_T2F_V3F = GL11.GL_T2F_V3F;
|
||||
public static final int GL_TEXTURE = GL11.GL_TEXTURE;
|
||||
public static final int GL_TEXTURE_1D = GL11.GL_TEXTURE_1D;
|
||||
public static final int GL_TEXTURE_2D = GL11.GL_TEXTURE_2D;
|
||||
public static final int GL_TEXTURE_3D = GL12.GL_TEXTURE_3D;
|
||||
public static final int GL_TEXTURE_COORD_ARRAY = GL11.GL_TEXTURE_COORD_ARRAY;
|
||||
public static final int GL_TEXTURE_CUBE_MAP = GL13.GL_TEXTURE_CUBE_MAP;
|
||||
public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_X = GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
||||
public static final int GL_TEXTURE_ENV = GL11.GL_TEXTURE_ENV;
|
||||
public static final int GL_TEXTURE_ENV_COLOR = GL11.GL_TEXTURE_ENV_COLOR;
|
||||
public static final int GL_TEXTURE_ENV_MODE = GL11.GL_TEXTURE_ENV_MODE;
|
||||
public static final int GL_TEXTURE_GEN_MODE = GL11.GL_TEXTURE_GEN_MODE;
|
||||
public static final int GL_TEXTURE_GEN_Q = GL11.GL_TEXTURE_GEN_Q;
|
||||
public static final int GL_TEXTURE_GEN_R = GL11.GL_TEXTURE_GEN_R;
|
||||
public static final int GL_TEXTURE_GEN_S = GL11.GL_TEXTURE_GEN_S;
|
||||
public static final int GL_TEXTURE_GEN_T = GL11.GL_TEXTURE_GEN_T;
|
||||
public static final int GL_TEXTURE_MAG_FILTER = GL11.GL_TEXTURE_MAG_FILTER;
|
||||
public static final int GL_TEXTURE_MIN_FILTER = GL11.GL_TEXTURE_MIN_FILTER;
|
||||
public static final int GL_TEXTURE_WRAP_R = GL12.GL_TEXTURE_WRAP_R;
|
||||
public static final int GL_TEXTURE_WRAP_S = GL11.GL_TEXTURE_WRAP_S;
|
||||
public static final int GL_TEXTURE_WRAP_T = GL11.GL_TEXTURE_WRAP_T;
|
||||
public static final int GL_TEXTURE0 = GL13.GL_TEXTURE0;
|
||||
public static final int GL_TEXTURE1 = GL13.GL_TEXTURE1;
|
||||
public static final int GL_TEXTURE2 = GL13.GL_TEXTURE2;
|
||||
public static final int GL_TRIANGLE_FAN = GL11.GL_TRIANGLE_FAN;
|
||||
public static final int GL_TRIANGLES = GL11.GL_TRIANGLES;
|
||||
public static final int GL_TRUE = GL11.GL_TRUE;
|
||||
public static final int GL_UNSIGNED_BYTE = GL11.GL_UNSIGNED_BYTE;
|
||||
public static final int GL_UNSIGNED_INT = GL11.GL_UNSIGNED_INT;
|
||||
public static final int GL_UNSIGNED_INT_8_8_8_8_REV = GL12.GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
public static final int GL_VENDOR = GL11.GL_VENDOR;
|
||||
public static final int GL_VERSION = GL11.GL_VERSION;
|
||||
public static final int GL_VERTEX_ARRAY = GL11.GL_VERTEX_ARRAY;
|
||||
public static final int GL_VERTEX_PROGRAM_ARB = ARBVertexProgram.GL_VERTEX_PROGRAM_ARB;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
private static ByteBuffer scratch;
|
||||
|
||||
private static ByteBuffer scratchFor(int bytes) {
|
||||
if (scratch == null || scratch.capacity() < bytes) {
|
||||
int cap = scratch == null ? 4096 : scratch.capacity();
|
||||
while (cap < bytes) {
|
||||
cap *= 2;
|
||||
}
|
||||
scratch = ByteBuffer.allocateDirect(cap).order(ByteOrder.nativeOrder());
|
||||
}
|
||||
scratch.clear();
|
||||
return scratch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a direct buffer with the same remaining contents as {@code data}.
|
||||
* Heap buffers are copied into the shared scratch buffer, which is only
|
||||
* valid until the next GL2 call — fine for uploads that copy at call time
|
||||
* (glTexImage*, glBufferData, glDrawPixels), never used for client-side
|
||||
* vertex arrays (those are allocateDirect throughout the client).
|
||||
*/
|
||||
private static Buffer direct(Buffer data) {
|
||||
if (data == null || data.isDirect()) {
|
||||
return data;
|
||||
}
|
||||
if (data instanceof ByteBuffer) {
|
||||
ByteBuffer src = ((ByteBuffer) data).duplicate();
|
||||
ByteBuffer dst = scratchFor(src.remaining());
|
||||
dst.put(src);
|
||||
dst.flip();
|
||||
return dst;
|
||||
}
|
||||
if (data instanceof IntBuffer) {
|
||||
IntBuffer src = ((IntBuffer) data).duplicate();
|
||||
IntBuffer dst = scratchFor(src.remaining() * 4).asIntBuffer();
|
||||
dst.put(src);
|
||||
dst.flip();
|
||||
return dst;
|
||||
}
|
||||
if (data instanceof FloatBuffer) {
|
||||
FloatBuffer src = ((FloatBuffer) data).duplicate();
|
||||
FloatBuffer dst = scratchFor(src.remaining() * 4).asFloatBuffer();
|
||||
dst.put(src);
|
||||
dst.flip();
|
||||
return dst;
|
||||
}
|
||||
throw new IllegalArgumentException("unsupported buffer type: " + data.getClass());
|
||||
}
|
||||
|
||||
/** Address of a direct buffer at its current position. */
|
||||
private static long addr(Buffer data) {
|
||||
if (data instanceof ByteBuffer) {
|
||||
return MemoryUtil.memAddress((ByteBuffer) data);
|
||||
}
|
||||
if (data instanceof IntBuffer) {
|
||||
return MemoryUtil.memAddress((IntBuffer) data);
|
||||
}
|
||||
if (data instanceof FloatBuffer) {
|
||||
return MemoryUtil.memAddress((FloatBuffer) data);
|
||||
}
|
||||
throw new IllegalArgumentException("unsupported buffer type: " + data.getClass());
|
||||
}
|
||||
|
||||
private static float[] slice(float[] a, int offset) {
|
||||
return offset == 0 ? a : Arrays.copyOfRange(a, offset, a.length);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// JOGL GL2 API surface used by the client
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
public boolean isExtensionAvailable(String name) {
|
||||
return extensions.contains(name);
|
||||
}
|
||||
|
||||
public void setSwapInterval(int interval) {
|
||||
GlRenderer.setSwapInterval(interval);
|
||||
}
|
||||
|
||||
public void glActiveTexture(int texture) {
|
||||
GL13.glActiveTexture(texture);
|
||||
}
|
||||
|
||||
public void glAlphaFunc(int func, float ref) {
|
||||
GL11.glAlphaFunc(func, ref);
|
||||
}
|
||||
|
||||
public void glBegin(int mode) {
|
||||
GL11.glBegin(mode);
|
||||
}
|
||||
|
||||
public void glBindBuffer(int target, int buffer) {
|
||||
GL15.glBindBuffer(target, buffer);
|
||||
}
|
||||
|
||||
public void glBindProgramARB(int target, int program) {
|
||||
ARBVertexProgram.glBindProgramARB(target, program);
|
||||
}
|
||||
|
||||
public void glBindTexture(int target, int texture) {
|
||||
GL11.glBindTexture(target, texture);
|
||||
}
|
||||
|
||||
public void glBlendFunc(int sfactor, int dfactor) {
|
||||
GL11.glBlendFunc(sfactor, dfactor);
|
||||
}
|
||||
|
||||
public void glBufferData(int target, long size, Buffer data, int usage) {
|
||||
Buffer d = direct(data);
|
||||
GL15.nglBufferData(target, size, d == null ? 0L : addr(d), usage);
|
||||
}
|
||||
|
||||
public void glBufferSubData(int target, long offset, long size, Buffer data) {
|
||||
Buffer d = direct(data);
|
||||
GL15.nglBufferSubData(target, offset, size, addr(d));
|
||||
}
|
||||
|
||||
public void glCallList(int list) {
|
||||
GL11.glCallList(list);
|
||||
}
|
||||
|
||||
public void glClear(int mask) {
|
||||
GL11.glClear(mask);
|
||||
}
|
||||
|
||||
public void glClearColor(float red, float green, float blue, float alpha) {
|
||||
GL11.glClearColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glClearDepth(double depth) {
|
||||
GL11.glClearDepth(depth);
|
||||
}
|
||||
|
||||
public void glClientActiveTexture(int texture) {
|
||||
GL13.glClientActiveTexture(texture);
|
||||
}
|
||||
|
||||
public void glColor3ub(byte red, byte green, byte blue) {
|
||||
GL11.glColor3ub(red, green, blue);
|
||||
}
|
||||
|
||||
public void glColor4f(float red, float green, float blue, float alpha) {
|
||||
GL11.glColor4f(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glColor4fv(float[] v, int offset) {
|
||||
float[] s = slice(v, offset);
|
||||
GL11.glColor4f(s[0], s[1], s[2], s[3]);
|
||||
}
|
||||
|
||||
public void glColor4ub(byte red, byte green, byte blue, byte alpha) {
|
||||
GL11.glColor4ub(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glColorMaterial(int face, int mode) {
|
||||
GL11.glColorMaterial(face, mode);
|
||||
}
|
||||
|
||||
public void glColorPointer(int size, int type, int stride, long pointerOffset) {
|
||||
GL11.glColorPointer(size, type, stride, pointerOffset);
|
||||
}
|
||||
|
||||
public void glColorPointer(int size, int type, int stride, ByteBuffer pointer) {
|
||||
GL11.nglColorPointer(size, type, stride, MemoryUtil.memAddress(pointer));
|
||||
}
|
||||
|
||||
public void glCopyPixels(int x, int y, int width, int height, int type) {
|
||||
GL11.glCopyPixels(x, y, width, height, type);
|
||||
}
|
||||
|
||||
public void glCullFace(int mode) {
|
||||
GL11.glCullFace(mode);
|
||||
}
|
||||
|
||||
public void glDeleteBuffers(int n, int[] buffers, int offset) {
|
||||
GL15.glDeleteBuffers(Arrays.copyOfRange(buffers, offset, offset + n));
|
||||
}
|
||||
|
||||
public void glDeleteLists(int list, int range) {
|
||||
GL11.glDeleteLists(list, range);
|
||||
}
|
||||
|
||||
public void glDeleteTextures(int n, int[] textures, int offset) {
|
||||
GL11.glDeleteTextures(Arrays.copyOfRange(textures, offset, offset + n));
|
||||
}
|
||||
|
||||
public void glDepthFunc(int func) {
|
||||
GL11.glDepthFunc(func);
|
||||
}
|
||||
|
||||
public void glDepthMask(boolean flag) {
|
||||
GL11.glDepthMask(flag);
|
||||
}
|
||||
|
||||
public void glDisable(int cap) {
|
||||
GL11.glDisable(cap);
|
||||
}
|
||||
|
||||
public void glDisableClientState(int cap) {
|
||||
GL11.glDisableClientState(cap);
|
||||
}
|
||||
|
||||
public void glDrawBuffer(int buf) {
|
||||
GL11.glDrawBuffer(buf);
|
||||
}
|
||||
|
||||
public void glDrawElements(int mode, int count, int type, long indicesOffset) {
|
||||
GL11.glDrawElements(mode, count, type, indicesOffset);
|
||||
}
|
||||
|
||||
public void glDrawElements(int mode, int count, int type, Buffer indices) {
|
||||
GL11.nglDrawElements(mode, count, type, addr(direct(indices)));
|
||||
}
|
||||
|
||||
public void glDrawPixels(int width, int height, int format, int type, Buffer pixels) {
|
||||
GL11.nglDrawPixels(width, height, format, type, addr(direct(pixels)));
|
||||
}
|
||||
|
||||
public void glEnable(int cap) {
|
||||
GL11.glEnable(cap);
|
||||
}
|
||||
|
||||
public void glEnableClientState(int cap) {
|
||||
GL11.glEnableClientState(cap);
|
||||
}
|
||||
|
||||
public void glEnd() {
|
||||
GL11.glEnd();
|
||||
}
|
||||
|
||||
public void glEndList() {
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
public void glFogf(int pname, float param) {
|
||||
GL11.glFogf(pname, param);
|
||||
}
|
||||
|
||||
public void glFogfv(int pname, float[] params, int offset) {
|
||||
GL11.glFogfv(pname, slice(params, offset));
|
||||
}
|
||||
|
||||
public void glFogi(int pname, int param) {
|
||||
GL11.glFogi(pname, param);
|
||||
}
|
||||
|
||||
public void glGenBuffers(int n, int[] buffers, int offset) {
|
||||
int[] tmp = new int[n];
|
||||
GL15.glGenBuffers(tmp);
|
||||
System.arraycopy(tmp, 0, buffers, offset, n);
|
||||
}
|
||||
|
||||
public int glGenLists(int range) {
|
||||
return GL11.glGenLists(range);
|
||||
}
|
||||
|
||||
public void glGenProgramsARB(int n, int[] programs, int offset) {
|
||||
int[] tmp = new int[n];
|
||||
ARBVertexProgram.glGenProgramsARB(tmp);
|
||||
System.arraycopy(tmp, 0, programs, offset, n);
|
||||
}
|
||||
|
||||
public void glGenTextures(int n, int[] textures, int offset) {
|
||||
int[] tmp = new int[n];
|
||||
GL11.glGenTextures(tmp);
|
||||
System.arraycopy(tmp, 0, textures, offset, n);
|
||||
}
|
||||
|
||||
public void glGenerateMipmap(int target) {
|
||||
if (caps != null && (caps.OpenGL30 || caps.GL_ARB_framebuffer_object)) {
|
||||
GL30.glGenerateMipmap(target);
|
||||
} else {
|
||||
EXTFramebufferObject.glGenerateMipmapEXT(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void glGetFloatv(int pname, float[] params, int offset) {
|
||||
float[] tmp = new float[params.length - offset];
|
||||
GL11.glGetFloatv(pname, tmp);
|
||||
System.arraycopy(tmp, 0, params, offset, tmp.length);
|
||||
}
|
||||
|
||||
public void glGetFloatv(int pname, FloatBuffer params) {
|
||||
if (params.isDirect()) {
|
||||
GL11.glGetFloatv(pname, params);
|
||||
return;
|
||||
}
|
||||
FloatBuffer tmp = scratchFor(params.remaining() * 4).asFloatBuffer();
|
||||
tmp.limit(params.remaining());
|
||||
GL11.glGetFloatv(pname, tmp);
|
||||
for (int i = 0; i < params.remaining(); i++) {
|
||||
params.put(params.position() + i, tmp.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void glGetIntegerv(int pname, int[] params, int offset) {
|
||||
if (offset == 0) {
|
||||
GL11.glGetIntegerv(pname, params);
|
||||
return;
|
||||
}
|
||||
int[] tmp = new int[params.length - offset];
|
||||
GL11.glGetIntegerv(pname, tmp);
|
||||
System.arraycopy(tmp, 0, params, offset, tmp.length);
|
||||
}
|
||||
|
||||
public String glGetString(int name) {
|
||||
return GL11.glGetString(name);
|
||||
}
|
||||
|
||||
public void glHint(int target, int hint) {
|
||||
GL11.glHint(target, hint);
|
||||
}
|
||||
|
||||
public void glInterleavedArrays(int format, int stride, long pointerOffset) {
|
||||
GL11.glInterleavedArrays(format, stride, pointerOffset);
|
||||
}
|
||||
|
||||
public void glInterleavedArrays(int format, int stride, ByteBuffer pointer) {
|
||||
GL11.nglInterleavedArrays(format, stride, MemoryUtil.memAddress(pointer));
|
||||
}
|
||||
|
||||
public void glLightModelfv(int pname, float[] params, int offset) {
|
||||
GL11.glLightModelfv(pname, slice(params, offset));
|
||||
}
|
||||
|
||||
public void glLightf(int light, int pname, float param) {
|
||||
GL11.glLightf(light, pname, param);
|
||||
}
|
||||
|
||||
public void glLightfv(int light, int pname, float[] params, int offset) {
|
||||
GL11.glLightfv(light, pname, slice(params, offset));
|
||||
}
|
||||
|
||||
public void glLineWidth(float width) {
|
||||
GL11.glLineWidth(width);
|
||||
}
|
||||
|
||||
public void glLoadIdentity() {
|
||||
GL11.glLoadIdentity();
|
||||
}
|
||||
|
||||
public void glLoadMatrixf(float[] m, int offset) {
|
||||
GL11.glLoadMatrixf(slice(m, offset));
|
||||
}
|
||||
|
||||
public void glMatrixMode(int mode) {
|
||||
GL11.glMatrixMode(mode);
|
||||
}
|
||||
|
||||
public void glMultiTexCoord2f(int target, float s, float t) {
|
||||
GL13.glMultiTexCoord2f(target, s, t);
|
||||
}
|
||||
|
||||
public void glNewList(int list, int mode) {
|
||||
GL11.glNewList(list, mode);
|
||||
}
|
||||
|
||||
public void glNormalPointer(int type, int stride, long pointerOffset) {
|
||||
GL11.glNormalPointer(type, stride, pointerOffset);
|
||||
}
|
||||
|
||||
public void glNormalPointer(int type, int stride, ByteBuffer pointer) {
|
||||
GL11.nglNormalPointer(type, stride, MemoryUtil.memAddress(pointer));
|
||||
}
|
||||
|
||||
public void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar) {
|
||||
GL11.glOrtho(left, right, bottom, top, zNear, zFar);
|
||||
}
|
||||
|
||||
public void glPixelZoom(float xfactor, float yfactor) {
|
||||
GL11.glPixelZoom(xfactor, yfactor);
|
||||
}
|
||||
|
||||
public void glPointParameterf(int pname, float param) {
|
||||
GL14.glPointParameterf(pname, param);
|
||||
}
|
||||
|
||||
public void glPointParameterfv(int pname, float[] params, int offset) {
|
||||
GL14.glPointParameterfv(pname, slice(params, offset));
|
||||
}
|
||||
|
||||
public void glPolygonMode(int face, int mode) {
|
||||
GL11.glPolygonMode(face, mode);
|
||||
}
|
||||
|
||||
public void glPopAttrib() {
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
public void glPopMatrix() {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void glProgramLocalParameter4fARB(int target, int index, float x, float y, float z, float w) {
|
||||
ARBVertexProgram.glProgramLocalParameter4fARB(target, index, x, y, z, w);
|
||||
}
|
||||
|
||||
public void glProgramLocalParameter4fvARB(int target, int index, float[] params, int offset) {
|
||||
float[] s = slice(params, offset);
|
||||
ARBVertexProgram.glProgramLocalParameter4fARB(target, index, s[0], s[1], s[2], s[3]);
|
||||
}
|
||||
|
||||
public void glProgramLocalParameter4fvARB(int target, int index, FloatBuffer params) {
|
||||
if (params.isDirect()) {
|
||||
ARBVertexProgram.glProgramLocalParameter4fvARB(target, index, params);
|
||||
} else {
|
||||
ARBVertexProgram.glProgramLocalParameter4fARB(target, index,
|
||||
params.get(params.position()), params.get(params.position() + 1),
|
||||
params.get(params.position() + 2), params.get(params.position() + 3));
|
||||
}
|
||||
}
|
||||
|
||||
public void glProgramStringARB(int target, int format, int length, String program) {
|
||||
ByteBuffer buf = scratchFor(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
buf.put((byte) program.charAt(i));
|
||||
}
|
||||
buf.flip();
|
||||
ARBVertexProgram.glProgramStringARB(target, format, buf);
|
||||
}
|
||||
|
||||
public void glPushAttrib(int mask) {
|
||||
GL11.glPushAttrib(mask);
|
||||
}
|
||||
|
||||
public void glPushMatrix() {
|
||||
GL11.glPushMatrix();
|
||||
}
|
||||
|
||||
public void glRasterPos2i(int x, int y) {
|
||||
GL11.glRasterPos2i(x, y);
|
||||
}
|
||||
|
||||
public void glReadBuffer(int src) {
|
||||
GL11.glReadBuffer(src);
|
||||
}
|
||||
|
||||
public void glReadPixels(int x, int y, int width, int height, int format, int type, Buffer pixels) {
|
||||
if (!pixels.isDirect()) {
|
||||
throw new IllegalArgumentException("glReadPixels requires a direct buffer");
|
||||
}
|
||||
GL11.nglReadPixels(x, y, width, height, format, type, addr(pixels));
|
||||
}
|
||||
|
||||
public void glRotatef(float angle, float x, float y, float z) {
|
||||
GL11.glRotatef(angle, x, y, z);
|
||||
}
|
||||
|
||||
public void glScalef(float x, float y, float z) {
|
||||
GL11.glScalef(x, y, z);
|
||||
}
|
||||
|
||||
public void glScissor(int x, int y, int width, int height) {
|
||||
GL11.glScissor(x, y, width, height);
|
||||
}
|
||||
|
||||
public void glShadeModel(int mode) {
|
||||
GL11.glShadeModel(mode);
|
||||
}
|
||||
|
||||
public void glTexCoord2f(float s, float t) {
|
||||
GL11.glTexCoord2f(s, t);
|
||||
}
|
||||
|
||||
public void glTexCoordPointer(int size, int type, int stride, long pointerOffset) {
|
||||
GL11.glTexCoordPointer(size, type, stride, pointerOffset);
|
||||
}
|
||||
|
||||
public void glTexCoordPointer(int size, int type, int stride, ByteBuffer pointer) {
|
||||
GL11.nglTexCoordPointer(size, type, stride, MemoryUtil.memAddress(pointer));
|
||||
}
|
||||
|
||||
public void glTexEnvf(int target, int pname, float param) {
|
||||
GL11.glTexEnvf(target, pname, param);
|
||||
}
|
||||
|
||||
public void glTexEnvfv(int target, int pname, float[] params, int offset) {
|
||||
GL11.glTexEnvfv(target, pname, slice(params, offset));
|
||||
}
|
||||
|
||||
public void glTexEnvi(int target, int pname, int param) {
|
||||
GL11.glTexEnvi(target, pname, param);
|
||||
}
|
||||
|
||||
public void glTexGenfv(int coord, int pname, float[] params, int offset) {
|
||||
GL11.glTexGenfv(coord, pname, slice(params, offset));
|
||||
}
|
||||
|
||||
public void glTexGeni(int coord, int pname, int param) {
|
||||
GL11.glTexGeni(coord, pname, param);
|
||||
}
|
||||
|
||||
public void glTexImage1D(int target, int level, int internalformat, int width, int border, int format, int type, Buffer pixels) {
|
||||
Buffer d = direct(pixels);
|
||||
GL11.nglTexImage1D(target, level, internalformat, width, border, format, type, d == null ? 0L : addr(d));
|
||||
}
|
||||
|
||||
public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, Buffer pixels) {
|
||||
Buffer d = direct(pixels);
|
||||
GL11.nglTexImage2D(target, level, internalformat, width, height, border, format, type, d == null ? 0L : addr(d));
|
||||
}
|
||||
|
||||
public void glTexImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int format, int type, Buffer pixels) {
|
||||
Buffer d = direct(pixels);
|
||||
GL12.nglTexImage3D(target, level, internalformat, width, height, depth, border, format, type, d == null ? 0L : addr(d));
|
||||
}
|
||||
|
||||
public void glTexParameteri(int target, int pname, int param) {
|
||||
GL11.glTexParameteri(target, pname, param);
|
||||
}
|
||||
|
||||
public void glTexStorage2D(int target, int levels, int internalformat, int width, int height) {
|
||||
if (caps != null && (caps.OpenGL42 || caps.GL_ARB_texture_storage)) {
|
||||
GL42.glTexStorage2D(target, levels, internalformat, width, height);
|
||||
return;
|
||||
}
|
||||
// Emulate immutable storage on old contexts (macOS 2.1) by allocating
|
||||
// each mip level; only ever called with GL_RGBA8 here.
|
||||
for (int level = 0; level < levels; level++) {
|
||||
int w = Math.max(1, width >> level);
|
||||
int h = Math.max(1, height >> level);
|
||||
GL11.nglTexImage2D(target, level, internalformat, w, h, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, Buffer pixels) {
|
||||
GL11.nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, addr(direct(pixels)));
|
||||
}
|
||||
|
||||
public void glTranslatef(float x, float y, float z) {
|
||||
GL11.glTranslatef(x, y, z);
|
||||
}
|
||||
|
||||
public void glVertex2f(float x, float y) {
|
||||
GL11.glVertex2f(x, y);
|
||||
}
|
||||
|
||||
public void glVertexPointer(int size, int type, int stride, long pointerOffset) {
|
||||
GL11.glVertexPointer(size, type, stride, pointerOffset);
|
||||
}
|
||||
|
||||
public void glVertexPointer(int size, int type, int stride, ByteBuffer pointer) {
|
||||
GL11.nglVertexPointer(size, type, stride, MemoryUtil.memAddress(pointer));
|
||||
}
|
||||
|
||||
public void glViewport(int x, int y, int width, int height) {
|
||||
GL11.glViewport(x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration;
|
||||
import com.jogamp.nativewindow.awt.JAWTWindow;
|
||||
import com.jogamp.opengl.*;
|
||||
import jogamp.newt.awt.NewtFactoryAWT;
|
||||
import net.runelite.rlawt.AWTContext;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GLCapabilities;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
@ -42,8 +42,8 @@ public final class GlRenderer {
|
|||
@OriginalMember(owner = "client!tf", name = "k", descriptor = "F")
|
||||
private static float aFloat32;
|
||||
|
||||
@OriginalMember(owner = "client!tf", name = "p", descriptor = "Lgl!javax/media/opengl/GLContext;")
|
||||
private static GLContext context;
|
||||
/** rlawt context bridging the AWT canvas to a native GL context. */
|
||||
static AWTContext awtContext;
|
||||
|
||||
@OriginalMember(owner = "client!tf", name = "r", descriptor = "Z")
|
||||
public static boolean extTexture3dSupported;
|
||||
|
|
@ -72,9 +72,6 @@ public final class GlRenderer {
|
|||
@OriginalMember(owner = "client!tf", name = "D", descriptor = "I")
|
||||
private static int maxTextureCoords;
|
||||
|
||||
@OriginalMember(owner = "client!tf", name = "E", descriptor = "Lgl!javax/media/opengl/GLDrawable;")
|
||||
private static GLDrawable drawable;
|
||||
|
||||
@OriginalMember(owner = "client!tf", name = "H", descriptor = "Z")
|
||||
public static boolean arbVertexProgramSupported;
|
||||
|
||||
|
|
@ -132,8 +129,6 @@ public final class GlRenderer {
|
|||
@OriginalMember(owner = "client!tf", name = "I", descriptor = "Lclient!na;")
|
||||
private static final JagString RADEON = JagString.parse("radeon");
|
||||
|
||||
private static JAWTWindow window;
|
||||
|
||||
@OriginalMember(owner = "client!tf", name = "a", descriptor = "(Ljava/lang/String;)Lclient!na;")
|
||||
private static JagString method4147(@OriginalArg(0) String arg0) {
|
||||
@Pc(3) byte[] local3;
|
||||
|
|
@ -205,12 +200,30 @@ public final class GlRenderer {
|
|||
@OriginalMember(owner = "client!tf", name = "d", descriptor = "()V")
|
||||
public static void swapBuffers() {
|
||||
try {
|
||||
drawable.swapBuffers();
|
||||
readPixels();
|
||||
awtContext.swapBuffers();
|
||||
// On macOS rlawt renders into IOSurface-backed FBOs and rotates
|
||||
// them on every swap, so the fresh back framebuffer must be bound
|
||||
// before anything else is drawn (returns 0 elsewhere: no-op).
|
||||
bindOutputFramebuffer();
|
||||
} catch (@Pc(3) Exception local3) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void bindOutputFramebuffer() {
|
||||
@Pc(1) int fbo = awtContext.getFramebuffer(false);
|
||||
if (fbo != 0) {
|
||||
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo);
|
||||
}
|
||||
}
|
||||
|
||||
/** Called by the GL2 shim to emulate JOGL's gl.setSwapInterval. */
|
||||
static void setSwapInterval(int interval) {
|
||||
if (awtContext != null) {
|
||||
awtContext.setSwapInterval(interval);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initializePixelBuffer(int width, int height) {
|
||||
// Allocate ByteBuffer for BGRA pixels (4 bytes per pixel)
|
||||
pixelByteBuffer = ByteBuffer.allocateDirect(width * height * 4).order(ByteOrder.nativeOrder());
|
||||
|
|
@ -332,6 +345,13 @@ public final class GlRenderer {
|
|||
|
||||
@OriginalMember(owner = "client!tf", name = "h", descriptor = "()V")
|
||||
public static void draw() {
|
||||
// Apple's GL does not support reliable GL_FRONT_LEFT reads; this front->back
|
||||
// glCopyPixels blit reads the front buffer and would smear garbage/black into
|
||||
// the back buffer on macOS, so skip it there and rely on normal back-buffer
|
||||
// rendering + swap.
|
||||
if (SignLink.osName != null && SignLink.osName.startsWith("mac")) {
|
||||
return;
|
||||
}
|
||||
@Pc(2) int[] local2 = new int[2];
|
||||
gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, local2, 0);
|
||||
gl.glGetIntegerv(GL2.GL_READ_BUFFER, local2, 1);
|
||||
|
|
@ -352,26 +372,10 @@ public final class GlRenderer {
|
|||
|
||||
@OriginalMember(owner = "client!tf", name = "a", descriptor = "(Ljava/awt/Canvas;)V")
|
||||
public static void createAndDestroyContext(@OriginalArg(0) Canvas canvas) {
|
||||
try {
|
||||
if (!canvas.isDisplayable()) {
|
||||
return;
|
||||
}
|
||||
GLProfile profile = GLProfile.getDefault();
|
||||
|
||||
GLCapabilities glCaps = new GLCapabilities(profile);
|
||||
AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(canvas.getGraphicsConfiguration(), glCaps, glCaps);
|
||||
JAWTWindow jawtWindow = NewtFactoryAWT.getNativeWindow(canvas, config);
|
||||
@Pc(5) GLDrawableFactory glDrawableFactory = GLDrawableFactory.getFactory(profile);
|
||||
@Pc(11) GLDrawable glDrawable = glDrawableFactory.createGLDrawable(jawtWindow);
|
||||
|
||||
glDrawable.setRealized(true);
|
||||
@Pc(18) GLContext glContext = glDrawable.createContext(null);
|
||||
glContext.makeCurrent();
|
||||
glContext.release();
|
||||
glContext.destroy();
|
||||
glDrawable.setRealized(false);
|
||||
} catch (@Pc(30) Throwable ex) {
|
||||
}
|
||||
// Under JOGL this created and immediately destroyed a GL context on the
|
||||
// fresh canvas when returning to SD, to reset the AWT drawing surface.
|
||||
// rlawt leaves the canvas untouched until a context is actually needed
|
||||
// (and on macOS would attach a stray CALayer here), so nothing to do.
|
||||
}
|
||||
|
||||
@OriginalMember(owner = "client!tf", name = "i", descriptor = "()V")
|
||||
|
|
@ -514,36 +518,21 @@ public final class GlRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
if (window != null) {
|
||||
if (!window.getLock().isLocked()) {
|
||||
window.lockSurface();
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
GlCleaner.clear(); // GlCleaner
|
||||
try {
|
||||
if (GLContext.getCurrent() == context) {
|
||||
context.release();
|
||||
}
|
||||
} catch (@Pc(17) Throwable ex) {
|
||||
}
|
||||
try {
|
||||
context.destroy();
|
||||
} catch (@Pc(21) Throwable ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (drawable != null) {
|
||||
if (awtContext != null) {
|
||||
try {
|
||||
drawable.setRealized(false);
|
||||
} catch (@Pc(30) Throwable ex) {
|
||||
GlCleaner.clear(); // GlCleaner
|
||||
} catch (@Pc(17) Throwable ex) {
|
||||
}
|
||||
try {
|
||||
awtContext.destroy();
|
||||
} catch (@Pc(21) Throwable ex) {
|
||||
}
|
||||
awtContext = null;
|
||||
}
|
||||
window = null;
|
||||
|
||||
GL.setCapabilities(null);
|
||||
GL2.shutdown();
|
||||
gl = null;
|
||||
context = null;
|
||||
drawable = null;
|
||||
LightingManager.method2398(); // LightingManager
|
||||
enabled = false;
|
||||
}
|
||||
|
|
@ -697,49 +686,26 @@ public final class GlRenderer {
|
|||
if (!canvas.isDisplayable()) {
|
||||
return -1;
|
||||
}
|
||||
GLProfile profile = GLProfile.get(GLProfile.GL3bc);
|
||||
@Pc(8) GLCapabilities capabilities = new GLCapabilities(profile);
|
||||
AWTContext.loadNatives();
|
||||
awtContext = new AWTContext(canvas);
|
||||
// 24-bit depth; on macOS this also puts a depth renderbuffer on the
|
||||
// IOSurface framebuffers (see the forked rlawt in /rlawt).
|
||||
awtContext.configurePixelFormat(0, 24, 0);
|
||||
if (numSamples > 0) {
|
||||
capabilities.setSampleBuffers(true);
|
||||
capabilities.setNumSamples(numSamples * 4);
|
||||
awtContext.configureMultisamples(numSamples * 4);
|
||||
}
|
||||
@Pc(18) GLDrawableFactory factory = GLDrawableFactory.getFactory(profile);
|
||||
AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(canvas.getGraphicsConfiguration(), capabilities, capabilities);
|
||||
window = NewtFactoryAWT.getNativeWindow(canvas, config);
|
||||
if (!window.getLock().isLocked()) {
|
||||
window.lockSurface();
|
||||
}
|
||||
try {
|
||||
drawable = factory.createGLDrawable(window);
|
||||
drawable.setRealized(true);
|
||||
} finally {
|
||||
window.unlockSurface();
|
||||
}
|
||||
@Pc(29) int swapBuffersAttempts = 0;
|
||||
@Pc(36) int result;
|
||||
while (true) {
|
||||
context = drawable.createContext(null);
|
||||
try {
|
||||
result = context.makeCurrent();
|
||||
if (result != 0) {
|
||||
break;
|
||||
}
|
||||
} catch (@Pc(41) Exception local41) {
|
||||
}
|
||||
if (swapBuffersAttempts++ > 5) {
|
||||
return -2;
|
||||
}
|
||||
ThreadUtils.sleep(1000L);
|
||||
}
|
||||
if (window.getLock().isLocked()) {
|
||||
window.unlockSurface();
|
||||
}
|
||||
gl = GLContext.getCurrentGL().getGL2();
|
||||
awtContext.createGLContext();
|
||||
awtContext.makeCurrent();
|
||||
@Pc(8) GLCapabilities capabilities = GL.createCapabilities();
|
||||
GL2.init(capabilities);
|
||||
gl = GL2.INSTANCE;
|
||||
awtContext.setSwapInterval(0);
|
||||
bindOutputFramebuffer();
|
||||
gl.glLineWidth((float) GameShell.canvasScale);
|
||||
enabled = true;
|
||||
canvasWidth = canvas.getSize().width;
|
||||
canvasHeight = canvas.getSize().height;
|
||||
result = checkContext();
|
||||
@Pc(36) int result = checkContext();
|
||||
if (result != 0) {
|
||||
quit();
|
||||
return result;
|
||||
|
|
@ -747,22 +713,12 @@ public final class GlRenderer {
|
|||
method4184();
|
||||
method4156();
|
||||
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
|
||||
swapBuffersAttempts = 0;
|
||||
while (true) {
|
||||
try {
|
||||
drawable.swapBuffers();
|
||||
break;
|
||||
} catch (@Pc(86) Exception ex) {
|
||||
if (swapBuffersAttempts++ > 5) {
|
||||
quit();
|
||||
return -3;
|
||||
}
|
||||
ThreadUtils.sleep(100L);
|
||||
}
|
||||
}
|
||||
awtContext.swapBuffers();
|
||||
bindOutputFramebuffer();
|
||||
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
|
||||
return 0;
|
||||
} catch (@Pc(103) Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
quit();
|
||||
return -5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
|
|||
|
|
@ -4689,7 +4689,8 @@ public final class ScriptRunner {
|
|||
continue;
|
||||
}
|
||||
if (opcode == Cs2Opcodes.getDisplayMode) {
|
||||
intStack[isp++] = DisplayMode.getWindowMode();
|
||||
int1 = DisplayMode.getWindowMode();
|
||||
intStack[isp++] = int1;
|
||||
continue;
|
||||
}
|
||||
if (opcode == 5307) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
import org.openrs2.deob.annotation.Pc;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import com.jogamp.opengl.GL2GL3;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
@ -80,7 +78,7 @@ public final class WaterMaterialRenderer implements MaterialRenderer {
|
|||
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_OPERAND0_RGB, GL2.GL_SRC_COLOR);
|
||||
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_SRC1_RGB, GL2.GL_CONSTANT);
|
||||
gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_RGB_SCALE, 2.0F);
|
||||
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2GL3.GL_SRC1_ALPHA, GL2.GL_CONSTANT);
|
||||
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_SRC1_ALPHA, GL2.GL_CONSTANT);
|
||||
gl.glTexGeni(GL2.GL_S, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR);
|
||||
gl.glTexGeni(GL2.GL_T, GL2.GL_TEXTURE_GEN_MODE, GL2.GL_OBJECT_LINEAR);
|
||||
gl.glTexGenfv(GL2.GL_S, GL2.GL_OBJECT_PLANE, new float[]{9.765625E-4F, 0.0F, 0.0F, 0.0F}, 0);
|
||||
|
|
@ -124,7 +122,7 @@ public final class WaterMaterialRenderer implements MaterialRenderer {
|
|||
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_OPERAND0_RGB, GL2.GL_SRC_COLOR);
|
||||
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_SRC1_RGB, GL2.GL_PREVIOUS);
|
||||
gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_RGB_SCALE, 1.0F);
|
||||
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2GL3.GL_SRC1_ALPHA, GL2.GL_PREVIOUS);
|
||||
gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_SRC1_ALPHA, GL2.GL_PREVIOUS);
|
||||
gl.glDisable(GL2.GL_TEXTURE_GEN_S);
|
||||
gl.glDisable(GL2.GL_TEXTURE_GEN_T);
|
||||
if (MaterialManager.allows3DTextureMapping) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import com.jogamp.opengl.util.GLReadBufferUtil;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue