Skip to content

Commit

Permalink
[OpenGL] Rewriting GLExtCaps (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Jan 31, 2024
1 parent af0157a commit da927e3
Show file tree
Hide file tree
Showing 7 changed files with 660 additions and 668 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jdkEnablePreview=true
jdkEarlyAccessDoc=jdk22
kotlinTargetJdkVersion=21

overrunMarshalVersion=0.1.0-alpha.10-jdk22
overrunMarshalVersion=0.1.0-alpha.12-jdk22
overrunPlatformVersion=1.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -3173,7 +3173,6 @@ fun glExtCaps() {
|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;
Expand Down Expand Up @@ -3220,14 +3219,11 @@ fun glExtCaps() {
appendLine(" }\n")
appendLine(
"""
| boolean findExtensionsGL(SegmentAllocator allocator, GLLoadFunc load, int version) {
| var pExts = allocator.allocate(ADDRESS);
| boolean findExtensionsGL(GLLoadFunc load, int version) {
| var list = new ArrayList<String>(700);
| if (!getExtensions(allocator, version, pExts, list, load)) return false;
| if (!getExtensions(load, version, list)) return false;
|
| String exts = Unmarshal.unmarshalAsString(pExts.get(Unmarshal.STR_LAYOUT, 0));
|
| ${caps.joinToString(separator = "\n| ") { "this.$it = hasExtension(version, exts, list, \"$it\");" }}
| ${caps.joinToString(separator = "\n| ") { "this.$it = list.contains(\"$it\");" }}
|
| return true;
| }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import overrun.marshal.Marshal;
import overrun.marshal.gen.Entrypoint;
import overrun.marshal.gen.Skip;
import overrungl.opengl.ext.arb.GLARBPointParameters;
import overrungl.opengl.ext.arb.GLARBShadow;
import overrungl.opengl.ext.arb.GLARBTextureMirroredRepeat;
Expand Down Expand Up @@ -100,7 +101,7 @@ default void multiDrawElements(int mode, MemorySegment count, int type, MemorySe
throw new ContextException();
}

@Entrypoint("glMultiDrawElements")
@Skip
default void multiDrawElements(SegmentAllocator allocator, int mode, int[] count, int type, byte[][] indices, int drawCount) {
var seg = allocator.allocate(ADDRESS, indices.length);
for (int i = 0; i < indices.length; i++) {
Expand All @@ -109,7 +110,7 @@ default void multiDrawElements(SegmentAllocator allocator, int mode, int[] count
multiDrawElements(mode, Marshal.marshal(allocator, count), type, seg, drawCount);
}

@Entrypoint("glMultiDrawElements")
@Skip
default void multiDrawElements(SegmentAllocator allocator, int mode, int[] count, int type, short[][] indices, int drawCount) {
var seg = allocator.allocate(ADDRESS, indices.length);
for (int i = 0; i < indices.length; i++) {
Expand All @@ -118,7 +119,7 @@ default void multiDrawElements(SegmentAllocator allocator, int mode, int[] count
multiDrawElements(mode, Marshal.marshal(allocator, count), type, seg, drawCount);
}

@Entrypoint("glMultiDrawElements")
@Skip
default void multiDrawElements(SegmentAllocator allocator, int mode, int[] count, int type, int[][] indices, int drawCount) {
var seg = allocator.allocate(ADDRESS, indices.length);
for (int i = 0; i < indices.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package overrungl.opengl;

import overrun.marshal.MemoryStack;
import overrun.marshal.Unmarshal;

import java.lang.foreign.FunctionDescriptor;
Expand Down Expand Up @@ -68,10 +67,7 @@ public int load(GLLoadFunc load) {
int version = findCoreGL(glGetString);

ext = new GLExtCaps(this);

try (var stack = MemoryStack.stackPush()) {
if (!ext.findExtensionsGL(stack, load, version)) return 0;
}
if (!ext.findExtensionsGL(load, version)) return 0;
ext.load(load);

rawGLVersion = version;
Expand Down
Loading

0 comments on commit da927e3

Please sign in to comment.