Skip to content

Commit

Permalink
[OpenGL] Update OpenGL extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Feb 1, 2024
1 parent d293347 commit f0cf725
Show file tree
Hide file tree
Showing 433 changed files with 8,528 additions and 3,285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package overrungl.util;

import org.jetbrains.annotations.Nullable;

import java.util.Arrays;

/**
Expand All @@ -26,8 +24,6 @@
* @since 0.1.0
*/
final class StackWalkUtil {
private static final StackWalker STACKWALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);

private StackWalkUtil() {
}

Expand All @@ -37,72 +33,6 @@ static StackTraceElement[] stackWalkArray(Object[] a) {
.toArray(StackTraceElement[]::new);
}

static Object stackWalkGetMethod(Class<?> after) {
return STACKWALKER.walk(s -> {
var iter = s.iterator();
iter.next(); // skip this method
iter.next(); // skip MemoryStack::pop

StackWalker.StackFrame frame;
do {
frame = iter.next();
} while (frame.getDeclaringClass() == after && iter.hasNext());

return frame;
});
}

private static boolean isSameMethod(StackWalker.StackFrame a, StackWalker.StackFrame b) {
return isSameMethod(a, b, b.getMethodName());
}

private static boolean isSameMethod(StackWalker.StackFrame a, StackWalker.StackFrame b, String methodName) {
return a.getDeclaringClass() == b.getDeclaringClass() &&
a.getMethodName().equals(methodName);
}

private static boolean isAutoCloseable(StackWalker.StackFrame element, StackWalker.StackFrame pushed) {
// Java 9 try-with-resources: synthetic $closeResource
if (isSameMethod(element, pushed, "$closeResource")) {
return true;
}

// Kotlin T.use: kotlin.AutoCloseable::closeFinally
return "kotlin.jdk7.AutoCloseableKt".equals(element.getClassName()) && "closeFinally".equals(element.getMethodName());
}

@Nullable
static Object stackWalkCheckPop(Class<?> after, Object pushedObj) {
StackWalker.StackFrame pushed = (StackWalker.StackFrame) pushedObj;

return StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk(s -> {
var iter = s.iterator();
iter.next();
iter.next();

StackWalker.StackFrame element;
do {
element = iter.next();
} while (element.getDeclaringClass() == after && iter.hasNext());

if (isSameMethod(element, pushed)) {
return null;
}

if (iter.hasNext() && isAutoCloseable(element, pushed)) {
// Some runtimes use a separate method to call AutoCloseable::close in try-with-resources blocks.
// That method suppresses any exceptions thrown by close if necessary.
// When that happens, the pop is 1 level deeper than expected.
element = iter.next();
if (isSameMethod(element, pushed)) {
return null;
}
}

return element;
});
}

static Object[] stackWalkGetTrace() {
return StackWalker.getInstance()
.walk(s -> s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ class OpenGLFile(
"""
${fileHeader.prependIndent("|")}
|package overrungl.opengl${ext.packageName};
|import overrungl.*;
|import overrun.marshal.*;
|import overrungl.NativeType;
|import overrungl.opengl.*;
|import java.lang.foreign.*;
|/**
Expand All @@ -208,31 +207,32 @@ class OpenGLFile(
append(" ")
if (overload) {
appendLine("@overrun.marshal.gen.Skip")
append(" default ")
append(" ")
}
if (f.nativeType != null)
append("@NativeType(\"${f.nativeType}\") ")
append("${f.returnType} ${f.name}(")
append("default ${f.returnType} ${f.name}(")
f.params.forEachIndexed { index, it ->
if (index != 0) append(", ")
if (it.nativeType != null)
append("@NativeType(\"${it.nativeType}\") ")
append("${it.type} ${it.name}")
}
append(")")
appendLine(") {")
}
functions.forEach { f ->
appendFuncHeader(f, false)
append(';')
appendLine(" throw new ContextException();")
appendLine(" }")
appendLine()

// overloads
if (f.overloads.isNotEmpty()) {
f.overloads.forEach { overload ->
appendFuncHeader(overload, true)
appendLine(" {")
appendLine(overload.content!!.prependIndent(" "))
appendLine(" }")
appendLine()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
* {@code GL_3DFX_tbuffer}
*/
public interface GL3DFXTbuffer {

void glTbufferMask3DFX(int mask);
default void glTbufferMask3DFX(int mask) {
throw new ContextException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
* {@code GL_GREMEDY_frame_terminator}
*/
public interface GLGREMEDYFrameTerminator {

void glFrameTerminatorGREMEDY();
default void glFrameTerminatorGREMEDY() {
throw new ContextException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
* {@code GL_GREMEDY_string_marker}
*/
public interface GLGREMEDYStringMarker {

void glStringMarkerGREMEDY(int len, @NativeType("const void *") MemorySegment string);
default void glStringMarkerGREMEDY(int len, @NativeType("const void *") MemorySegment string) {
throw new ContextException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand All @@ -41,10 +40,28 @@ public interface GLHPImageTransform {
int GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP = 0x8162;
int GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP = 0x8163;

void glImageTransformParameteriHP(int target, int pname, int param);
void glImageTransformParameterfHP(int target, int pname, float param);
void glImageTransformParameterivHP(int target, int pname, @NativeType("const GLint *") MemorySegment params);
void glImageTransformParameterfvHP(int target, int pname, @NativeType("const GLfloat *") MemorySegment params);
void glGetImageTransformParameterivHP(int target, int pname, @NativeType("GLint *") MemorySegment params);
void glGetImageTransformParameterfvHP(int target, int pname, @NativeType("GLfloat *") MemorySegment params);
default void glImageTransformParameteriHP(int target, int pname, int param) {
throw new ContextException();
}

default void glImageTransformParameterfHP(int target, int pname, float param) {
throw new ContextException();
}

default void glImageTransformParameterivHP(int target, int pname, @NativeType("const GLint *") MemorySegment params) {
throw new ContextException();
}

default void glImageTransformParameterfvHP(int target, int pname, @NativeType("const GLfloat *") MemorySegment params) {
throw new ContextException();
}

default void glGetImageTransformParameterivHP(int target, int pname, @NativeType("GLint *") MemorySegment params) {
throw new ContextException();
}

default void glGetImageTransformParameterfvHP(int target, int pname, @NativeType("GLfloat *") MemorySegment params) {
throw new ContextException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
* {@code GL_INGR_blend_func_separate}
*/
public interface GLINGRBlendFuncSeparate {

void glBlendFuncSeparateINGR(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dfactorAlpha);
default void glBlendFuncSeparateINGR(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dfactorAlpha) {
throw new ContextException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

// This file is auto-generated. DO NOT EDIT!
package overrungl.opengl.ext;

import overrungl.*;
import overrun.marshal.*;
import overrungl.NativeType;
import overrungl.opengl.*;
import java.lang.foreign.*;

/**
Expand Down
Loading

0 comments on commit f0cf725

Please sign in to comment.