Skip to content

Commit

Permalink
Merge branch 'main' into opengl
Browse files Browse the repository at this point in the history
  • Loading branch information
squid233 committed Nov 25, 2023
2 parents 94efe40 + f880529 commit 32f290a
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ body:
description: Add any other context or screenshots about the feature request here.
placeholder: Other context
value: "I want ..."
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/Over-Run/overrungl/blob/main/CODE_OF_CONDUCT.md)
options:
- label: I agree to follow this project's Code of Conduct
required: true
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Summary

_A brief introduction to your changes..._

# Description

_Full description of your changes..._

# Additional Context

_Other context, such as version, dependencies, ..._

---

- [ ] I agree to follow this project's [Code of Conduct](https://github.com/Over-Run/overrungl/blob/main/CODE_OF_CONDUCT.md)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ natives
│ └─ windows
│ └─ x64
│ └─ glfw3.dll
├─ nfd https://github.com/Over-Run/nativefiledialog-extended-ci
├─ nfd https://github.com/Over-Run/nfd-ci
│ ├─ linux
│ │ ├─ arm32
│ │ │ └─ libnfd.so
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ subprojects {
val compileOnly by configurations
val implementation by configurations
dependencies {
compileOnly("org.jetbrains:annotations:24.0.1")
compileOnly("org.jetbrains:annotations:24.1.0")
if (project.name != "core") {
implementation(project(":core"))
}
Expand Down
12 changes: 12 additions & 0 deletions modules/overrungl.core/src/main/java/overrungl/OverrunGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ public final class OverrunGL {
* The version of OverrunGL.
*/
public static final String VERSION = "0.1.0";
/**
* The version of GLFW native libraries.
*/
public static final String GLFW_VERSION = "3.3.8.0";
/**
* The version of NFD native libraries.
*/
public static final String NFD_VERSION = "0.1.0.0";
/**
* The version of STB native libraries.
*/
public static final String STB_VERSION = "0.1.0.0";
private static final Consumer<String> DEFAULT_LOGGER = System.err::println;
private static Consumer<String> apiLogger = DEFAULT_LOGGER;

Expand Down
17 changes: 17 additions & 0 deletions modules/overrungl.core/src/main/java/overrungl/util/CStdlib.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,21 @@ public static MemorySegment memset(MemorySegment dest, int c, long count) {
throw new AssertionError("should not reach here", e);
}
}

/**
* Allocates a string with {@link CStdlib}.
*
* @param s the string.
* @return the memory segment of the allocated string. <b>MUST</b> be released by {@link #free(MemorySegment)}.
*/
public static MemorySegment newString(String s) {
class Holder {
private static final SegmentAllocator ALLOCATOR = (byteSize, byteAlignment) -> {
checkByteSize(byteSize);
checkAlignment(byteAlignment);
return calloc(1, byteSize);
};
}
return Holder.ALLOCATOR.allocateUtf8String(s);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import overrungl.Configurations;
import overrungl.FunctionDescriptors;
import overrungl.OverrunGL;
import overrungl.internal.RuntimeHelper;

import java.lang.foreign.FunctionDescriptor;
Expand All @@ -40,8 +41,7 @@ final class Handles {
private static final SymbolLookup lookup;

static {
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("glfw", "glfw3",
STR. "\{ GLFW.VERSION_MAJOR }.\{ GLFW.VERSION_MINOR }.\{ GLFW.VERSION_REVISION }" );
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("glfw", "glfw3", OverrunGL.GLFW_VERSION);
final var function = Configurations.GLFW_SYMBOL_LOOKUP.get();
lookup = function != null ? function.apply(lib) : lib.get();
}
Expand Down
3 changes: 2 additions & 1 deletion modules/overrungl.nfd/src/main/java/overrungl/nfd/NFD.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import overrungl.Configurations;
import overrungl.FunctionDescriptors;
import overrungl.NativeType;
import overrungl.OverrunGL;
import overrungl.internal.RuntimeHelper;
import overrungl.os.Platform;
import overrungl.util.MemoryStack;
Expand Down Expand Up @@ -123,7 +124,7 @@ public final class NFD {
private static final SymbolLookup LOOKUP;

static {
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("nfd", "nfd", "0.1.0.0");
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("nfd", "nfd", OverrunGL.NFD_VERSION);
final var function = Configurations.NFD_SYMBOL_LOOKUP.get();
LOOKUP = function != null ? function.apply(lib) : lib.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import overrungl.Configurations;
import overrungl.FunctionDescriptors;
import overrungl.OverrunGL;
import overrungl.internal.RuntimeHelper;

import java.lang.foreign.Linker;
Expand All @@ -35,7 +36,7 @@ final class Handles {
private static final SymbolLookup lookup;

static {
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("stb", "stb", "0.1.0.0");
final Supplier<SymbolLookup> lib = () -> RuntimeHelper.load("stb", "stb", OverrunGL.STB_VERSION);
final var function = Configurations.STB_SYMBOL_LOOKUP.get();
lookup = function != null ? function.apply(lib) : lib.get();
}
Expand Down

0 comments on commit 32f290a

Please sign in to comment.