Skip to content

Commit

Permalink
Isolate LWJGL3 and redo renderer (#362)
Browse files Browse the repository at this point in the history
Co-authored-by: ev chang <[email protected]>
  • Loading branch information
Deftu and Wyvest authored Oct 20, 2024
1 parent e570e36 commit 77b1a77
Show file tree
Hide file tree
Showing 23 changed files with 1,072 additions and 765 deletions.
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ subprojects {
}
}

configure<QuiltLicenserGradleExtension> {
rule("${rootProject.rootDir}/FILEHEADER")
include("**/*.kt")
include("**/*.java")
}
// configure<QuiltLicenserGradleExtension> {
// rule("${rootProject.rootDir}/FILEHEADER")
// include("**/*.kt")
// include("**/*.java")
// }

configure<PublishingExtension> {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name=OneConfig
mod_id=oneconfig
version_major=1
version_minor=0
version_patch=0-alpha.21
version_patch=0-alpha.29

polyfrost.defaults.loom=3

Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ hypixel-modapi = "1.0"
lwjgl = "3.3.3"
universalcraft = "299"
mixin = "0.7.11-SNAPSHOT"
isolated-lwjgl3-loader = "0.1.1"

# Testing
junit-bom = "5.10.2"
Expand All @@ -32,6 +33,8 @@ junit-bom = { module = "org.junit:junit-bom", version.ref = "junit-bom" }

mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" }

isolated-lwjgl3-loader = { module = "org.polyfrost:isolated-lwjgl3-loader", version.ref = "isolated-lwjgl3-loader" }

hypixel-modapi = { module = "net.hypixel:mod-api", version.ref = "hypixel-modapi" }

polyui = { module = "org.polyfrost:polyui", version.ref = "polyui" }
Expand Down
3 changes: 3 additions & 0 deletions modules/dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ allprojects {

repositories {
mavenLocal()
maven("https://repo.polyfrost.org/snapshots")
}

dependencies {
Expand All @@ -21,4 +22,6 @@ dependencies {
api(libs.hypixel.modapi)

api(libs.bundles.nightconfig)

api(libs.isolated.lwjgl3.loader)
}
22 changes: 11 additions & 11 deletions modules/dependencies/legacy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ description = "Dependencies for legacy platforms (<1.12)"
val natives = listOf("windows", "windows-arm64", "linux", "macos", "macos-arm64")

dependencies {
for (dep in listOf("-nanovg", "-tinyfd", "-stb", "")) {
val lwjglDep = "org.lwjgl:lwjgl$dep:$lwjglVersion"
api(lwjglDep) {
isTransitive = false
}
for (native in natives) {
implementation("$lwjglDep:natives-$native") {
isTransitive = false
}
}
}
// for (dep in listOf("-nanovg", "-tinyfd", "-stb", "")) {
// val lwjglDep = "org.lwjgl:lwjgl$dep:$lwjglVersion"
// api(lwjglDep) {
// isTransitive = false
// }
// for (native in natives) {
// implementation("$lwjglDep:natives-$native") {
// isTransitive = false
// }
// }
// }
}

val build = project.tasks.getByName("build")
Expand Down
95 changes: 82 additions & 13 deletions modules/ui/api/ui.api
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,95 @@ public final class org/polyfrost/oneconfig/api/ui/v1/NotificationsManager$Type :

public final class org/polyfrost/oneconfig/api/ui/v1/OCPolyUIBuilder : org/polyfrost/polyui/utils/PolyUIBuilder {
public fun atResolution (FF)Lorg/polyfrost/oneconfig/api/ui/v1/OCPolyUIBuilder;
public fun blurs ()Lorg/polyfrost/oneconfig/api/ui/v1/OCPolyUIBuilder;
public static fun create ()Lorg/polyfrost/oneconfig/api/ui/v1/OCPolyUIBuilder;
public fun make ([Lorg/polyfrost/polyui/component/Drawable;)Lorg/polyfrost/polyui/PolyUI;
public fun makeAndOpen ([Lorg/polyfrost/polyui/component/Drawable;)Lorg/polyfrost/polyui/PolyUI;
public fun onClose (Ljava/lang/Runnable;)Lorg/polyfrost/oneconfig/api/ui/v1/OCPolyUIBuilder;
public fun onClose (Ljava/util/function/Consumer;)Lorg/polyfrost/oneconfig/api/ui/v1/OCPolyUIBuilder;
public fun pauses ()Lorg/polyfrost/oneconfig/api/ui/v1/OCPolyUIBuilder;
}

public abstract interface class org/polyfrost/oneconfig/api/ui/v1/TinyFD {
public abstract interface class org/polyfrost/oneconfig/api/ui/v1/UIManager {
public static final field INSTANCE Lorg/polyfrost/oneconfig/api/ui/v1/UIManager;
public fun createDefault ()Lorg/polyfrost/polyui/PolyUI;
public abstract fun createPolyUIScreen (Lorg/polyfrost/polyui/PolyUI;FFZZLjava/util/function/Consumer;)Ljava/lang/Object;
public abstract fun createWindow ()Lorg/polyfrost/polyui/renderer/Window;
public abstract fun getDefaultInstance ()Lorg/polyfrost/polyui/PolyUI;
public abstract fun getRenderer ()Lorg/polyfrost/polyui/renderer/Renderer;
public abstract fun getTinyFD ()Lorg/polyfrost/oneconfig/api/ui/v1/api/TinyFdApi;
}

public abstract interface class org/polyfrost/oneconfig/api/ui/v1/api/LwjglApi {
public abstract fun memAlloc (I)Ljava/nio/ByteBuffer;
}

public abstract interface class org/polyfrost/oneconfig/api/ui/v1/api/NanoVgApi {
public abstract fun beginFrame (FFF)V
public abstract fun beginPath ()V
public abstract fun boxGradient (JFFFFFFJJ)V
public abstract fun constants ()Lorg/polyfrost/oneconfig/api/ui/v1/api/NanoVgApi$NanoVgConstants;
public abstract fun createColor ()J
public abstract fun createFont (Ljava/lang/String;Ljava/nio/ByteBuffer;)I
public abstract fun createImage (FFLjava/nio/ByteBuffer;I)I
public abstract fun createPaint ()J
public abstract fun deleteImage (I)V
public abstract fun deleteSvg (J)V
public abstract fun endFrame ()V
public abstract fun fill ()V
public abstract fun fillColor (J)V
public abstract fun fillPaint (J)V
public abstract fun fontFaceId (I)V
public abstract fun fontSize (F)V
public abstract fun getPaintColor (J)J
public abstract fun globalAlpha (F)V
public abstract fun handle ()J
public abstract fun imagePattern (FFFFFIFJ)V
public abstract fun intersectScissor (FFFF)V
public abstract fun lineCap (I)V
public abstract fun lineJoin (I)V
public abstract fun lineTo (FF)V
public abstract fun linearGradient (JFFFFJJ)V
public abstract fun maybeSetup ()V
public abstract fun moveTo (FF)V
public abstract fun parseSvg (Ljava/nio/ByteBuffer;)Lkotlin/Triple;
public abstract fun pathWinding (I)V
public abstract fun radialGradient (JFFFFJJ)V
public abstract fun rasterizeSvg (JFFFLjava/nio/ByteBuffer;III)V
public abstract fun resetScissor ()V
public abstract fun restore ()V
public abstract fun rgba (JI)V
public abstract fun rotate (F)V
public abstract fun roundedRect (FFFFF)V
public abstract fun roundedRectVarying (FFFFFFFF)V
public abstract fun save ()V
public abstract fun scale (FF)V
public abstract fun scissor (FFFF)V
public abstract fun skewX (F)V
public abstract fun skewY (F)V
public abstract fun stroke ()V
public abstract fun strokeColor (J)V
public abstract fun strokePaint (J)V
public abstract fun strokeWidth (F)V
public abstract fun svgBounds (J)[F
public abstract fun svgHandle ()J
public abstract fun text (FFLjava/lang/String;)V
public abstract fun textAlign (I)V
public abstract fun textBounds (FFLjava/lang/String;[F)F
public abstract fun translate (FF)V
}

public abstract interface class org/polyfrost/oneconfig/api/ui/v1/api/NanoVgApi$NanoVgConstants {
public abstract fun NVG_ALIGN_LEFT ()I
public abstract fun NVG_ALIGN_TOP ()I
public abstract fun NVG_HOLE ()I
public abstract fun NVG_IMAGE_FLIPY ()I
public abstract fun NVG_ROUND ()I
}

public abstract interface class org/polyfrost/oneconfig/api/ui/v1/api/StbApi {
public abstract fun loadFromMemory (Ljava/nio/ByteBuffer;[I[I[II)Ljava/nio/ByteBuffer;
}

public abstract interface class org/polyfrost/oneconfig/api/ui/v1/api/TinyFdApi {
public static final field ERROR_ICON Ljava/lang/String;
public static final field INFO_ICON Ljava/lang/String;
public static final field OK_CANCEL_DIALOG Ljava/lang/String;
Expand All @@ -46,16 +125,6 @@ public abstract interface class org/polyfrost/oneconfig/api/ui/v1/TinyFD {
public abstract fun showNotification (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
}

public abstract interface class org/polyfrost/oneconfig/api/ui/v1/UIManager {
public static final field INSTANCE Lorg/polyfrost/oneconfig/api/ui/v1/UIManager;
public fun createDefault ()Lorg/polyfrost/polyui/PolyUI;
public abstract fun createPolyUIScreen (Lorg/polyfrost/polyui/PolyUI;FFZZLjava/util/function/Consumer;)Ljava/lang/Object;
public abstract fun createWindow ()Lorg/polyfrost/polyui/renderer/Window;
public abstract fun getDefaultInstance ()Lorg/polyfrost/polyui/PolyUI;
public abstract fun getRenderer ()Lorg/polyfrost/polyui/renderer/Renderer;
public abstract fun getTinyFD ()Lorg/polyfrost/oneconfig/api/ui/v1/TinyFD;
}

public final class org/polyfrost/oneconfig/api/ui/v1/keybind/BindNotInScreen : org/polyfrost/polyui/input/KeyBinder$Bind {
public synthetic fun <init> ([I[Lorg/polyfrost/polyui/input/Keys;[IBJLkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> ([I[Lorg/polyfrost/polyui/input/Keys;[IBJLkotlin/jvm/functions/Function1;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.polyfrost.oneconfig.api.event.v1.events.HudRenderEvent;
import org.polyfrost.oneconfig.api.event.v1.events.ResizeEvent;
import org.polyfrost.oneconfig.api.platform.v1.Platform;
import org.polyfrost.oneconfig.api.ui.v1.api.TinyFdApi;
import org.polyfrost.polyui.PolyUI;
import org.polyfrost.polyui.component.Component;
import org.polyfrost.polyui.Settings;
Expand Down Expand Up @@ -60,7 +61,7 @@ public interface UIManager {
* Return the TinyFD implementation instance. This interface specifies operations for opening native
* file dialogs, and showing notifications.
*/
TinyFD getTinyFD();
TinyFdApi getTinyFD();

/**
* Create a new window that is backed by this Minecraft instance. Returns accurate sizing and has cursor support on MC 1.13+.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.polyfrost.oneconfig.api.ui.v1.api;

import java.nio.ByteBuffer;

public interface LwjglApi {

ByteBuffer memAlloc(int size);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package org.polyfrost.oneconfig.api.ui.v1.api;

import kotlin.Triple;

import java.nio.ByteBuffer;

public interface NanoVgApi {

interface NanoVgConstants {

int NVG_ROUND();

int NVG_ALIGN_LEFT();

int NVG_ALIGN_TOP();

int NVG_HOLE();

int NVG_IMAGE_FLIPY();

}

NanoVgConstants constants();

long handle();
long svgHandle();

/**
* If this instance is not set up already, it will set up the instance (initializes it's NVG and NSVG context).
*
* @throws IllegalStateException if the instance failed to set up.
*
* @since 0.2.0
* @author Deftu
*/
void maybeSetup();

/**
* Starts a new frame.
*/
void beginFrame(float width, float height, float scale);

/**
* Ends the current frame.
*/
void endFrame();

void globalAlpha(float alpha);

void translate(float x, float y);

void scale(float x, float y);

void rotate(float angle);

void skewX(float angle);

void skewY(float angle);

void save();

void restore();

/**
* Creates a new NanoVG paint and returns the address.
*/
long createPaint();

/**
* Fills the paint with the item at the address.
*/
void fillPaint(long address);

long getPaintColor(long address);

long createColor();

void fillColor(long address);

void rgba(long address, int rgba);

void beginPath();

void pathWinding(int winding);

void fill();

void roundedRect(float x, float y, float w, float h, float r);

void roundedRectVarying(float x, float y, float w, float h, float tl, float tr, float br, float bl);

void lineJoin(int join);

void lineCap(int cap);

void stroke();

void strokeWidth(float width);

void strokePaint(long address);

void strokeColor(long address);

void moveTo(float x, float y);

void lineTo(float x, float y);

int createFont(String name, ByteBuffer buffer);

void fontSize(float size);

void fontFaceId(int id);

void textAlign(int align);

void text(float x, float y, String text);

float textBounds(float x, float y, String text, float[] bounds);

int createImage(float width, float height, ByteBuffer buffer, int flags);

void scissor(float x, float y, float w, float h);

void intersectScissor(float x, float y, float w, float h);

void resetScissor();

void imagePattern(float x, float y, float w, float h, float angle, int image, float alpha, long address);

void linearGradient(long address, float x0, float y0, float x1, float y1, long startColor, long endColor);

void radialGradient(long address, float cx, float cy, float inr, float outr, long startColor, long endColor);

void boxGradient(long address, float x, float y, float w, float h, float r, float f, long startColor, long endColor);

void deleteImage(int address);

float[] svgBounds(long address);

Triple<Long, Float, Float> parseSvg(ByteBuffer data);

void deleteSvg(long address);

void rasterizeSvg(long address, float x, float y, float scale, ByteBuffer data, int w, int h, int stride);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.polyfrost.oneconfig.api.ui.v1.api;

import java.nio.ByteBuffer;

public interface StbApi {

ByteBuffer loadFromMemory(ByteBuffer buffer, int[] widthOutput, int[] heightOutput, int[] channelsOutput, int desiredChannels);

}
Loading

0 comments on commit 77b1a77

Please sign in to comment.