Skip to content

Commit

Permalink
Merge pull request #49 from Over-Run/glfw
Browse files Browse the repository at this point in the history
[GLFW] Upgrade GLFW to 3.4
  • Loading branch information
squid233 authored Mar 9, 2024
2 parents 5f5923f + 350441f commit ace41e5
Show file tree
Hide file tree
Showing 28 changed files with 1,253 additions and 213 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Feature request
description: Suggest an idea for this project
title: "Feature: "
labels: [ "enhancement", "P5" ]
labels: [ "enh", "P4" ]
assignees:
- "squid233"
body:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

name: Java CI with Gradle

on: [ push, pull_request, workflow_dispatch ]
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Javadoc

on: [ release, workflow_dispatch ]

jobs:
build:
strategy:
matrix:
java: [
22-ea
]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: |
${{ matrix.java }}
21
distribution: 'temurin'
- name: Grant execute permission for gradlew
if: ${{ runner.os != 'Windows' }}
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Execute Gradle build
run: ./gradlew aggregateJavadoc
- name: Capture Javadoc
uses: actions/upload-artifact@v4
with:
name: javadoc
path: build/docs/javadoc/
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ artifactNameMap.forEach { (subprojectName, artifactName) ->
// temporary maven repositories
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") }
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/releases") }
maven { url = uri("https://maven.aliyun.com/repository/central") }
}

val compileOnly by configurations
Expand Down
2 changes: 1 addition & 1 deletion doc/notes/0.x/0.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _Not Released Yet_

This version includes the following features:

- GLFW 3.3.9
- GLFW 3.4
- OpenGL 1.0 ~ 4.6 functions and constants
- OpenGL extension functions
- OpenGL Loader
Expand Down
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.21-jdk22
overrunMarshalVersion=0.1.0-alpha.23-jdk22
overrunPlatformVersion=1.0.0
24 changes: 23 additions & 1 deletion modules/overrungl.core/src/main/java/overrungl/OverrunGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

package overrungl;

import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.jar.Manifest;

/**
* Constants of OverrunGL.
Expand All @@ -33,7 +37,7 @@ public final class OverrunGL {
/**
* The version of GLFW native libraries.
*/
public static final String GLFW_VERSION = "3.3.9.0";
public static final String GLFW_VERSION = "3.4.0.0";
/**
* The version of NFD native libraries.
*/
Expand All @@ -49,6 +53,24 @@ private OverrunGL() {
//no instance
}

/**
* {@return the actual version of OverrunGL from the jar file}
*/
public static String actualVersion() {
try {
final URL url = ((URLClassLoader) OverrunGL.class.getClassLoader()).findResource("META-INF/MANIFEST.MF");
if (url == null) {
return VERSION;
}
try (InputStream stream = url.openStream()) {
final String value = new Manifest(stream).getMainAttributes().getValue("Implementation-Version");
return value != null ? value : VERSION;
}
} catch (Exception e) {
return VERSION;
}
}

/**
* Sets the API logger.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import overrungl.OverrunGL;

import java.io.IOException;
import java.lang.foreign.Arena;
import java.lang.foreign.Linker;
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.SymbolLookup;
import java.lang.foreign.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
Expand All @@ -51,6 +48,10 @@ public final class RuntimeHelper {
public static final MemoryLayout LONG = CANONICAL_LAYOUTS.get("long"),
SIZE_T = CANONICAL_LAYOUTS.get("size_t"),
WCHAR_T = CANONICAL_LAYOUTS.get("wchar_t");
/**
* Is {@code size_t} of {@code long}?
*/
public static final boolean SIZE_T_LONG = SIZE_T instanceof ValueLayout.OfLong;

