Skip to content

Commit

Permalink
OSX Support (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seba244c authored Feb 22, 2024
1 parent 5cd1c7a commit 4520e88
Show file tree
Hide file tree
Showing 78 changed files with 55,516 additions and 823 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
* This file was generated by the Gradle 'init' task.
*/
import org.gradle.internal.os.OperatingSystem

plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
Expand All @@ -9,3 +7,9 @@ plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}

if(project.ext.os == OperatingSystem.MAC_OS) {
application {
applicationDefaultJvmArgs = ["-XstartOnFirstThread"]
}
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
/*
* This file was generated by the Gradle 'init' task.
*/

import org.gradle.internal.os.OperatingSystem

plugins {
// Apply the java Plugin to add support for Java.
id 'java'
}

ext {
lwjglVersion = "3.3.3"
imguiVersion = "1.86.10"
jomlVersion = "1.10.5"
}

// Supports Linux X64, Windows x64
if (!project.hasProperty('targetOS')) {
switch (OperatingSystem.current()) {
case OperatingSystem.LINUX:
project.ext.os = OperatingSystem.LINUX
break
case OperatingSystem.WINDOWS:
project.ext.os = OperatingSystem.WINDOWS
break
}
} else {
// Find out what the target os is
if (!project.hasProperty('targetOS')) project.ext.os = OperatingSystem.current()
else {
if (targetOS.equalsIgnoreCase("linux")) project.ext.os = OperatingSystem.LINUX
else if (targetOS.equalsIgnoreCase("windows") || os.equalsIgnoreCase("win")) project.ext.os = OperatingSystem.WINDOWS
else if (targetOS.equalsIgnoreCase("macos") || os.equalsIgnoreCase("osx")) project.ext.os = OperatingSystem.MAC_OS
}

switch (project.ext.os) {
case OperatingSystem.LINUX:
project.ext.lwjglNatives = "natives-linux"
project.ext.imguiNatives = "natives-linux"
break
case OperatingSystem.WINDOWS:
project.ext.lwjglNatives = "natives-windows"
project.ext.imguiNatives = "natives-windows"
break
case OperatingSystem.MAC_OS:
project.ext.imguiNatives = "natives-macos"
project.ext.lwjglNatives = project.ext.os.properties.get("arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
break
}

Expand All @@ -51,14 +40,18 @@ repositories {
name "spellbookRepositorySnapshots"
url "https://maven.sebsa.dk/snapshots"
}
maven {
name "realrobotixImguiJava"
url "https://maven.realrobotix.me/imgui-java"
}
}

dependencies {
implementation 'dk.sebsa:mana:1.0d-SNAPSHOT'
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
implementation "dk.sebsa:mana:${rootProject.ext.manaVersion}"
compileOnly "org.projectlombok:lombok:${rootProject.ext.lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${rootProject.ext.lombokVersion}"

implementation "org.joml:joml:${jomlVersion}"
implementation "org.joml:joml:${rootProject.ext.jomlVersion}"

// LWJGL
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
Expand All @@ -70,7 +63,7 @@ dependencies {

implementation "io.github.spair:imgui-java-binding:$imguiVersion"
implementation "io.github.spair:imgui-java-lwjgl3:$imguiVersion"
implementation "io.github.spair:imgui-java-$lwjglNatives:$imguiVersion"
implementation "io.github.spair:imgui-java-$imguiNatives:$imguiVersion"

// https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform
implementation 'net.java.dev.jna:jna-platform:5.13.0'
Expand All @@ -93,5 +86,5 @@ tasks.withType(JavaCompile).configureEach {
compileJava {
sourceCompatibility = '1.21'
targetCompatibility = '1.21'
options.release = targetJavaVersion;
options.release = targetJavaVersion
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dk.sebsa.spellbook.core.events.EngineBuildRenderPipelineEvent;
import dk.sebsa.spellbook.core.events.EventListener;
import dk.sebsa.spellbook.math.Color;
import dk.sebsa.spellbook.opengl.stages.SpriteStage;
import dk.sebsa.spellbook.graphics.opengl.stages.SpriteStage;

import java.io.File;

Expand Down
4 changes: 2 additions & 2 deletions demos/tappy/src/main/java/dk/sebsa/Tappy.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import dk.sebsa.spellbook.ecs.Entity;
import dk.sebsa.spellbook.math.Color;
import dk.sebsa.spellbook.math.Time;
import dk.sebsa.spellbook.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.opengl.stages.SpriteStage;
import dk.sebsa.spellbook.graphics.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.graphics.opengl.stages.SpriteStage;
import dk.sebsa.spellbook.phys.components.BoxCollider2D;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dk.sebsa.spellbook.ecs.Component;
import dk.sebsa.spellbook.ecs.Entity;
import dk.sebsa.spellbook.math.Time;
import dk.sebsa.spellbook.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.graphics.opengl.components.SpriteRenderer;

public class BGManager extends Component {
public static final float BGSCALE = 0.5f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dk.sebsa.spellbook.FrameData;
import dk.sebsa.spellbook.math.Time;
import dk.sebsa.spellbook.math.Vector3f;
import dk.sebsa.spellbook.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.graphics.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.phys.components.Collider2D;
import dk.sebsa.spellbook.phys.components.SpriteCollider2D;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dk.sebsa.spellbook.ecs.Component;
import dk.sebsa.spellbook.ecs.Entity;
import dk.sebsa.spellbook.math.Time;
import dk.sebsa.spellbook.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.graphics.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.util.Random;

public class PipesManager extends Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dk.sebsa.spellbook.FrameData;
import dk.sebsa.spellbook.math.Time;
import dk.sebsa.spellbook.math.Vector3f;
import dk.sebsa.spellbook.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.graphics.opengl.components.SpriteRenderer;
import dk.sebsa.spellbook.phys.components.Collider2D;
import dk.sebsa.spellbook.phys.components.SpriteCollider2D;
import org.lwjgl.glfw.GLFW;
Expand Down
10 changes: 5 additions & 5 deletions demos/tappy/src/main/java/dk/sebsa/layers/DeathScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dk.sebsa.spellbook.core.events.Event;
import dk.sebsa.spellbook.core.events.Layer;
import dk.sebsa.spellbook.core.events.UserEvent;
import dk.sebsa.spellbook.io.KeyPressedEvent;
import dk.sebsa.spellbook.io.events.KeyPressedEvent;
import dk.sebsa.spellbook.marble.FontType;
import dk.sebsa.spellbook.marble.Marble;
import dk.sebsa.spellbook.marble.MarbleIMRenderer;
Expand All @@ -29,12 +29,12 @@ protected void userEvent(UserEvent event) {
@Override
protected void render(Marble marble, Rect r) {
if (titleRenderer == null) titleRenderer = marble.getMarbleIM(
marble.font((FontType) AssetManager.getAssetS(new Identifier("tappy", "SAOWelcomeTT-Bold.ttf")), 82),
marble.font(new Identifier("tappy", "SAOWelcomeTT-Bold.ttf"), 82),
null,
null);
if (otherRenderer == null) otherRenderer = marble.getMarbleIM(marble.font("Inter", 24), null, null);
titleRenderer.label("You Died", (r.width / 2) - ((float) titleRenderer.getFont().getStringWidth("You Died") / 2), 20);
if (otherRenderer == null) otherRenderer = marble.getMarbleIM(marble.font(new Identifier("spellbook", "fonts/Inter.ttf"), 24), null, null);
titleRenderer.label("You Died", new Rect(0,20,r.width,124));

otherRenderer.label("Press SPACE to restart", (r.width / 2) - ((float) otherRenderer.getFont().getStringWidth("Press SPACE to restart") / 2), 124);
otherRenderer.label("Press SPACE to restart", new Rect(0,124,r.width,242));
}
}
10 changes: 5 additions & 5 deletions demos/tappy/src/main/java/dk/sebsa/layers/MainMenuScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dk.sebsa.spellbook.core.events.Event;
import dk.sebsa.spellbook.core.events.Layer;
import dk.sebsa.spellbook.core.events.UserEvent;
import dk.sebsa.spellbook.io.KeyPressedEvent;
import dk.sebsa.spellbook.io.events.KeyPressedEvent;
import dk.sebsa.spellbook.marble.FontType;
import dk.sebsa.spellbook.marble.Marble;
import dk.sebsa.spellbook.marble.MarbleIMRenderer;
Expand All @@ -28,12 +28,12 @@ protected void userEvent(UserEvent event) {
@Override
protected void render(Marble marble, Rect r) {
if (titleRenderer == null) titleRenderer = marble.getMarbleIM(
marble.font((FontType) AssetManager.getAssetS(new Identifier("tappy", "SAOWelcomeTT-Bold.ttf")), 82),
marble.font(new Identifier("tappy", "SAOWelcomeTT-Bold.ttf"), 82),
null,
null);
if (otherRenderer == null) otherRenderer = marble.getMarbleIM(marble.font("Inter", 24), null, null);
titleRenderer.label("Tappy Bird", (r.width / 2) - ((float) titleRenderer.getFont().getStringWidth("Tappy Bird") / 2) - 23, 20);
if (otherRenderer == null) otherRenderer = marble.getMarbleIM(marble.font(new Identifier("spellbook", "fonts/Inter.ttf"), 24), null, null);
titleRenderer.labelCenterH("Tappy Bird", new Rect(0,20,r.width,124));

otherRenderer.label("Press SPACE to jump", (r.width / 2) - ((float) otherRenderer.getFont().getStringWidth("Press SPACE to jump") / 2) - 23, 124);
otherRenderer.labelCenterH("Press SPACE to jump", new Rect(0,124,r.width,242));
}
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
lwjglVersion=3.3.3
jomlVersion=1.10.5
imguiVersion=1.86.11-10-g0dbf36c
lombokVersion=1.18.30
manaVersion=1.0d-SNAPSHOT
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading

0 comments on commit 4520e88

Please sign in to comment.