Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenGL] Update core and extensions #32

Merged
merged 29 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d30e253
[OpenGL] Update extensions
squid233 Aug 23, 2023
105383f
[OpenGL] Add KHR extensions
squid233 Aug 23, 2023
9a93173
Merge branch 'main' into opengl
squid233 Sep 17, 2023
e1f9ebd
[OpenGL] Update Generator
squid233 Sep 20, 2023
f2d977e
[OpenGL] Add support to function overload
squid233 Sep 23, 2023
0889e85
Merge branch 'main' into opengl
squid233 Sep 23, 2023
a06ed74
[OpenGL] Updated generator
squid233 Sep 23, 2023
7e485ab
[OpenGL] Update generator
squid233 Sep 23, 2023
f73af88
[OpenGL] Generate files
squid233 Sep 23, 2023
f58866c
Merge branch 'main' into opengl
squid233 Sep 30, 2023
0010cc7
[OpenGL] Added new extensions; update license header
squid233 Oct 14, 2023
bc63ed5
Merge branch 'main' into opengl
squid233 Oct 14, 2023
12a4195
Merge branch 'main' into opengl
squid233 Oct 14, 2023
41b07e2
Merge branch 'main' into opengl
squid233 Oct 21, 2023
b1a5da6
[OpenGL] Update extensions
squid233 Oct 28, 2023
9a0856d
[OpenGL] Updated extensions and compability constants
squid233 Nov 4, 2023
597cf78
[OpenGL] Update extensions; fixed CI
squid233 Nov 4, 2023
4d20cd2
Merge branch 'main' into opengl
squid233 Nov 4, 2023
201ea6a
[OpenGL] Update extensions
squid233 Nov 11, 2023
94efe40
[OpenGL] Update extensions
squid233 Nov 18, 2023
32f290a
Merge branch 'main' into opengl
squid233 Nov 25, 2023
3e4cad5
[OpenGL] Update extensions
squid233 Nov 25, 2023
faceced
Merge branch 'main' into opengl
squid233 Dec 1, 2023
f927dbd
Update extensions
squid233 Dec 2, 2023
471be64
[OpenGL] Update extensions
squid233 Dec 9, 2023
7905eb1
[OpenGL] Update extensions
squid233 Dec 16, 2023
65eacd1
[OpenGL] Update extensions
squid233 Dec 23, 2023
1acec2c
[OpenGL] Updated extensions.
squid233 Dec 29, 2023
d44845b
[OpenGL] Removed GLConst and GLConstC
squid233 Dec 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 17 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.gradle.plugins.ide.idea.model.IdeaModel
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.nio.file.Files
import kotlin.io.path.Path

Expand All @@ -7,6 +8,7 @@ plugins {
`maven-publish`
signing
id("me.champeau.jmh") version "0.7.1" apply false
embeddedKotlin("jvm") apply false
}

val projGroupId: String by project
Expand All @@ -19,9 +21,12 @@ val orgName: String by project
val orgUrl: String by project
val developers: String by project

val jdkEABuildDoc: String? = null
val targetJavaVersion = 21
val enablePreview = true
val jdkVersion: String by rootProject
val jdkEnablePreview: String by rootProject
val jdkEarlyAccessDoc: String? by rootProject
val kotlinTargetJdkVersion: String by rootProject

val targetJavaVersion = jdkVersion.toInt()

