Skip to content
squid233 edited this page Feb 1, 2024 · 9 revisions

OverrunGL is designed base on Java FFM API. We use Marshal to conveniently generate classes that invoke native functions.

C Types -> Java Types

FunctionDescriptor is a carrier of the memory layouts. We use a corresponding FunctionDescriptor to pass and get the values.

The types in the table this below are directly converted from/to C.

Value Layout Parameter Type C/C++ Type
JAVA_BYTE byte char
JAVA_SHORT short short
JAVA_INT int int
JAVA_LONG long long long
JAVA_CHAR char short
JAVA_BOOLEAN boolean char/bool
JAVA_FLOAT float float
JAVA_DOUBLE double double
ADDRESS MemorySegment void*

Any pointer types can directly convert to MemorySegment even if it is a pointer of struct or other pointers of pointer.

✔️ int*
✔️ my_struct*
✔️ void**
✔️ other_struct******

ValueLayout.ADDRESS with target layout on return type will reinterpret to correspoding size.

Naming Convention

OverrunGL removes the prefix of the macros and functions when the wrapper class name is similar to it.

// C: glfwInit()
glfw.init();
// C: glGetString()
gl.getString();
Clone this wiki locally