Skip to content

Commit

Permalink
[OpenGL] Hotfix of GLLoader
Browse files Browse the repository at this point in the history
Added lookup parameter
  • Loading branch information
squid233 committed Mar 16, 2024
1 parent 885d8a3 commit 2b8d607
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static GLFlags loadFlags(GLLoadFunc load) {
*/
@Nullable
public static GL load(GLFlags flags) {
return flags.GL10 ? loadContext(flags, GL.class) : null;
return flags.GL10 ? loadBuiltin(flags, GL.class) : null;
}

/**
Expand All @@ -83,7 +83,7 @@ public static GL load(GLFlags flags) {
*/
@Nullable
public static GLLegacy loadLegacy(GLFlags flags) {
return flags.GL10 ? loadContext(flags, GLLegacy.class) : null;
return flags.GL10 ? loadBuiltin(flags, GLLegacy.class) : null;
}

/**
Expand All @@ -94,7 +94,7 @@ public static GLLegacy loadLegacy(GLFlags flags) {
*/
@Nullable
public static GLExtension loadExtension(GLFlags flags) {
return flags.foundExtension ? loadContext(flags, GLExtension.class) : null;
return flags.foundExtension ? loadBuiltin(flags, GLExtension.class) : null;
}

/**
Expand All @@ -105,8 +105,21 @@ public static GLExtension loadExtension(GLFlags flags) {
* @param <T> the type of the instance
* @return an instance that wraps OpenGL context
*/
public static <T> T loadContext(GLFlags flags, Class<T> targetClass) {
return Downcall.load(LOOKUP,
public static <T> T loadBuiltin(GLFlags flags, Class<T> targetClass) {
return loadContext(LOOKUP, flags, targetClass);
}

/**
* Loads OpenGL context with the given flags.
*
* @param caller the lookup object for the caller
* @param flags the OpenGL flags
* @param targetClass the target class
* @param <T> the type of the instance
* @return an instance that wraps OpenGL context
*/
public static <T> T loadContext(MethodHandles.Lookup caller, GLFlags flags, Class<T> targetClass) {
return Downcall.load(caller,
flags.load.lookup(),
DowncallOption.targetClass(targetClass),
DowncallOption.descriptors(DESCRIPTOR_MAP));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ private void load(Arena arena) {

debugProc = GLUtil.setupDebugMessageCallback(gl,
flags,
() -> GLLoader.loadContext(flags, GLARBDebugOutput.class),
() -> GLLoader.loadContext(flags, GLAMDDebugOutput.class));
() -> GLLoader.loadBuiltin(flags, GLARBDebugOutput.class),
() -> GLLoader.loadBuiltin(flags, GLAMDDebugOutput.class));
gl.clearColor(0.4f, 0.6f, 0.9f, 1.0f);
program = gl.createProgram();
int vsh = gl.createShader(GL.VERTEX_SHADER);
Expand Down

0 comments on commit 2b8d607

Please sign in to comment.