/**
* constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

import java.lang.foreign.*;
import java.lang.invoke.MethodHandle;
import java.util.Objects;

import static java.lang.foreign.FunctionDescriptor.of;
import static java.lang.foreign.ValueLayout.ADDRESS;
import static overrungl.internal.RuntimeHelper.SIZE_T;
import static overrungl.internal.RuntimeHelper.SIZE_T_LONG;

/**
* The standard-C memory allocator.
Expand Down Expand Up @@ -121,7 +121,8 @@ public static void checkAlignment(long alignment) throws IllegalArgumentExceptio
*/
public static MemorySegment malloc(long size) {
try {
final MemorySegment seg = ((MemorySegment) m_malloc.invokeExact(size)).reinterpret(size);
final MemorySegment seg = (SIZE_T_LONG ? (MemorySegment) m_malloc.invokeExact(size) : (MemorySegment) m_malloc.invokeExact(Math.toIntExact(size)))
.reinterpret(size);
if (DEBUG) DebugAllocator.track(seg.address(), size);
return seg;
} catch (Throwable e) {
Expand Down Expand Up @@ -155,7 +156,8 @@ public static MemorySegment malloc(MemoryLayout layout) {
public static MemorySegment calloc(long number, long size) {
try {
long byteSize = number * size;
final MemorySegment seg = ((MemorySegment) m_calloc.invokeExact(number, size)).reinterpret(byteSize);
final MemorySegment seg = (SIZE_T_LONG ? (MemorySegment) m_calloc.invokeExact(number, size) : (MemorySegment) m_calloc.invokeExact(Math.toIntExact(number), Math.toIntExact(size)))
.reinterpret(byteSize);
if (DEBUG) DebugAllocator.track(seg.address(), byteSize);
return seg;
} catch (Throwable e) {
Expand Down Expand Up @@ -215,9 +217,9 @@ public static MemorySegment realloc(@Nullable MemorySegment memblock, long size)
oldSize = DebugAllocator.untrack(ptr);
}
try {
MemorySegment segment = ((MemorySegment) m_realloc.invokeExact(
Objects.requireNonNullElse(memblock, MemorySegment.NULL),
size)).reinterpret(size);
final MemorySegment mem = memblock != null ? memblock : MemorySegment.NULL;
MemorySegment segment = (SIZE_T_LONG ? (MemorySegment) m_realloc.invokeExact(mem, size) : (MemorySegment) m_realloc.invokeExact(mem, Math.toIntExact(size)))
.reinterpret(size);
if (DEBUG) {
if (!isNullptr(segment)) {
DebugAllocator.track(segment.address(), size);
Expand Down Expand Up @@ -270,7 +272,7 @@ public static void free(@Nullable MemorySegment memblock) {
*/
public static MemorySegment memcpy(MemorySegment dest, MemorySegment src, long count) {
try {
final var _ = (MemorySegment) m_memcpy.invokeExact(dest, src, count);
final var _ = SIZE_T_LONG ? (MemorySegment) m_memcpy.invokeExact(dest, src, count) : (MemorySegment) m_memcpy.invokeExact(dest, src, Math.toIntExact(count));
return dest;
} catch (Throwable e) {
throw new AssertionError("should not reach here", e);
Expand All @@ -295,7 +297,7 @@ public static MemorySegment memcpy(MemorySegment dest, MemorySegment src, long c
*/
public static MemorySegment memmove(MemorySegment dest, MemorySegment src, long count) {
try {
final var _ = (MemorySegment) m_memmove.invokeExact(dest, src, count);
final var _ = SIZE_T_LONG ? (MemorySegment) m_memmove.invokeExact(dest, src, count) : (MemorySegment) m_memmove.invokeExact(dest, src, Math.toIntExact(count));
return dest;
} catch (Throwable e) {
throw new AssertionError("should not reach here", e);
Expand All @@ -318,7 +320,7 @@ public static MemorySegment memmove(MemorySegment dest, MemorySegment src, long
*/
public static MemorySegment memset(MemorySegment dest, int c, long count) {
try {
final var _ = (MemorySegment) m_memset.invokeExact(dest, c, count);
final var _ = SIZE_T_LONG ? (MemorySegment) m_memset.invokeExact(dest, c, count) : (MemorySegment) m_memset.invokeExact(dest, c, Math.toIntExact(count));
return dest;
} catch (Throwable e) {
throw new AssertionError("should not reach here", e);
Expand Down
Loading

0 comments on commit ace41e5

Please sign in to comment.