group = projGroupId
version = projVersion
Expand Down Expand Up @@ -121,6 +126,7 @@ subprojects {
apply(plugin = "java-library")
apply(plugin = "idea")
apply(plugin = "me.champeau.jmh")
apply(plugin = "org.jetbrains.kotlin.jvm")

group = projGroupId
version = projVersion
Expand All @@ -145,12 +151,16 @@ subprojects {

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
if (enablePreview) options.compilerArgs.add("--enable-preview")
if (jdkEnablePreview.toBoolean()) options.compilerArgs.add("--enable-preview")
options.release.set(targetJavaVersion)
}

tasks.withType<KotlinCompile> {
kotlinOptions { jvmTarget = kotlinTargetJdkVersion }
}

tasks.withType<Test> {
if (enablePreview) jvmArgs("--enable-preview")
if (jdkEnablePreview.toBoolean()) jvmArgs("--enable-preview")
}

extensions.configure<JavaPluginExtension>("java") {
Expand Down Expand Up @@ -241,10 +251,10 @@ allprojects {
charSet = "UTF-8"
docEncoding = "UTF-8"
isAuthor = true
if (jdkEABuildDoc == null) {
if (jdkEarlyAccessDoc == null) {
links("https://docs.oracle.com/en/java/javase/$targetJavaVersion/docs/api/")
} else {
links("https://download.java.net/java/early_access/$jdkEABuildDoc/docs/api/")
links("https://download.java.net/java/early_access/$jdkEarlyAccessDoc/docs/api/")
}

tags(
Expand Down Expand Up @@ -288,17 +298,6 @@ publishing.publications {
name.set(orgName)
url.set(orgUrl)
}
developers {
developers.split(',')
.map { it.split(':', limit = 3) }
.forEach { (id1, name1, email1) ->
developer {
id.set(id1)
name.set(name1)
email.set(email1)
}
}
}
scm {
connection.set("scm:git:https://github.com/${projVcs}.git")
developerConnection.set("scm:git:https://github.com/${projVcs}.git")
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ projBranch=main
orgName=Overrun Organization
orgUrl=https://over-run.github.io/

# Developers
developers=squid233:squid233:[email protected]
jdkVersion=21
jdkEnablePreview=true
#jdkEarlyAccessDoc=jdk22
kotlinTargetJdkVersion=21

projModules=core, glfw, nfd, joml, opengl, stb
20 changes: 20 additions & 0 deletions modules/overrungl.core/src/main/java/overrungl/Callback.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.lang.foreign.MemorySegment;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.util.function.Function;

/**
* The upcall stub which can be passed to other foreign functions as a function pointer,
Expand Down Expand Up @@ -58,6 +59,16 @@ default MemorySegment address(Arena arena) {
*/
MethodHandle handle(MethodHandles.Lookup lookup) throws NoSuchMethodException, IllegalAccessException;

/**
* Creates a method handle that invokes a native function callback.
*
* @param segment the segment of the native function.
* @return the method handle
*/
default MethodHandle nativeHandle(MemorySegment segment) {
return RuntimeHelper.LINKER.downcallHandle(segment, descriptor());
}

/**
* Gets the memory segment of the upcall stub with the given arena.
*
Expand All @@ -72,4 +83,13 @@ default MemorySegment segment(Arena arena, FunctionDescriptor function) {
throw new RuntimeException(e);
}
}

/**
* Method handle getter.
*
* @author squid233
* @since 0.1.0
*/
interface Native<T> extends Function<MemorySegment, T> {
}
}
18 changes: 16 additions & 2 deletions modules/overrungl.opengl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
val jdkVersion: String by rootProject
val jdkEnablePreview: String by rootProject
val kotlinTargetJdkVersion: String by rootProject

sourceSets {
create("generator")
}

tasks.named<JavaCompile>("compileGeneratorJava") {
javaCompiler.set(javaToolchains.compilerFor {
targetCompatibility = kotlinTargetJdkVersion
languageVersion.set(JavaLanguageVersion.of(jdkVersion))
})
}

tasks.register<JavaExec>("generate") {
classpath(sourceSets["generator"].runtimeClasspath)
jvmArgs("--enable-preview")
mainClass.set("overrungl.opengl.OpenGLGenerator")
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(jdkVersion))
})
if (jdkEnablePreview.toBoolean()) jvmArgs("--enable-preview")
mainClass.set("overrungl.opengl.OpenGLGeneratorKt")
workingDir = File("src/main/java/overrungl/opengl")
}
Loading