mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2026-08-01 14:39:16 -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
11
README.md
11
README.md
|
|
@ -25,9 +25,16 @@ Build requirements:
|
|||
|
||||
Runtime requirements:
|
||||
* SD: Java 8+
|
||||
* HD on Windows, use Java 15 or lower. There is a JOGL issue on 16+ related to how they grab the WGL context from the window.
|
||||
* HD on Windows: Java 8+
|
||||
* HD on Linux: Java 8+
|
||||
* HD on macOS: Not possible yet on latest macOS. Might work for earlier OS versions.
|
||||
* HD on macOS: Java 8+, works natively on both Apple Silicon (arm64) and Intel.
|
||||
|
||||
HD rendering uses LWJGL 3 with a forked [rlawt](https://github.com/runelite/rlawt)
|
||||
(RuneLite's AWT-GL bridge) for windowing — see `rlawt/` for the fork and its build
|
||||
script. The JOGL-era caveats (no macOS support, Java 15 ceiling on Windows) no
|
||||
longer apply. Verified on macOS/Apple Silicon; the Windows/Linux paths use the
|
||||
same port with upstream rlawt natives but have not been runtime-tested since the
|
||||
switch from JOGL.
|
||||
|
||||
```
|
||||
git clone https://github.com/Pazaz/RT4-Client.git
|
||||
|
|
|
|||
|
|
@ -16,28 +16,28 @@ tasks.withType(JavaCompile) {
|
|||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
def lwjglVersion = '3.3.4'
|
||||
|
||||
dependencies {
|
||||
compileOnly project(':deob-annotations')
|
||||
implementation project(':signlink')
|
||||
|
||||
implementation 'lib:gson'
|
||||
implementation 'lib:gluegen-rt'
|
||||
implementation 'lib:gluegen-rt-natives-windows-amd64'
|
||||
implementation 'lib:gluegen-rt-natives-windows-i586'
|
||||
implementation 'lib:gluegen-rt-natives-linux-amd64'
|
||||
implementation 'lib:gluegen-rt-natives-linux-i586'
|
||||
implementation 'lib:gluegen-rt-natives-macosx-universal'
|
||||
implementation 'lib:gluegen-rt-natives-android-aarch64'
|
||||
implementation 'lib:gluegen-rt-natives-linux-aarch64'
|
||||
|
||||
implementation 'lib:jogl-all'
|
||||
implementation 'lib:jogl-all-natives-linux-aarch64'
|
||||
implementation 'lib:jogl-all-natives-windows-amd64'
|
||||
implementation 'lib:jogl-all-natives-windows-i586'
|
||||
implementation 'lib:jogl-all-natives-linux-amd64'
|
||||
implementation 'lib:jogl-all-natives-linux-i586'
|
||||
implementation 'lib:jogl-all-natives-macosx-universal'
|
||||
implementation 'lib:jogl-all-natives-android-aarch64'
|
||||
implementation "org.lwjgl:lwjgl:$lwjglVersion"
|
||||
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion"
|
||||
implementation "org.lwjgl:lwjgl:$lwjglVersion:natives-macos-arm64"
|
||||
implementation "org.lwjgl:lwjgl:$lwjglVersion:natives-macos"
|
||||
implementation "org.lwjgl:lwjgl:$lwjglVersion:natives-windows"
|
||||
implementation "org.lwjgl:lwjgl:$lwjglVersion:natives-windows-x86"
|
||||
implementation "org.lwjgl:lwjgl:$lwjglVersion:natives-linux"
|
||||
implementation "org.lwjgl:lwjgl:$lwjglVersion:natives-linux-arm64"
|
||||
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion:natives-macos-arm64"
|
||||
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion:natives-macos"
|
||||
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion:natives-windows"
|
||||
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion:natives-windows-x86"
|
||||
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion:natives-linux"
|
||||
implementation "org.lwjgl:lwjgl-opengl:$lwjglVersion:natives-linux-arm64"
|
||||
|
||||
runtime 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10'
|
||||
}
|
||||
|
|
|
|||
181
client/src/main/java/net/runelite/rlawt/AWTContext.java
Normal file
181
client/src/main/java/net/runelite/rlawt/AWTContext.java
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.rlawt;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Window;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Native;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
public final class AWTContext
|
||||
{
|
||||
private static boolean nativesLoaded = false;
|
||||
|
||||
@Native
|
||||
private long instance;
|
||||
|
||||
public synchronized static void loadNatives()
|
||||
{
|
||||
if (nativesLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// this needs to be in core since doing this in hub plugins will break core gpu
|
||||
System.loadLibrary("jawt");
|
||||
|
||||
String overridePath = System.getProperty("runelite.rlawtpath");
|
||||
if (overridePath != null)
|
||||
{
|
||||
System.load(overridePath);
|
||||
nativesLoaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
String os = System.getProperty("os.name", "no-os").toLowerCase();
|
||||
String arch = System.getProperty("os.arch", "no-arch");
|
||||
String name = "unknown";
|
||||
if (os.contains("mac") || os.contains("darwin"))
|
||||
{
|
||||
os = "macos";
|
||||
name = "librlawt.dylib";
|
||||
}
|
||||
else if (os.contains("win"))
|
||||
{
|
||||
os = "windows";
|
||||
name = "rlawt.dll";
|
||||
}
|
||||
else if (os.contains("nux"))
|
||||
{
|
||||
os = "linux";
|
||||
name = "librlawt.so";
|
||||
}
|
||||
|
||||
String path = os + "-" + arch + "/" + name;
|
||||
try (InputStream is = AWTContext.class.getResourceAsStream(path))
|
||||
{
|
||||
if (is == null)
|
||||
{
|
||||
throw new RuntimeException("rlawt does not exist at " + path);
|
||||
}
|
||||
|
||||
Path temp = Files.createTempFile("", name);
|
||||
temp.toFile().deleteOnExit();
|
||||
Files.copy(is, temp, StandardCopyOption.REPLACE_EXISTING);
|
||||
System.load(temp.toAbsolutePath().toString());
|
||||
nativesLoaded = true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static native long create0(Component component);
|
||||
|
||||
public AWTContext(Component component)
|
||||
{
|
||||
this.instance = create0(component);
|
||||
if (instance == 0)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
// JAWT on osx does not set our bounds when rlawt creates the CALayer
|
||||
// so we have to calculate it's offset from the superlayer until it is first
|
||||
// resized. We assume that the superlayer is the Window
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
for (Component c = component.getParent(); c != null; c = c.getParent())
|
||||
{
|
||||
if (c instanceof Window)
|
||||
{
|
||||
Insets insets = ((Window) c).getInsets();
|
||||
x -= insets.left;
|
||||
y -= insets.top;
|
||||
break;
|
||||
}
|
||||
|
||||
x += c.getX();
|
||||
y += c.getY();
|
||||
}
|
||||
configureInsets(x, y);
|
||||
}
|
||||
|
||||
public native void destroy();
|
||||
|
||||
private native void configureInsets(int x, int y);
|
||||
|
||||
public native void configurePixelFormat(int alpha, int depth, int stencil);
|
||||
|
||||
public native void configureMultisamples(int samples);
|
||||
|
||||
/**
|
||||
* Gets the name of the active front or back framebuffer object.
|
||||
*/
|
||||
public native int getFramebuffer(boolean front);
|
||||
|
||||
/**
|
||||
* Gets the framebuffer target name associated with {@link #getFramebuffer(boolean)}
|
||||
*/
|
||||
public int getBufferMode()
|
||||
{
|
||||
final int GL_FRONT = 0x404;
|
||||
final int GL_COLOR_ATTACHMENT0 = 0x8CE0;
|
||||
|
||||
return getFramebuffer(true) == 0 ? GL_FRONT : GL_COLOR_ATTACHMENT0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the configuration phase of the context, actually creating an OpenGL
|
||||
* context.
|
||||
*/
|
||||
public native void createGLContext();
|
||||
|
||||
public native int setSwapInterval(int interval);
|
||||
|
||||
public native void makeCurrent();
|
||||
|
||||
public native void detachCurrent();
|
||||
|
||||
/**
|
||||
* Presents the framebuffer to the user. After calling this you MUST bind
|
||||
* the current active framebuffer (see {@link #getFramebuffer(boolean)}) before drawing anything else
|
||||
*/
|
||||
public native void swapBuffers();
|
||||
|
||||
public native long getGLContext();
|
||||
|
||||
public native long getCGLShareGroup();
|
||||
|
||||
public native long getGLXDisplay();
|
||||
|
||||
public native long getWGLHDC();
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
BIN
client/src/main/resources/net/runelite/rlawt/macos-aarch64/librlawt.dylib
Executable file
BIN
client/src/main/resources/net/runelite/rlawt/macos-aarch64/librlawt.dylib
Executable file
Binary file not shown.
BIN
client/src/main/resources/net/runelite/rlawt/macos-x86_64/librlawt.dylib
Executable file
BIN
client/src/main/resources/net/runelite/rlawt/macos-x86_64/librlawt.dylib
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/jogl-all.jar
BIN
lib/jogl-all.jar
Binary file not shown.
|
|
@ -1,8 +1,5 @@
|
|||
package com.itspazaz.rt4;
|
||||
|
||||
import com.jogamp.opengl.GL2;
|
||||
import com.jogamp.opengl.GLContext;
|
||||
import com.jogamp.opengl.util.GLBuffers;
|
||||
import rt4.DisplayMode;
|
||||
import rt4.*;
|
||||
|
||||
|
|
@ -272,8 +269,9 @@ public class Playground extends GameShell {
|
|||
public static boolean useGl = false;
|
||||
|
||||
private void exportGlImage(String filename) {
|
||||
GL2 gl = GLContext.getCurrentGL().getGL2();
|
||||
ByteBuffer buffer = GLBuffers.newDirectByteBuffer(GameShell.canvasWidth * GameShell.canvasHeight * 4);
|
||||
GL2 gl = GlRenderer.gl;
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(GameShell.canvasWidth * GameShell.canvasHeight * 4)
|
||||
.order(java.nio.ByteOrder.nativeOrder());
|
||||
|
||||
gl.glReadBuffer(GL2.GL_BACK);
|
||||
gl.glReadPixels(0, 0, GameShell.canvasWidth, GameShell.canvasHeight, GL2.GL_BGRA, GL2.GL_UNSIGNED_BYTE, buffer);
|
||||
|
|
|
|||
1
rlawt/.gitignore
vendored
Normal file
1
rlawt/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
build/
|
||||
181
rlawt/AWTContext.java
Normal file
181
rlawt/AWTContext.java
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.rlawt;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Window;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Native;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
public final class AWTContext
|
||||
{
|
||||
private static boolean nativesLoaded = false;
|
||||
|
||||
@Native
|
||||
private long instance;
|
||||
|
||||
public synchronized static void loadNatives()
|
||||
{
|
||||
if (nativesLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// this needs to be in core since doing this in hub plugins will break core gpu
|
||||
System.loadLibrary("jawt");
|
||||
|
||||
String overridePath = System.getProperty("runelite.rlawtpath");
|
||||
if (overridePath != null)
|
||||
{
|
||||
System.load(overridePath);
|
||||
nativesLoaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
String os = System.getProperty("os.name", "no-os").toLowerCase();
|
||||
String arch = System.getProperty("os.arch", "no-arch");
|
||||
String name = "unknown";
|
||||
if (os.contains("mac") || os.contains("darwin"))
|
||||
{
|
||||
os = "macos";
|
||||
name = "librlawt.dylib";
|
||||
}
|
||||
else if (os.contains("win"))
|
||||
{
|
||||
os = "windows";
|
||||
name = "rlawt.dll";
|
||||
}
|
||||
else if (os.contains("nux"))
|
||||
{
|
||||
os = "linux";
|
||||
name = "librlawt.so";
|
||||
}
|
||||
|
||||
String path = os + "-" + arch + "/" + name;
|
||||
try (InputStream is = AWTContext.class.getResourceAsStream(path))
|
||||
{
|
||||
if (is == null)
|
||||
{
|
||||
throw new RuntimeException("rlawt does not exist at " + path);
|
||||
}
|
||||
|
||||
Path temp = Files.createTempFile("", name);
|
||||
temp.toFile().deleteOnExit();
|
||||
Files.copy(is, temp, StandardCopyOption.REPLACE_EXISTING);
|
||||
System.load(temp.toAbsolutePath().toString());
|
||||
nativesLoaded = true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static native long create0(Component component);
|
||||
|
||||
public AWTContext(Component component)
|
||||
{
|
||||
this.instance = create0(component);
|
||||
if (instance == 0)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
// JAWT on osx does not set our bounds when rlawt creates the CALayer
|
||||
// so we have to calculate it's offset from the superlayer until it is first
|
||||
// resized. We assume that the superlayer is the Window
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
for (Component c = component.getParent(); c != null; c = c.getParent())
|
||||
{
|
||||
if (c instanceof Window)
|
||||
{
|
||||
Insets insets = ((Window) c).getInsets();
|
||||
x -= insets.left;
|
||||
y -= insets.top;
|
||||
break;
|
||||
}
|
||||
|
||||
x += c.getX();
|
||||
y += c.getY();
|
||||
}
|
||||
configureInsets(x, y);
|
||||
}
|
||||
|
||||
public native void destroy();
|
||||
|
||||
private native void configureInsets(int x, int y);
|
||||
|
||||
public native void configurePixelFormat(int alpha, int depth, int stencil);
|
||||
|
||||
public native void configureMultisamples(int samples);
|
||||
|
||||
/**
|
||||
* Gets the name of the active front or back framebuffer object.
|
||||
*/
|
||||
public native int getFramebuffer(boolean front);
|
||||
|
||||
/**
|
||||
* Gets the framebuffer target name associated with {@link #getFramebuffer(boolean)}
|
||||
*/
|
||||
public int getBufferMode()
|
||||
{
|
||||
final int GL_FRONT = 0x404;
|
||||
final int GL_COLOR_ATTACHMENT0 = 0x8CE0;
|
||||
|
||||
return getFramebuffer(true) == 0 ? GL_FRONT : GL_COLOR_ATTACHMENT0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the configuration phase of the context, actually creating an OpenGL
|
||||
* context.
|
||||
*/
|
||||
public native void createGLContext();
|
||||
|
||||
public native int setSwapInterval(int interval);
|
||||
|
||||
public native void makeCurrent();
|
||||
|
||||
public native void detachCurrent();
|
||||
|
||||
/**
|
||||
* Presents the framebuffer to the user. After calling this you MUST bind
|
||||
* the current active framebuffer (see {@link #getFramebuffer(boolean)}) before drawing anything else
|
||||
*/
|
||||
public native void swapBuffers();
|
||||
|
||||
public native long getGLContext();
|
||||
|
||||
public native long getCGLShareGroup();
|
||||
|
||||
public native long getGLXDisplay();
|
||||
|
||||
public native long getWGLHDC();
|
||||
}
|
||||
43
rlawt/CMakeLists.txt
Normal file
43
rlawt/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
cmake_minimum_required(VERSION 3.15)
|
||||
project(rlawt C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
find_package(Java 1.8 REQUIRED)
|
||||
include(UseJava)
|
||||
set(CMAKE_FIND_FRAMEWORK NEVER) # does not find jni otherwise
|
||||
find_package(JNI REQUIRED)
|
||||
unset(CMAKE_FIND_FRAMEWORK)
|
||||
|
||||
set(CMAKE_SKIP_RPATH TRUE)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9")
|
||||
|
||||
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.8" "-target" "1.8")
|
||||
add_jar(jar AWTContext.java GENERATE_NATIVE_HEADERS rlawt-headers)
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(/W4)
|
||||
else()
|
||||
add_compile_options(-Wall)
|
||||
endif()
|
||||
|
||||
add_library(rlawt SHARED rlawt.c rlawt_nix.c rlawt_windows.c)
|
||||
|
||||
target_link_libraries(rlawt rlawt-headers ${JNI_LIBRARIES})
|
||||
|
||||
if (WIN32)
|
||||
include_directories(include/windows)
|
||||
set_property(TARGET rlawt PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") # multi-threaded statically-linked runtime
|
||||
target_link_libraries(rlawt opengl32)
|
||||
elseif (APPLE)
|
||||
target_sources(rlawt PRIVATE rlawt_mac.m)
|
||||
find_library(CORE_FOUNDATION CoreFoundation)
|
||||
find_library(QUARTZ_CORE QuartzCore)
|
||||
find_library(IO_SURFACE IOSurface)
|
||||
find_library(OPENGL OpenGL)
|
||||
find_library(APPKIT AppKit)
|
||||
set_property(SOURCE rlawt.c APPEND PROPERTY COMPILE_OPTIONS -x objective-c)
|
||||
target_link_libraries(rlawt ${CORE_FOUNDATION} ${QUARTZ_CORE} ${IO_SURFACE} ${OPENGL} ${APPKIT})
|
||||
elseif (UNIX)
|
||||
target_link_libraries(rlawt GL GLX)
|
||||
endif ()
|
||||
25
rlawt/LICENSE
Normal file
25
rlawt/LICENSE
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2022 Abex
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
47
rlawt/build-macos.sh
Executable file
47
rlawt/build-macos.sh
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
# Builds the forked librlawt.dylib (universal arm64 + x86_64) and installs it
|
||||
# into the client's resources so AWTContext.loadNatives() can find it.
|
||||
#
|
||||
# This is a fork of https://github.com/runelite/rlawt (BSD-2, see LICENSE):
|
||||
# - macOS requests the Legacy (2.1 compatibility) GL profile instead of GL4
|
||||
# core, because the client's HD renderer uses fixed-function GL + ARB
|
||||
# assembly programs.
|
||||
# - The IOSurface-backed framebuffers get a depth renderbuffer attachment
|
||||
# (the client needs a depth buffer; upstream RuneLite does not).
|
||||
#
|
||||
# Windows/Linux natives are taken unmodified from the upstream rlawt artifact:
|
||||
# their context creation already yields compatibility contexts (plain
|
||||
# wglCreateContext / GLX with default attribs), so no fork is needed there.
|
||||
#
|
||||
# Requires: Xcode command line tools, a JDK 11+ at JAVA_HOME (headers only).
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
: "${JAVA_HOME:=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home}"
|
||||
|
||||
BUILD=build
|
||||
RES=../client/src/main/resources/net/runelite/rlawt
|
||||
mkdir -p "$BUILD"
|
||||
|
||||
# JNI header (net_runelite_rlawt_AWTContext.h)
|
||||
"$JAVA_HOME/bin/javac" -h "$BUILD" -d "$BUILD/classes" AWTContext.java
|
||||
|
||||
# no -fobjc-arc: upstream rlawt uses manual retain/release
|
||||
CFLAGS="-O2 -Wall -x objective-c \
|
||||
-I$BUILD -I$JAVA_HOME/include -I$JAVA_HOME/include/darwin"
|
||||
LDFLAGS="-dynamiclib \
|
||||
-framework CoreFoundation -framework QuartzCore -framework IOSurface \
|
||||
-framework OpenGL -framework AppKit \
|
||||
-Wl,-undefined,dynamic_lookup"
|
||||
|
||||
# JAWT_GetAWT is resolved at runtime (System.loadLibrary("jawt") runs before
|
||||
# this library loads), hence -undefined dynamic_lookup.
|
||||
clang -arch arm64 -mmacosx-version-min=11.0 $CFLAGS $LDFLAGS rlawt.c rlawt_mac.m -o "$BUILD/librlawt-arm64.dylib"
|
||||
clang -arch x86_64 -mmacosx-version-min=10.13 $CFLAGS $LDFLAGS rlawt.c rlawt_mac.m -o "$BUILD/librlawt-x86_64.dylib"
|
||||
lipo -create "$BUILD/librlawt-arm64.dylib" "$BUILD/librlawt-x86_64.dylib" -output "$BUILD/librlawt.dylib"
|
||||
|
||||
mkdir -p "$RES/macos-aarch64" "$RES/macos-x86_64"
|
||||
cp "$BUILD/librlawt.dylib" "$RES/macos-aarch64/librlawt.dylib"
|
||||
cp "$BUILD/librlawt.dylib" "$RES/macos-x86_64/librlawt.dylib"
|
||||
echo "installed:"
|
||||
lipo -info "$RES/macos-aarch64/librlawt.dylib"
|
||||
14
rlawt/cmake/toolchain-linux-aarch64.cmake
Normal file
14
rlawt/cmake/toolchain-linux-aarch64.cmake
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
||||
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
|
||||
|
||||
# set(CMAKE_SYSROOT /usr/lib/jvm/java-1.11.0-openjdk-arm64)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
845
rlawt/include/windows/wglext.h
Normal file
845
rlawt/include/windows/wglext.h
Normal file
|
|
@ -0,0 +1,845 @@
|
|||
#ifndef __wgl_wglext_h_
|
||||
#define __wgl_wglext_h_ 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright 2013-2020 The Khronos Group Inc.
|
||||
** SPDX-License-Identifier: MIT
|
||||
**
|
||||
** This header is generated from the Khronos OpenGL / OpenGL ES XML
|
||||
** API Registry. The current version of the Registry, generator scripts
|
||||
** used to make the header, and the header can be found at
|
||||
** https://github.com/KhronosGroup/OpenGL-Registry
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#define WGL_WGLEXT_VERSION 20220530
|
||||
|
||||
/* Generated C header for:
|
||||
* API: wgl
|
||||
* Versions considered: .*
|
||||
* Versions emitted: _nomatch_^
|
||||
* Default extensions included: wgl
|
||||
* Additional extensions included: _nomatch_^
|
||||
* Extensions removed: _nomatch_^
|
||||
*/
|
||||
|
||||
#ifndef WGL_ARB_buffer_region
|
||||
#define WGL_ARB_buffer_region 1
|
||||
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
|
||||
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
|
||||
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
|
||||
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
|
||||
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
|
||||
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
|
||||
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
|
||||
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);
|
||||
VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);
|
||||
BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);
|
||||
BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
|
||||
#endif
|
||||
#endif /* WGL_ARB_buffer_region */
|
||||
|
||||
#ifndef WGL_ARB_context_flush_control
|
||||
#define WGL_ARB_context_flush_control 1
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
|
||||
#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
|
||||
#endif /* WGL_ARB_context_flush_control */
|
||||
|
||||
#ifndef WGL_ARB_create_context
|
||||
#define WGL_ARB_create_context 1
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);
|
||||
#endif
|
||||
#endif /* WGL_ARB_create_context */
|
||||
|
||||
#ifndef WGL_ARB_create_context_no_error
|
||||
#define WGL_ARB_create_context_no_error 1
|
||||
#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3
|
||||
#endif /* WGL_ARB_create_context_no_error */
|
||||
|
||||
#ifndef WGL_ARB_create_context_profile
|
||||
#define WGL_ARB_create_context_profile 1
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||
#endif /* WGL_ARB_create_context_profile */
|
||||
|
||||
#ifndef WGL_ARB_create_context_robustness
|
||||
#define WGL_ARB_create_context_robustness 1
|
||||
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
|
||||
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
|
||||
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
|
||||
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
|
||||
#endif /* WGL_ARB_create_context_robustness */
|
||||
|
||||
#ifndef WGL_ARB_extensions_string
|
||||
#define WGL_ARB_extensions_string 1
|
||||
typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
const char *WINAPI wglGetExtensionsStringARB (HDC hdc);
|
||||
#endif
|
||||
#endif /* WGL_ARB_extensions_string */
|
||||
|
||||
#ifndef WGL_ARB_framebuffer_sRGB
|
||||
#define WGL_ARB_framebuffer_sRGB 1
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
|
||||
#endif /* WGL_ARB_framebuffer_sRGB */
|
||||
|
||||
#ifndef WGL_ARB_make_current_read
|
||||
#define WGL_ARB_make_current_read 1
|
||||
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
|
||||
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
|
||||
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
HDC WINAPI wglGetCurrentReadDCARB (void);
|
||||
#endif
|
||||
#endif /* WGL_ARB_make_current_read */
|
||||
|
||||
#ifndef WGL_ARB_multisample
|
||||
#define WGL_ARB_multisample 1
|
||||
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
|
||||
#define WGL_SAMPLES_ARB 0x2042
|
||||
#endif /* WGL_ARB_multisample */
|
||||
|
||||
#ifndef WGL_ARB_pbuffer
|
||||
#define WGL_ARB_pbuffer 1
|
||||
DECLARE_HANDLE(HPBUFFERARB);
|
||||
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
|
||||
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
|
||||
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
|
||||
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
|
||||
#define WGL_PBUFFER_LARGEST_ARB 0x2033
|
||||
#define WGL_PBUFFER_WIDTH_ARB 0x2034
|
||||
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
|
||||
#define WGL_PBUFFER_LOST_ARB 0x2036
|
||||
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
|
||||
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);
|
||||
int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);
|
||||
BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);
|
||||
BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
|
||||
#endif
|
||||
#endif /* WGL_ARB_pbuffer */
|
||||
|
||||
#ifndef WGL_ARB_pixel_format
|
||||
#define WGL_ARB_pixel_format 1
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
||||
#define WGL_ACCELERATION_ARB 0x2003
|
||||
#define WGL_NEED_PALETTE_ARB 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
||||
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
||||
#define WGL_SWAP_METHOD_ARB 0x2007
|
||||
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
||||
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
||||
#define WGL_TRANSPARENT_ARB 0x200A
|
||||
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
||||
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
||||
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
||||
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
||||
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
||||
#define WGL_SHARE_DEPTH_ARB 0x200C
|
||||
#define WGL_SHARE_STENCIL_ARB 0x200D
|
||||
#define WGL_SHARE_ACCUM_ARB 0x200E
|
||||
#define WGL_SUPPORT_GDI_ARB 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||
#define WGL_STEREO_ARB 0x2012
|
||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||
#define WGL_COLOR_BITS_ARB 0x2014
|
||||
#define WGL_RED_BITS_ARB 0x2015
|
||||
#define WGL_RED_SHIFT_ARB 0x2016
|
||||
#define WGL_GREEN_BITS_ARB 0x2017
|
||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||
#define WGL_BLUE_BITS_ARB 0x2019
|
||||
#define WGL_BLUE_SHIFT_ARB 0x201A
|
||||
#define WGL_ALPHA_BITS_ARB 0x201B
|
||||
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
||||
#define WGL_ACCUM_BITS_ARB 0x201D
|
||||
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
||||
#define WGL_SWAP_COPY_ARB 0x2029
|
||||
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
||||
#define WGL_TYPE_RGBA_ARB 0x202B
|
||||
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
|
||||
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
||||
BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
|
||||
BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#endif
|
||||
#endif /* WGL_ARB_pixel_format */
|
||||
|
||||
#ifndef WGL_ARB_pixel_format_float
|
||||
#define WGL_ARB_pixel_format_float 1
|
||||
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
|
||||
#endif /* WGL_ARB_pixel_format_float */
|
||||
|
||||
#ifndef WGL_ARB_render_texture
|
||||
#define WGL_ARB_render_texture 1
|
||||
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
|
||||
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
|
||||
#define WGL_TEXTURE_FORMAT_ARB 0x2072
|
||||
#define WGL_TEXTURE_TARGET_ARB 0x2073
|
||||
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
|
||||
#define WGL_TEXTURE_RGB_ARB 0x2075
|
||||
#define WGL_TEXTURE_RGBA_ARB 0x2076
|
||||
#define WGL_NO_TEXTURE_ARB 0x2077
|
||||
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
|
||||
#define WGL_TEXTURE_1D_ARB 0x2079
|
||||
#define WGL_TEXTURE_2D_ARB 0x207A
|
||||
#define WGL_MIPMAP_LEVEL_ARB 0x207B
|
||||
#define WGL_CUBE_MAP_FACE_ARB 0x207C
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
|
||||
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
|
||||
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
|
||||
#define WGL_FRONT_LEFT_ARB 0x2083
|
||||
#define WGL_FRONT_RIGHT_ARB 0x2084
|
||||
#define WGL_BACK_LEFT_ARB 0x2085
|
||||
#define WGL_BACK_RIGHT_ARB 0x2086
|
||||
#define WGL_AUX0_ARB 0x2087
|
||||
#define WGL_AUX1_ARB 0x2088
|
||||
#define WGL_AUX2_ARB 0x2089
|
||||
#define WGL_AUX3_ARB 0x208A
|
||||
#define WGL_AUX4_ARB 0x208B
|
||||
#define WGL_AUX5_ARB 0x208C
|
||||
#define WGL_AUX6_ARB 0x208D
|
||||
#define WGL_AUX7_ARB 0x208E
|
||||
#define WGL_AUX8_ARB 0x208F
|
||||
#define WGL_AUX9_ARB 0x2090
|
||||
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);
|
||||
BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);
|
||||
#endif
|
||||
#endif /* WGL_ARB_render_texture */
|
||||
|
||||
#ifndef WGL_ARB_robustness_application_isolation
|
||||
#define WGL_ARB_robustness_application_isolation 1
|
||||
#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008
|
||||
#endif /* WGL_ARB_robustness_application_isolation */
|
||||
|
||||
#ifndef WGL_ARB_robustness_share_group_isolation
|
||||
#define WGL_ARB_robustness_share_group_isolation 1
|
||||
#endif /* WGL_ARB_robustness_share_group_isolation */
|
||||
|
||||
#ifndef WGL_3DFX_multisample
|
||||
#define WGL_3DFX_multisample 1
|
||||
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
|
||||
#define WGL_SAMPLES_3DFX 0x2061
|
||||
#endif /* WGL_3DFX_multisample */
|
||||
|
||||
#ifndef WGL_3DL_stereo_control
|
||||
#define WGL_3DL_stereo_control 1
|
||||
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
|
||||
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
|
||||
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
|
||||
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
|
||||
typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);
|
||||
#endif
|
||||
#endif /* WGL_3DL_stereo_control */
|
||||
|
||||
#ifndef WGL_AMD_gpu_association
|
||||
#define WGL_AMD_gpu_association 1
|
||||
#define WGL_GPU_VENDOR_AMD 0x1F00
|
||||
#define WGL_GPU_RENDERER_STRING_AMD 0x1F01
|
||||
#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02
|
||||
#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2
|
||||
#define WGL_GPU_RAM_AMD 0x21A3
|
||||
#define WGL_GPU_CLOCK_AMD 0x21A4
|
||||
#define WGL_GPU_NUM_PIPES_AMD 0x21A5
|
||||
#define WGL_GPU_NUM_SIMD_AMD 0x21A6
|
||||
#define WGL_GPU_NUM_RB_AMD 0x21A7
|
||||
#define WGL_GPU_NUM_SPI_AMD 0x21A8
|
||||
typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);
|
||||
typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void *data);
|
||||
typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);
|
||||
typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);
|
||||
typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);
|
||||
typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);
|
||||
typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
|
||||
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);
|
||||
INT WINAPI wglGetGPUInfoAMD (UINT id, INT property, GLenum dataType, UINT size, void *data);
|
||||
UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);
|
||||
HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);
|
||||
HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);
|
||||
BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);
|
||||
BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);
|
||||
HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);
|
||||
VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#endif
|
||||
#endif /* WGL_AMD_gpu_association */
|
||||
|
||||
#ifndef WGL_ATI_pixel_format_float
|
||||
#define WGL_ATI_pixel_format_float 1
|
||||
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
|
||||
#endif /* WGL_ATI_pixel_format_float */
|
||||
|
||||
#ifndef WGL_ATI_render_texture_rectangle
|
||||
#define WGL_ATI_render_texture_rectangle 1
|
||||
#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5
|
||||
#endif /* WGL_ATI_render_texture_rectangle */
|
||||
|
||||
#ifndef WGL_EXT_colorspace
|
||||
#define WGL_EXT_colorspace 1
|
||||
#define WGL_COLORSPACE_EXT 0x309D
|
||||
#define WGL_COLORSPACE_SRGB_EXT 0x3089
|
||||
#define WGL_COLORSPACE_LINEAR_EXT 0x308A
|
||||
#endif /* WGL_EXT_colorspace */
|
||||
|
||||
#ifndef WGL_EXT_create_context_es2_profile
|
||||
#define WGL_EXT_create_context_es2_profile 1
|
||||
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
|
||||
#endif /* WGL_EXT_create_context_es2_profile */
|
||||
|
||||
#ifndef WGL_EXT_create_context_es_profile
|
||||
#define WGL_EXT_create_context_es_profile 1
|
||||
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
|
||||
#endif /* WGL_EXT_create_context_es_profile */
|
||||
|
||||
#ifndef WGL_EXT_depth_float
|
||||
#define WGL_EXT_depth_float 1
|
||||
#define WGL_DEPTH_FLOAT_EXT 0x2040
|
||||
#endif /* WGL_EXT_depth_float */
|
||||
|
||||
#ifndef WGL_EXT_display_color_table
|
||||
#define WGL_EXT_display_color_table 1
|
||||
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
|
||||
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);
|
||||
GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);
|
||||
GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);
|
||||
VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);
|
||||
#endif
|
||||
#endif /* WGL_EXT_display_color_table */
|
||||
|
||||
#ifndef WGL_EXT_extensions_string
|
||||
#define WGL_EXT_extensions_string 1
|
||||
typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
const char *WINAPI wglGetExtensionsStringEXT (void);
|
||||
#endif
|
||||
#endif /* WGL_EXT_extensions_string */
|
||||
|
||||
#ifndef WGL_EXT_framebuffer_sRGB
|
||||
#define WGL_EXT_framebuffer_sRGB 1
|
||||
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
|
||||
#endif /* WGL_EXT_framebuffer_sRGB */
|
||||
|
||||
#ifndef WGL_EXT_make_current_read
|
||||
#define WGL_EXT_make_current_read 1
|
||||
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
|
||||
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
|
||||
HDC WINAPI wglGetCurrentReadDCEXT (void);
|
||||
#endif
|
||||
#endif /* WGL_EXT_make_current_read */
|
||||
|
||||
#ifndef WGL_EXT_multisample
|
||||
#define WGL_EXT_multisample 1
|
||||
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
|
||||
#define WGL_SAMPLES_EXT 0x2042
|
||||
#endif /* WGL_EXT_multisample */
|
||||
|
||||
#ifndef WGL_EXT_pbuffer
|
||||
#define WGL_EXT_pbuffer 1
|
||||
DECLARE_HANDLE(HPBUFFEREXT);
|
||||
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
|
||||
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
|
||||
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
|
||||
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
|
||||
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
|
||||
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
|
||||
#define WGL_PBUFFER_LARGEST_EXT 0x2033
|
||||
#define WGL_PBUFFER_WIDTH_EXT 0x2034
|
||||
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
|
||||
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
|
||||
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
|
||||
HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);
|
||||
int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);
|
||||
BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);
|
||||
BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
|
||||
#endif
|
||||
#endif /* WGL_EXT_pbuffer */
|
||||
|
||||
#ifndef WGL_EXT_pixel_format
|
||||
#define WGL_EXT_pixel_format 1
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
|
||||
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
|
||||
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
|
||||
#define WGL_ACCELERATION_EXT 0x2003
|
||||
#define WGL_NEED_PALETTE_EXT 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
|
||||
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
|
||||
#define WGL_SWAP_METHOD_EXT 0x2007
|
||||
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
|
||||
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
|
||||
#define WGL_TRANSPARENT_EXT 0x200A
|
||||
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
|
||||
#define WGL_SHARE_DEPTH_EXT 0x200C
|
||||
#define WGL_SHARE_STENCIL_EXT 0x200D
|
||||
#define WGL_SHARE_ACCUM_EXT 0x200E
|
||||
#define WGL_SUPPORT_GDI_EXT 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_EXT 0x2010
|
||||
#define WGL_DOUBLE_BUFFER_EXT 0x2011
|
||||
#define WGL_STEREO_EXT 0x2012
|
||||
#define WGL_PIXEL_TYPE_EXT 0x2013
|
||||
#define WGL_COLOR_BITS_EXT 0x2014
|
||||
#define WGL_RED_BITS_EXT 0x2015
|
||||
#define WGL_RED_SHIFT_EXT 0x2016
|
||||
#define WGL_GREEN_BITS_EXT 0x2017
|
||||
#define WGL_GREEN_SHIFT_EXT 0x2018
|
||||
#define WGL_BLUE_BITS_EXT 0x2019
|
||||
#define WGL_BLUE_SHIFT_EXT 0x201A
|
||||
#define WGL_ALPHA_BITS_EXT 0x201B
|
||||
#define WGL_ALPHA_SHIFT_EXT 0x201C
|
||||
#define WGL_ACCUM_BITS_EXT 0x201D
|
||||
#define WGL_ACCUM_RED_BITS_EXT 0x201E
|
||||
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
|
||||
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
|
||||
#define WGL_DEPTH_BITS_EXT 0x2022
|
||||
#define WGL_STENCIL_BITS_EXT 0x2023
|
||||
#define WGL_AUX_BUFFERS_EXT 0x2024
|
||||
#define WGL_NO_ACCELERATION_EXT 0x2025
|
||||
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
|
||||
#define WGL_FULL_ACCELERATION_EXT 0x2027
|
||||
#define WGL_SWAP_EXCHANGE_EXT 0x2028
|
||||
#define WGL_SWAP_COPY_EXT 0x2029
|
||||
#define WGL_SWAP_UNDEFINED_EXT 0x202A
|
||||
#define WGL_TYPE_RGBA_EXT 0x202B
|
||||
#define WGL_TYPE_COLORINDEX_EXT 0x202C
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
|
||||
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
|
||||
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
|
||||
BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
|
||||
BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
|
||||
#endif
|
||||
#endif /* WGL_EXT_pixel_format */
|
||||
|
||||
#ifndef WGL_EXT_pixel_format_packed_float
|
||||
#define WGL_EXT_pixel_format_packed_float 1
|
||||
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
|
||||
#endif /* WGL_EXT_pixel_format_packed_float */
|
||||
|
||||
#ifndef WGL_EXT_swap_control
|
||||
#define WGL_EXT_swap_control 1
|
||||
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
|
||||
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglSwapIntervalEXT (int interval);
|
||||
int WINAPI wglGetSwapIntervalEXT (void);
|
||||
#endif
|
||||
#endif /* WGL_EXT_swap_control */
|
||||
|
||||
#ifndef WGL_EXT_swap_control_tear
|
||||
#define WGL_EXT_swap_control_tear 1
|
||||
#endif /* WGL_EXT_swap_control_tear */
|
||||
|
||||
#ifndef WGL_I3D_digital_video_control
|
||||
#define WGL_I3D_digital_video_control 1
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
|
||||
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
|
||||
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
|
||||
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);
|
||||
BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);
|
||||
#endif
|
||||
#endif /* WGL_I3D_digital_video_control */
|
||||
|
||||
#ifndef WGL_I3D_gamma
|
||||
#define WGL_I3D_gamma 1
|
||||
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
|
||||
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
|
||||
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
|
||||
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);
|
||||
BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);
|
||||
BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
|
||||
BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
|
||||
#endif
|
||||
#endif /* WGL_I3D_gamma */
|
||||
|
||||
#ifndef WGL_I3D_genlock
|
||||
#define WGL_I3D_genlock 1
|
||||
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
|
||||
#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045
|
||||
#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046
|
||||
#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047
|
||||
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
|
||||
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
|
||||
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
|
||||
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
|
||||
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
|
||||
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
|
||||
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglEnableGenlockI3D (HDC hDC);
|
||||
BOOL WINAPI wglDisableGenlockI3D (HDC hDC);
|
||||
BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);
|
||||
BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);
|
||||
BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);
|
||||
BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);
|
||||
BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);
|
||||
BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);
|
||||
BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);
|
||||
BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);
|
||||
BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);
|
||||
BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
|
||||
#endif
|
||||
#endif /* WGL_I3D_genlock */
|
||||
|
||||
#ifndef WGL_I3D_image_buffer
|
||||
#define WGL_I3D_image_buffer 1
|
||||
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
|
||||
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
|
||||
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
|
||||
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
|
||||
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);
|
||||
BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);
|
||||
BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
|
||||
BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);
|
||||
#endif
|
||||
#endif /* WGL_I3D_image_buffer */
|
||||
|
||||
#ifndef WGL_I3D_swap_frame_lock
|
||||
#define WGL_I3D_swap_frame_lock 1
|
||||
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglEnableFrameLockI3D (void);
|
||||
BOOL WINAPI wglDisableFrameLockI3D (void);
|
||||
BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);
|
||||
BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);
|
||||
#endif
|
||||
#endif /* WGL_I3D_swap_frame_lock */
|
||||
|
||||
#ifndef WGL_I3D_swap_frame_usage
|
||||
#define WGL_I3D_swap_frame_usage 1
|
||||
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
|
||||
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetFrameUsageI3D (float *pUsage);
|
||||
BOOL WINAPI wglBeginFrameTrackingI3D (void);
|
||||
BOOL WINAPI wglEndFrameTrackingI3D (void);
|
||||
BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
|
||||
#endif
|
||||
#endif /* WGL_I3D_swap_frame_usage */
|
||||
|
||||
#ifndef WGL_NV_DX_interop
|
||||
#define WGL_NV_DX_interop 1
|
||||
#define WGL_ACCESS_READ_ONLY_NV 0x00000000
|
||||
#define WGL_ACCESS_READ_WRITE_NV 0x00000001
|
||||
#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002
|
||||
typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);
|
||||
typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);
|
||||
typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
|
||||
typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);
|
||||
typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);
|
||||
typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);
|
||||
HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);
|
||||
BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);
|
||||
HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
|
||||
BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);
|
||||
BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);
|
||||
BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);
|
||||
#endif
|
||||
#endif /* WGL_NV_DX_interop */
|
||||
|
||||
#ifndef WGL_NV_DX_interop2
|
||||
#define WGL_NV_DX_interop2 1
|
||||
#endif /* WGL_NV_DX_interop2 */
|
||||
|
||||
#ifndef WGL_NV_copy_image
|
||||
#define WGL_NV_copy_image 1
|
||||
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#endif
|
||||
#endif /* WGL_NV_copy_image */
|
||||
|
||||
#ifndef WGL_NV_delay_before_swap
|
||||
#define WGL_NV_delay_before_swap 1
|
||||
typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds);
|
||||
#endif
|
||||
#endif /* WGL_NV_delay_before_swap */
|
||||
|
||||
#ifndef WGL_NV_float_buffer
|
||||
#define WGL_NV_float_buffer 1
|
||||
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
|
||||
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
|
||||
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
|
||||
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
|
||||
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
|
||||
#endif /* WGL_NV_float_buffer */
|
||||
|
||||
#ifndef WGL_NV_gpu_affinity
|
||||
#define WGL_NV_gpu_affinity 1
|
||||
DECLARE_HANDLE(HGPUNV);
|
||||
struct _GPU_DEVICE {
|
||||
DWORD cb;
|
||||
CHAR DeviceName[32];
|
||||
CHAR DeviceString[128];
|
||||
DWORD Flags;
|
||||
RECT rcVirtualScreen;
|
||||
};
|
||||
typedef struct _GPU_DEVICE *PGPU_DEVICE;
|
||||
#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0
|
||||
#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
|
||||
typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);
|
||||
typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
|
||||
typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);
|
||||
BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);
|
||||
HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);
|
||||
BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);
|
||||
BOOL WINAPI wglDeleteDCNV (HDC hdc);
|
||||
#endif
|
||||
#endif /* WGL_NV_gpu_affinity */
|
||||
|
||||
#ifndef WGL_NV_multigpu_context
|
||||
#define WGL_NV_multigpu_context 1
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_NV 0x20AA
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_SINGLE_NV 0x20AB
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_AFR_NV 0x20AC
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTICAST_NV 0x20AD
|
||||
#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTI_DISPLAY_MULTICAST_NV 0x20AE
|
||||
#endif /* WGL_NV_multigpu_context */
|
||||
|
||||
#ifndef WGL_NV_multisample_coverage
|
||||
#define WGL_NV_multisample_coverage 1
|
||||
#define WGL_COVERAGE_SAMPLES_NV 0x2042
|
||||
#define WGL_COLOR_SAMPLES_NV 0x20B9
|
||||
#endif /* WGL_NV_multisample_coverage */
|
||||
|
||||
#ifndef WGL_NV_present_video
|
||||
#define WGL_NV_present_video 1
|
||||
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
|
||||
#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0
|
||||
typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
int WINAPI wglEnumerateVideoDevicesNV (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList);
|
||||
BOOL WINAPI wglBindVideoDeviceNV (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);
|
||||
BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);
|
||||
#endif
|
||||
#endif /* WGL_NV_present_video */
|
||||
|
||||
#ifndef WGL_NV_render_depth_texture
|
||||
#define WGL_NV_render_depth_texture 1
|
||||
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
|
||||
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
|
||||
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
|
||||
#define WGL_DEPTH_COMPONENT_NV 0x20A7
|
||||
#endif /* WGL_NV_render_depth_texture */
|
||||
|
||||
#ifndef WGL_NV_render_texture_rectangle
|
||||
#define WGL_NV_render_texture_rectangle 1
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
|
||||
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
|
||||
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
|
||||
#endif /* WGL_NV_render_texture_rectangle */
|
||||
|
||||
#ifndef WGL_NV_swap_group
|
||||
#define WGL_NV_swap_group 1
|
||||
typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);
|
||||
typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);
|
||||
BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);
|
||||
BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);
|
||||
BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);
|
||||
BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);
|
||||
BOOL WINAPI wglResetFrameCountNV (HDC hDC);
|
||||
#endif
|
||||
#endif /* WGL_NV_swap_group */
|
||||
|
||||
#ifndef WGL_NV_vertex_array_range
|
||||
#define WGL_NV_vertex_array_range 1
|
||||
typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
|
||||
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
|
||||
void WINAPI wglFreeMemoryNV (void *pointer);
|
||||
#endif
|
||||
#endif /* WGL_NV_vertex_array_range */
|
||||
|
||||
#ifndef WGL_NV_video_capture
|
||||
#define WGL_NV_video_capture 1
|
||||
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
|
||||
#define WGL_UNIQUE_ID_NV 0x20CE
|
||||
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
|
||||
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
|
||||
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
|
||||
UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
|
||||
BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
|
||||
BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
#endif
|
||||
#endif /* WGL_NV_video_capture */
|
||||
|
||||
#ifndef WGL_NV_video_output
|
||||
#define WGL_NV_video_output 1
|
||||
DECLARE_HANDLE(HPVIDEODEV);
|
||||
#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0
|
||||
#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1
|
||||
#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2
|
||||
#define WGL_VIDEO_OUT_COLOR_NV 0x20C3
|
||||
#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4
|
||||
#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5
|
||||
#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6
|
||||
#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7
|
||||
#define WGL_VIDEO_OUT_FRAME 0x20C8
|
||||
#define WGL_VIDEO_OUT_FIELD_1 0x20C9
|
||||
#define WGL_VIDEO_OUT_FIELD_2 0x20CA
|
||||
#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB
|
||||
#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC
|
||||
typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
|
||||
typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);
|
||||
BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);
|
||||
BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);
|
||||
BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);
|
||||
BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||
#endif
|
||||
#endif /* WGL_NV_video_output */
|
||||
|
||||
#ifndef WGL_OML_sync_control
|
||||
#define WGL_OML_sync_control 1
|
||||
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
|
||||
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);
|
||||
INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
|
||||
BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
|
||||
#endif
|
||||
#endif /* WGL_OML_sync_control */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
203
rlawt/rlawt.c
Normal file
203
rlawt/rlawt.c
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "rlawt.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static jfieldID AWTContext_instance = 0;
|
||||
AWTContext *rlawtGetContext(JNIEnv *env, jobject self) {
|
||||
if (!AWTContext_instance) {
|
||||
jclass clazz = (*env)->GetObjectClass(env, self);
|
||||
AWTContext_instance = (*env)->GetFieldID(env, clazz, "instance", "J");
|
||||
if (!AWTContext_instance) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
jlong ins = (*env)->GetLongField(env, self, AWTContext_instance);
|
||||
if (!ins) {
|
||||
jclass clazz = (*env)->FindClass(env, "java/lang/NullPointerException");
|
||||
(*env)->ThrowNew(env, clazz, "no instance");
|
||||
}
|
||||
return (AWTContext*) ins;
|
||||
}
|
||||
|
||||
bool rlawtContextState(JNIEnv *env, AWTContext *context, bool created) {
|
||||
if (context->contextCreated != created) {
|
||||
rlawtThrow(env, created ? "context must be already created" : "context cannot be created");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void rlawtUnlockAWT(JNIEnv *env, AWTContext *ctx) {
|
||||
jthrowable exception = (*env)->ExceptionOccurred(env);
|
||||
ctx->awt.Unlock(env);
|
||||
if (exception) {
|
||||
(*env)->Throw(env, exception);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_runelite_rlawt_AWTContext_create0(JNIEnv *env, jclass _self, jobject component) {
|
||||
AWTContext *ctx = calloc(1, sizeof(AWTContext));
|
||||
|
||||
#ifdef __APPLE__
|
||||
ctx->awt.version = JAWT_VERSION_1_7;
|
||||
#else
|
||||
// java < 9 on Windows does not support jawt 1_7
|
||||
ctx->awt.version = JAWT_VERSION_1_4;
|
||||
#endif
|
||||
if (!JAWT_GetAWT(env, &ctx->awt)) {
|
||||
rlawtThrow(env, "cannot get the awt");
|
||||
goto free_ctx;
|
||||
}
|
||||
|
||||
ctx->awt.Lock(env);
|
||||
ctx->ds = ctx->awt.GetDrawingSurface(env, component);
|
||||
if (!ctx->ds) {
|
||||
rlawtThrow(env, "cannot get the ds");
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
ctx->awt.Unlock(env);
|
||||
|
||||
return (jlong) ctx;
|
||||
|
||||
unlock:
|
||||
ctx->awt.Unlock(env);
|
||||
free_ctx:
|
||||
free(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_destroy(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
(*env)->SetLongField(env, self, AWTContext_instance, 0);
|
||||
|
||||
rlawtContextFreePlatform(env, ctx);
|
||||
if (ctx->ds) {
|
||||
ctx->awt.FreeDrawingSurface(ctx->ds);
|
||||
}
|
||||
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_configureInsets(JNIEnv *env, jobject self, jint x, jint y) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
ctx->offsetX = x;
|
||||
ctx->offsetY = y;
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_configurePixelFormat(JNIEnv *env, jobject self, jint alpha, jint depth, jint stencil) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->alphaDepth = alpha;
|
||||
ctx->depthDepth = depth;
|
||||
ctx->stencilDepth = stencil;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_configureMultisamples(JNIEnv *env, jobject self, jint samples) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->multisamples = samples;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_runelite_rlawt_AWTContext_getGLContext(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (jlong) ctx->context;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_runelite_rlawt_AWTContext_getCGLShareGroup(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
return (jlong) CGLGetShareGroup(ctx->context);
|
||||
#else
|
||||
rlawtThrow(env, "not supported");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_runelite_rlawt_AWTContext_getGLXDisplay(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __unix__
|
||||
return (jlong) ctx->dpy;
|
||||
#else
|
||||
rlawtThrow(env, "not supported");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_net_runelite_rlawt_AWTContext_getWGLHDC(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
return (jlong) ctx->dspi->hdc;
|
||||
#else
|
||||
rlawtThrow(env, "not supported");
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
JNIEXPORT jint JNICALL Java_net_runelite_rlawt_AWTContext_getFramebuffer(JNIEnv *env, jobject self, jboolean front) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
126
rlawt/rlawt.h
Normal file
126
rlawt/rlawt.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "net_runelite_rlawt_AWTContext.h"
|
||||
#include <jawt.h>
|
||||
#include <jawt_md.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define GL_SILENCE_DEPRECATION
|
||||
# include <IOSurface/IOSurface.h>
|
||||
# include <QuartzCore/CALayer.h>
|
||||
# include <OpenGL/OpenGL.h>
|
||||
#endif
|
||||
|
||||
#ifdef __unix__
|
||||
# include <X11/Xlib.h>
|
||||
# include <GL/glx.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# include <GL/gl.h>
|
||||
# include <wglext.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define RLAWT_MAX_POOL 8
|
||||
|
||||
typedef struct {
|
||||
IOSurfaceRef surface;
|
||||
CGFloat scale;
|
||||
GLuint tex;
|
||||
GLuint fbo;
|
||||
GLuint depthRb;
|
||||
} IOSurfaceEntry;
|
||||
|
||||
typedef struct {
|
||||
IOSurfaceEntry entries[RLAWT_MAX_POOL];
|
||||
int count; // entries currently allocated (0..RLAWT_MAX_POOL)
|
||||
int back; // current render target index
|
||||
int front; // most recently presented surface index
|
||||
|
||||
#ifdef RLAWT_POOL_DEBUG
|
||||
struct {
|
||||
int swaps;
|
||||
int allocs;
|
||||
int reuses;
|
||||
int grows;
|
||||
int stalls;
|
||||
int failures;
|
||||
int highWater;
|
||||
} stats;
|
||||
CFAbsoluteTime lastLogTime;
|
||||
#endif
|
||||
} IOSurfacePool;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
JAWT awt;
|
||||
JAWT_DrawingSurface *ds;
|
||||
bool contextCreated;
|
||||
|
||||
#ifdef __APPLE__
|
||||
CALayer *layer;
|
||||
CGLContextObj context;
|
||||
IOSurfacePool pool;
|
||||
|
||||
int offsetX;
|
||||
int offsetY;
|
||||
#endif
|
||||
|
||||
#ifdef __unix__
|
||||
Display *dpy;
|
||||
Drawable drawable;
|
||||
GLXContext context;
|
||||
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
|
||||
bool glxSwapControlTear;
|
||||
PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
|
||||
bool doubleBuffered;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
JAWT_DrawingSurfaceInfo *dsi;
|
||||
JAWT_Win32DrawingSurfaceInfo *dspi;
|
||||
HGLRC context;
|
||||
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
|
||||
bool wglSwapControlTear;
|
||||
#endif
|
||||
|
||||
int alphaDepth;
|
||||
int depthDepth;
|
||||
int stencilDepth;
|
||||
|
||||
int multisamples;
|
||||
} AWTContext;
|
||||
|
||||
void rlawtThrow(JNIEnv *env, const char *msg);
|
||||
void rlawtUnlockAWT(JNIEnv *env, AWTContext *ctx);
|
||||
AWTContext *rlawtGetContext(JNIEnv *env, jobject self);
|
||||
bool rlawtContextState(JNIEnv *env, AWTContext *context, bool created);
|
||||
|
||||
|
||||
void rlawtContextFreePlatform(JNIEnv *env, AWTContext *ctx);
|
||||
457
rlawt/rlawt_mac.m
Normal file
457
rlawt/rlawt_mac.m
Normal file
|
|
@ -0,0 +1,457 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include "rlawt.h"
|
||||
#include <jawt_md.h>
|
||||
#include <OpenGL/gl3.h>
|
||||
#include <QuartzCore/QuartzCore.h>
|
||||
|
||||
@protocol CanSetContentsChanged
|
||||
-(void)setContentsChanged;
|
||||
@end
|
||||
|
||||
@interface RLLayer : CALayer {
|
||||
@public int offsetY;
|
||||
CGFloat newScale;
|
||||
}
|
||||
- (void)setFrame:(CGRect)newValue;
|
||||
- (void)fixFrame;
|
||||
- (void)displayIOSurface:(id)ioSurface;
|
||||
@end
|
||||
|
||||
@implementation RLLayer
|
||||
- (void)setFrame:(CGRect)newValue {
|
||||
[super setFrame: newValue];
|
||||
|
||||
if (self.superlayer) {
|
||||
offsetY = self.superlayer.frame.size.height - newValue.origin.y - newValue.size.height;
|
||||
}
|
||||
}
|
||||
|
||||
// JAWT does not update our bounds when the y offset from the bottom of our
|
||||
// superlayer changes, causing the layer to become displaced from the correct
|
||||
// vertical position
|
||||
- (void)fixFrame {
|
||||
if (!self.superlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.frame = CGRectMake(
|
||||
self.frame.origin.x,
|
||||
self.superlayer.frame.size.height - offsetY - self.frame.size.height,
|
||||
self.frame.size.width,
|
||||
self.frame.size.height);
|
||||
}
|
||||
|
||||
- (void)displayIOSurface:(id)ioSurface {
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions: true];
|
||||
self.contentsScale = self->newScale;
|
||||
self.contents = ioSurface;
|
||||
[(id<CanSetContentsChanged>)self setContentsChanged];
|
||||
[self fixFrame];
|
||||
[CATransaction commit];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
void rlawtThrow(JNIEnv *env, const char *msg) {
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
return;
|
||||
}
|
||||
jclass clazz = (*env)->FindClass(env, "java/lang/RuntimeException");
|
||||
(*env)->ThrowNew(env, clazz, msg);
|
||||
}
|
||||
|
||||
static void rlawtThrowCGLError(JNIEnv *env, const char *msg, CGLError err) {
|
||||
char buf[256] = {0};
|
||||
snprintf(buf, sizeof(buf), "%s (cgl: %s)", msg, CGLErrorString(err));
|
||||
rlawtThrow(env, buf);
|
||||
}
|
||||
|
||||
static bool makeCurrent(JNIEnv *env, CGLContextObj ctx) {
|
||||
CGLError err = CGLSetCurrentContext(ctx);
|
||||
if (err != kCGLNoError) {
|
||||
rlawtThrowCGLError(env, "unable to make current", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void propsPutInt(CFMutableDictionaryRef props, const CFStringRef key, int value) {
|
||||
CFNumberRef boxedValue = CFNumberCreate(NULL, kCFNumberIntType, &value);
|
||||
CFDictionaryAddValue(props, key, boxedValue);
|
||||
CFRelease(boxedValue);
|
||||
}
|
||||
|
||||
// -- IOSurfacePool helpers --
|
||||
|
||||
#ifdef RLAWT_POOL_DEBUG
|
||||
#define POOL_STAT(pool, field) ((pool)->stats.field++)
|
||||
#else
|
||||
#define POOL_STAT(pool, field) ((void)0)
|
||||
#endif
|
||||
|
||||
static void poolInit(IOSurfacePool *pool) {
|
||||
memset(pool, 0, sizeof(*pool));
|
||||
GLuint textures[RLAWT_MAX_POOL], framebuffers[RLAWT_MAX_POOL], depthRbs[RLAWT_MAX_POOL];
|
||||
glGenTextures(RLAWT_MAX_POOL, textures);
|
||||
glGenFramebuffers(RLAWT_MAX_POOL, framebuffers);
|
||||
glGenRenderbuffers(RLAWT_MAX_POOL, depthRbs);
|
||||
for (int i = 0; i < RLAWT_MAX_POOL; i++) {
|
||||
pool->entries[i].tex = textures[i];
|
||||
pool->entries[i].fbo = framebuffers[i];
|
||||
pool->entries[i].depthRb = depthRbs[i];
|
||||
}
|
||||
#ifdef RLAWT_POOL_DEBUG
|
||||
pool->lastLogTime = CFAbsoluteTimeGetCurrent();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void poolDestroy(IOSurfacePool *pool) {
|
||||
for (int i = 0; i < RLAWT_MAX_POOL; i++) {
|
||||
glDeleteTextures(1, &pool->entries[i].tex);
|
||||
glDeleteFramebuffers(1, &pool->entries[i].fbo);
|
||||
glDeleteRenderbuffers(1, &pool->entries[i].depthRb);
|
||||
if (pool->entries[i].surface) {
|
||||
CFRelease(pool->entries[i].surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool poolEntryMatchesSize(IOSurfaceEntry *entry, CALayer *layer) {
|
||||
if (!entry->surface) return false;
|
||||
CGFloat scale = entry->scale;
|
||||
CGSize size = layer.frame.size;
|
||||
return IOSurfaceGetWidth(entry->surface) == (size_t)(size.width * scale)
|
||||
&& IOSurfaceGetHeight(entry->surface) == (size_t)(size.height * scale)
|
||||
&& layer.superlayer.contentsScale == scale;
|
||||
}
|
||||
|
||||
static bool poolCreateSurface(JNIEnv *env, IOSurfaceEntry *entry, CALayer *layer, AWTContext *ctx) {
|
||||
CGLContextObj cglCtx = ctx->context;
|
||||
CGFloat scale = layer.superlayer.contentsScale;
|
||||
CGSize size = layer.frame.size;
|
||||
size.width *= scale;
|
||||
size.height *= scale;
|
||||
|
||||
CFMutableDictionaryRef props = CFDictionaryCreateMutable(NULL, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
propsPutInt(props, kIOSurfaceHeight, size.height);
|
||||
propsPutInt(props, kIOSurfaceWidth, size.width);
|
||||
propsPutInt(props, kIOSurfaceBytesPerElement, 4);
|
||||
propsPutInt(props, kIOSurfacePixelFormat, (int)'BGRA');
|
||||
|
||||
IOSurfaceRef buf = IOSurfaceCreate(props);
|
||||
CFRelease(props);
|
||||
if (!buf) {
|
||||
rlawtThrow(env, "unable to create io surface");
|
||||
return false;
|
||||
}
|
||||
|
||||
const GLuint target = GL_TEXTURE_RECTANGLE;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(target, entry->tex);
|
||||
CGLError err = CGLTexImageIOSurface2D(
|
||||
cglCtx,
|
||||
target, GL_RGBA,
|
||||
size.width, size.height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
buf,
|
||||
0);
|
||||
glBindTexture(target, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, entry->fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, entry->tex, 0);
|
||||
|
||||
// The IOSurface FBO is the only render target this context ever draws to,
|
||||
// so it needs its own depth buffer when the caller asked for one via
|
||||
// configurePixelFormat (kCGLPFADepthSize only affects the never-used
|
||||
// default framebuffer).
|
||||
if (ctx->depthDepth > 0) {
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, entry->depthRb);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, size.width, size.height);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, entry->depthRb);
|
||||
}
|
||||
|
||||
if (err != kCGLNoError) {
|
||||
rlawtThrowCGLError(env, "unable to bind io surface to texture", err);
|
||||
goto freeSurface;
|
||||
}
|
||||
|
||||
int fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (fbStatus != GL_FRAMEBUFFER_COMPLETE) {
|
||||
char buf[256] = {0};
|
||||
snprintf(buf, sizeof(buf), "unable to create fb (%d)", fbStatus);
|
||||
rlawtThrow(env, buf);
|
||||
goto freeSurface;
|
||||
}
|
||||
|
||||
if (entry->surface) {
|
||||
CFRelease(entry->surface);
|
||||
}
|
||||
entry->surface = buf;
|
||||
entry->scale = scale;
|
||||
return true;
|
||||
freeSurface:
|
||||
CFRelease(buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int poolNextBack(IOSurfacePool *pool) {
|
||||
// Find any non-front surface the compositor isn't using
|
||||
for (int i = 0; i < pool->count; i++) {
|
||||
if (i == pool->front) continue;
|
||||
if (pool->entries[i].surface && !IOSurfaceIsInUse(pool->entries[i].surface)) {
|
||||
POOL_STAT(pool, reuses);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// Grow pool if nothing was available
|
||||
if (pool->count < RLAWT_MAX_POOL) {
|
||||
int idx = pool->count++;
|
||||
POOL_STAT(pool, grows);
|
||||
#ifdef RLAWT_POOL_DEBUG
|
||||
if (pool->count > pool->stats.highWater) {
|
||||
pool->stats.highWater = pool->count;
|
||||
}
|
||||
#endif
|
||||
return idx;
|
||||
}
|
||||
|
||||
// Pool full, all in use -- evict first non-front entry.
|
||||
// count >= 2 is guaranteed here (pool grows on first swap), so this always finds one.
|
||||
for (int i = 0; i < pool->count; i++) {
|
||||
if (i != pool->front) {
|
||||
POOL_STAT(pool, stalls);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0; // unreachable
|
||||
}
|
||||
|
||||
#ifdef RLAWT_POOL_DEBUG
|
||||
static void poolLogStats(IOSurfacePool *pool) {
|
||||
CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
|
||||
if (now - pool->lastLogTime < 60.0) return;
|
||||
|
||||
NSLog(@"IOSurfacePool: %d swaps, %d allocs, pool %d/%d (hw %d), %d reuse, %d grow, %d stall, %d fail",
|
||||
pool->stats.swaps,
|
||||
pool->stats.allocs,
|
||||
pool->count,
|
||||
RLAWT_MAX_POOL,
|
||||
pool->stats.highWater,
|
||||
pool->stats.reuses,
|
||||
pool->stats.grows,
|
||||
pool->stats.stalls,
|
||||
pool->stats.failures);
|
||||
|
||||
memset(&pool->stats, 0, sizeof(pool->stats));
|
||||
pool->stats.highWater = pool->count;
|
||||
pool->lastLogTime = now;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_createGLContext(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
JAWT_DrawingSurfaceInfo *dsi = ctx->ds->GetDrawingSurfaceInfo(ctx->ds);
|
||||
if (!dsi) {
|
||||
rlawtThrow(env, "unable to get dsi");
|
||||
return;
|
||||
}
|
||||
|
||||
id<JAWT_SurfaceLayers> dspi = (id<JAWT_SurfaceLayers>) dsi->platformInfo;
|
||||
if (!dspi) {
|
||||
rlawtThrow(env, "unable to get platform dsi");
|
||||
goto freeDSI;
|
||||
}
|
||||
|
||||
CGLPixelFormatAttribute attribs[] = {
|
||||
kCGLPFAColorSize, 24,
|
||||
kCGLPFAAlphaSize, ctx->alphaDepth,
|
||||
kCGLPFADepthSize, ctx->depthDepth,
|
||||
kCGLPFAStencilSize, ctx->stencilDepth,
|
||||
kCGLPFADoubleBuffer, true,
|
||||
kCGLPFASampleBuffers, ctx->multisamples > 0,
|
||||
kCGLPFASamples, ctx->multisamples,
|
||||
// Legacy (2.1 compatibility) profile: this client's HD renderer is
|
||||
// fixed-function + ARB assembly programs, which no longer exist in the
|
||||
// GL4 core profile upstream rlawt requests.
|
||||
kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_Legacy,
|
||||
0
|
||||
};
|
||||
|
||||
CGLPixelFormatObj pxFmt = NULL;
|
||||
int numPxFmt = 1;
|
||||
CGLError err = CGLChoosePixelFormat(attribs, &pxFmt, &numPxFmt);
|
||||
if (!pxFmt || err != kCGLNoError) {
|
||||
rlawtThrowCGLError(env, "unable to choose format", err);
|
||||
goto freeDSI;
|
||||
}
|
||||
|
||||
err = CGLCreateContext(pxFmt, NULL, &ctx->context);
|
||||
CGLReleasePixelFormat(pxFmt);
|
||||
if (!ctx->context || err != kCGLNoError) {
|
||||
rlawtThrowCGLError(env, "unable to create context", err);
|
||||
goto freeDSI;
|
||||
}
|
||||
|
||||
if (!makeCurrent(env, ctx->context)) {
|
||||
goto freeContext;
|
||||
}
|
||||
|
||||
poolInit(&ctx->pool);
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
RLLayer *layer = [[RLLayer alloc] init];
|
||||
layer.opaque = true;
|
||||
layer.needsDisplayOnBoundsChange = false;
|
||||
layer.magnificationFilter = kCAFilterNearest;
|
||||
layer.contentsGravity = kCAGravityCenter;
|
||||
layer.affineTransform = CGAffineTransformMakeScale(1, -1);
|
||||
|
||||
ctx->layer = layer;
|
||||
dspi.layer = layer;
|
||||
|
||||
// must be after we give jawt the layer so our frame fix works
|
||||
layer.frame = CGRectMake(
|
||||
dsi->bounds.x + ctx->offsetX,
|
||||
dspi.windowLayer.bounds.size.height - (dsi->bounds.y + ctx->offsetY) - dsi->bounds.height, // as per AWTSurfaceLayers::setBounds
|
||||
dsi->bounds.width,
|
||||
dsi->bounds.height);
|
||||
});
|
||||
|
||||
ctx->pool.count = 1;
|
||||
if (!poolCreateSurface(env, &ctx->pool.entries[0], ctx->layer, ctx)) {
|
||||
goto freeContext;
|
||||
}
|
||||
|
||||
ctx->ds->FreeDrawingSurfaceInfo(dsi);
|
||||
|
||||
ctx->contextCreated = true;
|
||||
return;
|
||||
|
||||
freeContext:
|
||||
CGLDestroyContext(ctx->context);
|
||||
freeDSI:
|
||||
ctx->ds->FreeDrawingSurfaceInfo(dsi);
|
||||
}
|
||||
|
||||
void rlawtContextFreePlatform(JNIEnv *env, AWTContext *ctx) {
|
||||
poolDestroy(&ctx->pool);
|
||||
CGLSetCurrentContext(NULL);
|
||||
if (ctx->context) {
|
||||
CGLDestroyContext(ctx->context);
|
||||
}
|
||||
if (ctx->layer) {
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
[ctx->layer removeFromSuperlayer];
|
||||
[ctx->layer release];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT int JNICALL Java_net_runelite_rlawt_AWTContext_setSwapInterval(JNIEnv *env, jobject self, jint interval) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_makeCurrent(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
makeCurrent(env, ctx->context);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_detachCurrent(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
makeCurrent(env, NULL);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_swapBuffers(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
glFlush();
|
||||
|
||||
IOSurfacePool *pool = &ctx->pool;
|
||||
|
||||
// Present the current back buffer
|
||||
pool->front = pool->back;
|
||||
RLLayer *rlLayer = (RLLayer*) ctx->layer;
|
||||
rlLayer->newScale = pool->entries[pool->front].scale;
|
||||
[rlLayer performSelectorOnMainThread:
|
||||
@selector(displayIOSurface:)
|
||||
withObject: (id)(pool->entries[pool->front].surface)
|
||||
waitUntilDone: true];
|
||||
|
||||
POOL_STAT(pool, swaps);
|
||||
|
||||
// Find a free surface for the next frame
|
||||
pool->back = poolNextBack(pool);
|
||||
IOSurfaceEntry *back = &pool->entries[pool->back];
|
||||
|
||||
// Create/recreate surface if needed (new slot, wrong size, or still held by compositor)
|
||||
if (!poolEntryMatchesSize(back, ctx->layer)
|
||||
|| IOSurfaceIsInUse(back->surface)) {
|
||||
if (!poolCreateSurface(env, back, ctx->layer, ctx)) {
|
||||
POOL_STAT(pool, failures);
|
||||
return;
|
||||
}
|
||||
POOL_STAT(pool, allocs);
|
||||
}
|
||||
|
||||
#ifdef RLAWT_POOL_DEBUG
|
||||
poolLogStats(pool);
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_net_runelite_rlawt_AWTContext_getFramebuffer(JNIEnv *env, jobject self, jboolean front) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (front) {
|
||||
return ctx->pool.entries[ctx->pool.front].fbo;
|
||||
}
|
||||
return ctx->pool.entries[ctx->pool.back].fbo;
|
||||
}
|
||||
|
||||
#endif
|
||||
296
rlawt/rlawt_nix.c
Normal file
296
rlawt/rlawt_nix.c
Normal file
|
|
@ -0,0 +1,296 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef __unix__
|
||||
|
||||
#include "rlawt.h"
|
||||
#include <jawt_md.h>
|
||||
#include <string.h>
|
||||
|
||||
static XErrorEvent lastError = {0};
|
||||
static int rlawtXErrorHandler(Display *display, XErrorEvent *event) {
|
||||
if (lastError.display == 0) {
|
||||
lastError = *event;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rlawtThrow(JNIEnv *env, const char *msg) {
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
return;
|
||||
}
|
||||
|
||||
jclass clazz = (*env)->FindClass(env, "java/lang/RuntimeException");
|
||||
if (lastError.display) {
|
||||
char buf[256] = {0};
|
||||
snprintf(buf, sizeof(buf), "%s (glx: %u.%u: %u)", msg, (unsigned) lastError.minor_code, (unsigned) lastError.request_code, (unsigned) lastError.error_code);
|
||||
lastError.display = 0;
|
||||
(*env)->ThrowNew(env, clazz, buf);
|
||||
} else {
|
||||
(*env)->ThrowNew(env, clazz, msg);
|
||||
}
|
||||
}
|
||||
|
||||
static bool makeCurrent(JNIEnv *env, Display *dpy, GLXDrawable drawable, GLXContext ctx) {
|
||||
if (!glXMakeCurrent(dpy, drawable, ctx)) {
|
||||
rlawtThrow(env, "unable to make current");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_createGLContext(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->awt.Lock(env);
|
||||
XErrorHandler oldErrorHandler = XSetErrorHandler(rlawtXErrorHandler);
|
||||
|
||||
jint dsLock = ctx->ds->Lock(ctx->ds);
|
||||
if (dsLock & JAWT_LOCK_ERROR) {
|
||||
rlawtThrow(env, "unable to lock ds");
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
JAWT_DrawingSurfaceInfo *dsi = ctx->ds->GetDrawingSurfaceInfo(ctx->ds);
|
||||
if (!dsi) {
|
||||
rlawtThrow(env, "unable to get dsi");
|
||||
goto unlockDS;
|
||||
}
|
||||
|
||||
JAWT_X11DrawingSurfaceInfo *dspi = (JAWT_X11DrawingSurfaceInfo*) dsi->platformInfo;
|
||||
if (!dspi || !dspi->display || !dspi->drawable) {
|
||||
rlawtThrow(env, "unable to get platform dsi");
|
||||
goto freeDSI;
|
||||
}
|
||||
|
||||
ctx->drawable = dspi->drawable;
|
||||
|
||||
const char *displayName = XDisplayString(dspi->display);
|
||||
ctx->dpy = XOpenDisplay(displayName);
|
||||
if (!ctx->dpy) {
|
||||
rlawtThrow(env, "unable to open display copy");
|
||||
goto freeDSI;
|
||||
}
|
||||
|
||||
if (!glXQueryExtension(ctx->dpy, NULL, NULL)) {
|
||||
rlawtThrow(env, "glx is not supported");
|
||||
goto freeDisplay;
|
||||
}
|
||||
|
||||
int screen = DefaultScreen(ctx->dpy);
|
||||
|
||||
GLXFBConfig fbConfig = NULL;
|
||||
for (int db = 0; db < 2; db++) {
|
||||
ctx->doubleBuffered = db == 0;
|
||||
|
||||
int attribs[] = {
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, // JAWT never hands out a pixmap
|
||||
GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
|
||||
GLX_X_RENDERABLE, true,
|
||||
GLX_RED_SIZE, 8,
|
||||
GLX_GREEN_SIZE, 8,
|
||||
GLX_BLUE_SIZE, 8,
|
||||
GLX_ALPHA_SIZE, ctx->alphaDepth,
|
||||
GLX_DEPTH_SIZE, ctx->depthDepth,
|
||||
GLX_STENCIL_SIZE, ctx->stencilDepth,
|
||||
GLX_SAMPLE_BUFFERS, ctx->multisamples > 0,
|
||||
GLX_SAMPLES, ctx->multisamples,
|
||||
GLX_DOUBLEBUFFER, ctx->doubleBuffered,
|
||||
None
|
||||
};
|
||||
|
||||
int nConfigs;
|
||||
GLXFBConfig *fbConfigs = glXChooseFBConfig(ctx->dpy, screen, attribs, &nConfigs);
|
||||
if (!fbConfigs) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// X11 doesn't seem to care if you use a matching visual, but we try to anyway
|
||||
for (int i = 0; i < nConfigs; i++) {
|
||||
int fbVid = -1;
|
||||
glXGetFBConfigAttrib(ctx->dpy, fbConfigs[i], GLX_VISUAL_ID, &fbVid);
|
||||
if (fbVid == dspi->visualID) {
|
||||
fbConfig = fbConfigs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fbConfig) {
|
||||
XFree(fbConfigs);
|
||||
break;
|
||||
} else {
|
||||
fbConfig = fbConfigs[0];
|
||||
XFree(fbConfigs);
|
||||
}
|
||||
}
|
||||
if (!fbConfig) {
|
||||
rlawtThrow(env, "unable to find a fb config");
|
||||
goto freeDisplay;
|
||||
}
|
||||
|
||||
const char *extensions = glXQueryExtensionsString(ctx->dpy, screen);
|
||||
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = NULL;
|
||||
if (strstr(extensions, "GLX_ARB_create_context")) {
|
||||
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddressARB("glXCreateContextAttribsARB");
|
||||
}
|
||||
|
||||
if (glXCreateContextAttribsARB) {
|
||||
ctx->context = glXCreateContextAttribsARB(ctx->dpy, fbConfig, NULL, true, NULL);
|
||||
} else {
|
||||
ctx->context = glXCreateNewContext(ctx->dpy, fbConfig, GLX_RGBA_TYPE, NULL, true);
|
||||
}
|
||||
|
||||
if (!ctx->context) {
|
||||
rlawtThrow(env, "unable to create glx context");
|
||||
goto freeDisplay;
|
||||
}
|
||||
|
||||
if (!makeCurrent(env, ctx->dpy, ctx->drawable, ctx->context)) {
|
||||
goto freeContext;
|
||||
}
|
||||
|
||||
if (strstr(extensions, "GLX_EXT_swap_control")) {
|
||||
ctx->glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddress("glXSwapIntervalEXT");
|
||||
ctx->glxSwapControlTear = !!strstr(extensions, "GLX_EXT_swap_control_tear");
|
||||
} else if (strstr(extensions, "GLX_SGI_swap_control")) {
|
||||
ctx->glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddress("glXSwapIntervalSGI");
|
||||
}
|
||||
|
||||
ctx->ds->FreeDrawingSurfaceInfo(dsi);
|
||||
|
||||
XSync(ctx->dpy, false);
|
||||
XSetErrorHandler(oldErrorHandler);
|
||||
ctx->ds->Unlock(ctx->ds);
|
||||
rlawtUnlockAWT(env, ctx);
|
||||
|
||||
ctx->contextCreated = true;
|
||||
return;
|
||||
|
||||
freeContext:
|
||||
glXDestroyContext(ctx->dpy, ctx->context);
|
||||
freeDisplay:
|
||||
XSync(ctx->dpy, false);
|
||||
XCloseDisplay(ctx->dpy);
|
||||
jthrowable exception;
|
||||
freeDSI:
|
||||
exception = (*env)->ExceptionOccurred(env);
|
||||
ctx->ds->FreeDrawingSurfaceInfo(dsi);
|
||||
if (exception) {
|
||||
(*env)->Throw(env, exception);
|
||||
}
|
||||
unlockDS:
|
||||
exception = (*env)->ExceptionOccurred(env);
|
||||
ctx->ds->Unlock(ctx->ds);
|
||||
if (exception) {
|
||||
(*env)->Throw(env, exception);
|
||||
}
|
||||
unlock:
|
||||
XSetErrorHandler(oldErrorHandler);
|
||||
rlawtUnlockAWT(env, ctx);
|
||||
}
|
||||
|
||||
void rlawtContextFreePlatform(JNIEnv *env, AWTContext *ctx) {
|
||||
if (ctx->contextCreated) {
|
||||
glXMakeCurrent(ctx->dpy, None, None);
|
||||
glXDestroyContext(ctx->dpy, ctx->context);
|
||||
XCloseDisplay(ctx->dpy);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_net_runelite_rlawt_AWTContext_setSwapInterval(JNIEnv *env, jobject self, jint interval) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx->awt.Lock(env);
|
||||
|
||||
if (interval < 0 && !ctx->glxSwapControlTear) {
|
||||
interval = -interval;
|
||||
}
|
||||
if (ctx->glXSwapIntervalEXT) {
|
||||
ctx->glXSwapIntervalEXT(ctx->dpy, ctx->drawable, interval);
|
||||
} else if (ctx->glXSwapIntervalSGI) {
|
||||
ctx->glXSwapIntervalSGI(interval);
|
||||
} else {
|
||||
interval = 0;
|
||||
}
|
||||
|
||||
rlawtUnlockAWT(env, ctx);
|
||||
|
||||
return interval;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_makeCurrent(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->awt.Lock(env);
|
||||
|
||||
makeCurrent(env, ctx->dpy, ctx->drawable, ctx->context);
|
||||
|
||||
rlawtUnlockAWT(env, ctx);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_detachCurrent(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->awt.Lock(env);
|
||||
|
||||
makeCurrent(env, ctx->dpy, None, None);
|
||||
|
||||
rlawtUnlockAWT(env, ctx);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_swapBuffers(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->awt.Lock(env);
|
||||
XErrorHandler oldErrorHandler = XSetErrorHandler(rlawtXErrorHandler);
|
||||
|
||||
if (ctx->doubleBuffered) {
|
||||
// TODO: handle -1
|
||||
glXSwapBuffers(ctx->dpy, ctx->drawable);
|
||||
} else {
|
||||
glFinish();
|
||||
}
|
||||
|
||||
rlawtUnlockAWT(env, ctx);
|
||||
}
|
||||
|
||||
#endif
|
||||
237
rlawt/rlawt_windows.c
Normal file
237
rlawt/rlawt_windows.c
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include "rlawt.h"
|
||||
#include <jawt_md.h>
|
||||
#include <wingdi.h>
|
||||
|
||||
void rlawtThrow(JNIEnv *env, const char *msg) {
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
return;
|
||||
}
|
||||
|
||||
jclass clazz = (*env)->FindClass(env, "java/lang/RuntimeException");
|
||||
int lastError = GetLastError();
|
||||
if (lastError) {
|
||||
char buf[256] = {0};
|
||||
snprintf(buf, sizeof(buf), "%s (%d)", msg, lastError);
|
||||
(*env)->ThrowNew(env, clazz, buf);
|
||||
} else {
|
||||
(*env)->ThrowNew(env, clazz, msg);
|
||||
}
|
||||
}
|
||||
|
||||
static HGLRC createContext(HDC hdc) {
|
||||
HGLRC base = wglCreateContext(hdc);
|
||||
if (!base) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!wglMakeCurrent(hdc, base)) {
|
||||
wglDeleteContext(base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
if (wglCreateContextAttribsARB) {
|
||||
// The default values for WGL_CONTEXT_MAJOR_VERSION_ARB and WGL_CONTEXT_MINOR_VERSION_ARB are 1 and 0 respectively. In this case,
|
||||
// implementations will typically return the most recent version of OpenGL they support which is backwards compatible with OpenGL 1.0.
|
||||
const int attribs[] = {
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};
|
||||
HGLRC gl = wglCreateContextAttribsARB(hdc, 0, attribs);
|
||||
if (!gl) {
|
||||
wglDeleteContext(base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!wglMakeCurrent(hdc, gl)) {
|
||||
wglDeleteContext(base);
|
||||
wglDeleteContext(gl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wglDeleteContext(base);
|
||||
return gl;
|
||||
} else {
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
||||
static bool makeCurrent(JNIEnv *env, HDC dc, HGLRC context) {
|
||||
if (!wglMakeCurrent(dc, context)) {
|
||||
rlawtThrow(env, "unable to make current");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_createGLContext(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
jint dsLock = ctx->ds->Lock(ctx->ds);
|
||||
if (dsLock & JAWT_LOCK_ERROR) {
|
||||
rlawtThrow(env, "unable to lock ds");
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->dsi = ctx->ds->GetDrawingSurfaceInfo(ctx->ds);
|
||||
if (!ctx->dsi) {
|
||||
rlawtThrow(env, "unable to get dsi");
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
ctx->dspi = (JAWT_Win32DrawingSurfaceInfo*) ctx->dsi->platformInfo;
|
||||
if (!ctx->dspi || !ctx->dspi->hdc) {
|
||||
ctx->ds->FreeDrawingSurfaceInfo(ctx->dsi);
|
||||
ctx->dsi = NULL;
|
||||
rlawtThrow(env, "unable to get platform dsi");
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd = {0};
|
||||
pfd.nSize = sizeof(pfd);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 24;
|
||||
pfd.cRedBits = 8;
|
||||
pfd.cBlueBits = 8;
|
||||
pfd.cGreenBits = 8;
|
||||
pfd.cAlphaBits = ctx->alphaDepth;
|
||||
pfd.cDepthBits = ctx->depthDepth;
|
||||
pfd.cStencilBits = ctx->stencilDepth;
|
||||
|
||||
int format = ChoosePixelFormat(ctx->dspi->hdc, &pfd);
|
||||
if (!format) {
|
||||
rlawtThrow(env, "unable to choose format");
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
if (!SetPixelFormat(ctx->dspi->hdc, format, &pfd)) {
|
||||
rlawtThrow(env, "unable to set pixel format");
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
if (!makeCurrent(env, ctx->dspi->hdc, NULL)) {
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
ctx->context = createContext(ctx->dspi->hdc);
|
||||
if (!ctx->context) {
|
||||
rlawtThrow(env, "unable to create context");
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC) wglGetProcAddress("wglGetExtensionsStringEXT");
|
||||
if (wglGetExtensionsStringEXT) {
|
||||
const char *extensions = wglGetExtensionsStringEXT();
|
||||
|
||||
if (strstr(extensions, "WGL_EXT_swap_control")) {
|
||||
ctx->wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT");
|
||||
ctx->wglSwapControlTear = !!strstr(extensions, "WGL_EXT_swap_control_tear");
|
||||
}
|
||||
}
|
||||
|
||||
ctx->ds->Unlock(ctx->ds);
|
||||
|
||||
ctx->contextCreated = true;
|
||||
return;
|
||||
|
||||
unlock:
|
||||
jthrowable exception = (*env)->ExceptionOccurred(env);
|
||||
ctx->ds->Unlock(ctx->ds);
|
||||
if (exception) {
|
||||
(*env)->Throw(env, exception);
|
||||
}
|
||||
}
|
||||
|
||||
void rlawtContextFreePlatform(JNIEnv *env, AWTContext *ctx) {
|
||||
if (ctx->context) {
|
||||
wglDeleteContext(ctx->context);
|
||||
}
|
||||
if (ctx->dsi) {
|
||||
ctx->ds->FreeDrawingSurfaceInfo(ctx->dsi);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_net_runelite_rlawt_AWTContext_setSwapInterval(JNIEnv *env, jobject self, jint interval) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx->awt.Lock(env);
|
||||
|
||||
if (interval < 0 && !ctx->wglSwapControlTear) {
|
||||
interval = -interval;
|
||||
}
|
||||
|
||||
if (ctx->wglSwapIntervalEXT) {
|
||||
ctx->wglSwapIntervalEXT(interval);
|
||||
} else {
|
||||
interval = 0;
|
||||
}
|
||||
|
||||
rlawtUnlockAWT(env, ctx);
|
||||
return interval;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_makeCurrent(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
makeCurrent(env, ctx->dspi->hdc, ctx->context);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_detachCurrent(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
makeCurrent(env, ctx->dspi->hdc, NULL);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_net_runelite_rlawt_AWTContext_swapBuffers(JNIEnv *env, jobject self) {
|
||||
AWTContext *ctx = rlawtGetContext(env, self);
|
||||
if (!ctx || !rlawtContextState(env, ctx, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SwapBuffers(ctx->dspi->hdc)) {
|
||||
rlawtThrow(env, "unable to SwapBuffers");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -10,5 +10,4 @@ targetCompatibility = 1.8
|
|||
|
||||
dependencies {
|
||||
compileOnly project(':deob-annotations')
|
||||
compileOnly 'lib:jogl-all'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package rt4;
|
||||
|
||||
import com.jogamp.opengl.GLProfile;
|
||||
import org.openrs2.deob.annotation.OriginalArg;
|
||||
import org.openrs2.deob.annotation.OriginalClass;
|
||||
import org.openrs2.deob.annotation.OriginalMember;
|
||||
|
|
@ -410,9 +409,9 @@ public final class SignLink implements Runnable {
|
|||
}
|
||||
request.result = ((Class) args[0]).getDeclaredField((String) args[1]);
|
||||
} else if (type == 10) {
|
||||
//GLProfile.initSingleton(); //this is no longer necessary with jogl versions 2.0+.
|
||||
// formerly GLProfile.initSingleton(); JOGL replaced by LWJGL/rlawt
|
||||
} else if (type == 11) {
|
||||
GLProfile.shutdown();
|
||||
// formerly GLProfile.shutdown(); JOGL replaced by LWJGL/rlawt
|
||||
} else if (type == 12) {
|
||||
String cacheSubDir = (String) request.objectArg;
|
||||
@Pc(558) FileOnDisk preferences = openPreferencesInternal(cacheSubDir);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue