Skip to content

Commit

Permalink
[OpenGL] Rewrite GL45C (WIP)
Browse files Browse the repository at this point in the history
[OpenGL] Reworking GLExtCaps
  • Loading branch information
squid233 committed Jan 31, 2024
1 parent bc8e131 commit af0157a
Show file tree
Hide file tree
Showing 14 changed files with 1,715 additions and 2,329 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3171,10 +3171,12 @@ fun glExtCaps() {
|import overrungl.opengl.ext.nv.*;
|import overrungl.opengl.ext.sgi.*;
|import overrungl.opengl.ext.sun.*;
|import overrun.marshal.Unmarshal;
|
|import java.lang.foreign.MemorySegment;
|import java.lang.foreign.SegmentAllocator;
|import java.lang.invoke.MethodHandle;
|import java.util.ArrayList;
|
|import static java.lang.foreign.ValueLayout.*;
|import static overrungl.opengl.GLExtFinder.*;
Expand Down Expand Up @@ -3218,17 +3220,14 @@ fun glExtCaps() {
appendLine(" }\n")
appendLine(
"""
| boolean findExtensionsGL(int version, SegmentAllocator allocator) {
| boolean findExtensionsGL(SegmentAllocator allocator, GLLoadFunc load, int version) {
| var pExts = allocator.allocate(ADDRESS);
| var pNumExtsI = allocator.allocate(JAVA_INT);
| var pExtsI = new MemorySegment[1];
| if (!getExtensions(allocator, version, pExts, pNumExtsI, pExtsI, caps)) return false;
| var list = new ArrayList<String>(700);
| if (!getExtensions(allocator, version, pExts, list, load)) return false;
|
| String exts = pExts.getString(0);
| int numExtsI = pNumExtsI.get(JAVA_INT, 0);
| var extsI = pExtsI[0];
| String exts = Unmarshal.unmarshalAsString(pExts.get(Unmarshal.STR_LAYOUT, 0));
|
| ${caps.joinToString(separator = "\n| ") { "this.$it = hasExtension(version, exts, numExtsI, extsI, \"$it\");" }}
| ${caps.joinToString(separator = "\n| ") { "this.$it = hasExtension(version, exts, list, \"$it\");" }}
|
| return true;
| }
Expand Down
20 changes: 7 additions & 13 deletions modules/overrungl.opengl/src/main/java/overrungl/opengl/GL15C.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,38 +99,32 @@ default void bufferData(int target, long size, int usage) {

@Skip
default void bufferData(SegmentAllocator allocator, int target, byte[] data, int usage) {
final MemorySegment segment = Marshal.marshal(allocator, data);
bufferData(target, segment.byteSize(), segment, usage);
bufferData(target, Marshal.marshal(allocator, data), usage);
}

@Skip
default void bufferData(SegmentAllocator allocator, int target, short[] data, int usage) {
final MemorySegment segment = Marshal.marshal(allocator, data);
bufferData(target, segment.byteSize(), segment, usage);
bufferData(target, Marshal.marshal(allocator, data), usage);
}

@Skip
default void bufferData(SegmentAllocator allocator, int target, int[] data, int usage) {
final MemorySegment segment = Marshal.marshal(allocator, data);
bufferData(target, segment.byteSize(), segment, usage);
bufferData(target, Marshal.marshal(allocator, data), usage);
}

@Skip
default void bufferData(SegmentAllocator allocator, int target, long[] data, int usage) {
final MemorySegment segment = Marshal.marshal(allocator, data);
bufferData(target, segment.byteSize(), segment, usage);
bufferData(target, Marshal.marshal(allocator, data), usage);
}

@Skip
default void bufferData(SegmentAllocator allocator, int target, float[] data, int usage) {
final MemorySegment segment = Marshal.marshal(allocator, data);
bufferData(target, segment.byteSize(), segment, usage);
bufferData(target, Marshal.marshal(allocator, data), usage);
}

@Skip
default void bufferData(SegmentAllocator allocator, int target, double[] data, int usage) {
final MemorySegment segment = Marshal.marshal(allocator, data);
bufferData(target, segment.byteSize(), segment, usage);
bufferData(target, Marshal.marshal(allocator, data), usage);
}

@Entrypoint("glBufferSubData")
Expand Down Expand Up @@ -386,7 +380,7 @@ default MemorySegment mapBuffer(int target, int access) {
long size = 0;
if (this instanceof GL32C gl32C) {
try {
size = gl32C.getBufferParameteri64v(target, GL30C.BUFFER_MAP_LENGTH);
size = gl32C.getBufferParameteri64v(target, BUFFER_SIZE);
} catch (ContextException e) {
size = getBufferParameteriv(target, BUFFER_SIZE);
}
Expand Down
Loading

0 comments on commit af0157a

Please sign in to comment.