Latest Changes
This commit is contained in:
parent
02b1aab8f3
commit
bc078abea4
14
.classpath
14
.classpath
@ -12,7 +12,19 @@
|
|||||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
|
<classpathentry kind="src" output="bin/graphics" path="src/graphics/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="graphics"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="graphics"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="bin/graphics" path="src/graphics/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="graphics"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="graphics"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25/"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
<classpathentry kind="output" path="bin/default"/>
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
arguments=
|
arguments=
|
||||||
auto.sync=false
|
auto.sync=false
|
||||||
build.scans.enabled=false
|
build.scans.enabled=false
|
||||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(9.1.0))
|
||||||
connection.project.dir=
|
connection.project.dir=
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
gradle.user.home=
|
gradle.user.home=
|
||||||
java.home=C\:/Program Files/Eclipse Adoptium/jdk-21.0.1.12-hotspot
|
java.home=C\:/Program Files/Java/jdk-25.0.2+10
|
||||||
jvm.arguments=
|
jvm.arguments=
|
||||||
offline.mode=false
|
offline.mode=false
|
||||||
override.workspace.settings=true
|
override.workspace.settings=true
|
||||||
|
|||||||
72
build.gradle
72
build.gradle
@ -1,6 +1,8 @@
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
|
|
||||||
|
java.toolchain.languageVersion = JavaLanguageVersion.of(25)
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
}
|
}
|
||||||
@ -12,7 +14,14 @@ eclipse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(21)
|
sourceSets {
|
||||||
|
graphics {}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
graphics.extendsFrom implementation
|
||||||
|
graphics.extendsFrom runtime
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -23,34 +32,6 @@ repositories {
|
|||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
}
|
}
|
||||||
|
|
||||||
task srcJar(type: Jar) {
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
archiveClassifier = 'sources'
|
|
||||||
from {
|
|
||||||
configurations.runtimeClasspath.collect {
|
|
||||||
it.isDirectory() ? it : zipTree(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
archives srcJar
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes "Main-Class": 'speiger.src.coreengine.NewInputTest'
|
|
||||||
}
|
|
||||||
from {
|
|
||||||
configurations.runtimeClasspath.collect {
|
|
||||||
it.isDirectory() ? it : zipTree(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exclude('**/*.LIST')
|
|
||||||
exclude('**/module-info.class')
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
//LWJGL 3
|
//LWJGL 3
|
||||||
@ -77,11 +58,38 @@ dependencies {
|
|||||||
implementation "org.lwjgl:lwjgl-harfbuzz::$lwjglNatives"
|
implementation "org.lwjgl:lwjgl-harfbuzz::$lwjglNatives"
|
||||||
implementation "org.lwjgl:lwjgl-nanovg::$lwjglNatives"
|
implementation "org.lwjgl:lwjgl-nanovg::$lwjglNatives"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Gson
|
//Gson
|
||||||
implementation 'com.google.code.gson:gson:2.8.6'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
|
|
||||||
//Primitive Collections
|
//Primitive Collections
|
||||||
implementation 'de.speiger:Primitive-Collections:0.9.0'
|
implementation 'de.speiger:Primitive-Collections:1.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
manifest {
|
||||||
|
attributes "Main-Class": 'speiger.src.coreengine.NewInputTest'
|
||||||
|
}
|
||||||
|
from {
|
||||||
|
configurations.runtimeClasspath.collect {
|
||||||
|
it.isDirectory() ? it : zipTree(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exclude('**/*.LIST')
|
||||||
|
exclude('**/module-info.class')
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
|
||||||
|
task srcJar(type: Jar) {
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
archiveClassifier = 'sources'
|
||||||
|
from {
|
||||||
|
configurations.runtimeClasspath.collect {
|
||||||
|
it.isDirectory() ? it : zipTree(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives srcJar
|
||||||
|
}
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
package speiger.src.coreengine.api.buffer;
|
||||||
|
|
||||||
|
public interface VertexBuffer {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package speiger.src.coreengine.api.core;
|
||||||
|
|
||||||
|
import speiger.src.coreengine.rendering.input.window.Window;
|
||||||
|
|
||||||
|
public interface Graphics {
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
public GraphicsDevice createDevice(Window window);
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package speiger.src.coreengine.api.core;
|
||||||
|
|
||||||
|
public interface GraphicsCommandQueue {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package speiger.src.coreengine.api.core;
|
||||||
|
|
||||||
|
import speiger.src.coreengine.api.buffer.VertexBuffer;
|
||||||
|
import speiger.src.coreengine.api.texture.Texture;
|
||||||
|
import speiger.src.coreengine.rendering.input.window.Window;
|
||||||
|
|
||||||
|
public interface GraphicsDevice {
|
||||||
|
public GraphicsSurface createSurface(Window window);
|
||||||
|
public GraphicsCommandQueue getQueue();
|
||||||
|
public VertexBuffer createBuffer();
|
||||||
|
public Texture createTexture();
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package speiger.src.coreengine.api.core;
|
||||||
|
|
||||||
|
public interface GraphicsResource {
|
||||||
|
public void remove();
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package speiger.src.coreengine.api.core;
|
||||||
|
|
||||||
|
public interface GraphicsSurface {
|
||||||
|
public void setVsync(boolean value);
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package speiger.src.coreengine.api.texture;
|
||||||
|
|
||||||
|
public abstract class Texture {
|
||||||
|
protected final TextureType type = null;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package speiger.src.coreengine.api.texture;
|
||||||
|
|
||||||
|
public enum TextureType {
|
||||||
|
TEXTURE_1D,
|
||||||
|
TEXTURE_1D_ARRAY,
|
||||||
|
TEXTURE_2D,
|
||||||
|
TEXTURE_2D_ARRAY,
|
||||||
|
TEXTURE_2D_MULTISAMPLE,
|
||||||
|
TEXTURE_2D_MULTISAMPLE_ARRAY,
|
||||||
|
TEXTURE_3D,
|
||||||
|
TEXTURE_CUBE_MAP,
|
||||||
|
TEXTURE_CUBE_MAP_ARRAY,
|
||||||
|
TEXTURE_RECTANGLE,
|
||||||
|
TEXTURE_BUFFER;
|
||||||
|
}
|
||||||
@ -28,6 +28,7 @@ import speiger.src.coreengine.rendering.input.devices.Joystick;
|
|||||||
import speiger.src.coreengine.rendering.input.devices.Keyboard;
|
import speiger.src.coreengine.rendering.input.devices.Keyboard;
|
||||||
import speiger.src.coreengine.rendering.input.devices.Mouse;
|
import speiger.src.coreengine.rendering.input.devices.Mouse;
|
||||||
import speiger.src.coreengine.rendering.input.events.KeyEvent;
|
import speiger.src.coreengine.rendering.input.events.KeyEvent;
|
||||||
|
import speiger.src.coreengine.rendering.input.events.MouseEvent;
|
||||||
import speiger.src.coreengine.rendering.input.window.Window;
|
import speiger.src.coreengine.rendering.input.window.Window;
|
||||||
import speiger.src.coreengine.rendering.input.window.WindowManager;
|
import speiger.src.coreengine.rendering.input.window.WindowManager;
|
||||||
import speiger.src.coreengine.rendering.models.buffers.BufferAttribute;
|
import speiger.src.coreengine.rendering.models.buffers.BufferAttribute;
|
||||||
@ -42,7 +43,6 @@ import speiger.src.coreengine.rendering.tesselation.format.VertexTypes;
|
|||||||
import speiger.src.coreengine.rendering.textures.custom.Drawable;
|
import speiger.src.coreengine.rendering.textures.custom.Drawable;
|
||||||
import speiger.src.coreengine.rendering.textures.custom.DynamicTexture;
|
import speiger.src.coreengine.rendering.textures.custom.DynamicTexture;
|
||||||
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
||||||
import speiger.src.coreengine.rendering.utils.values.GLBlendFactor;
|
|
||||||
import speiger.src.coreengine.rendering.utils.values.GLDataType;
|
import speiger.src.coreengine.rendering.utils.values.GLDataType;
|
||||||
import speiger.src.coreengine.rendering.utils.values.GLMode;
|
import speiger.src.coreengine.rendering.utils.values.GLMode;
|
||||||
import speiger.src.coreengine.rendering.utils.values.textures.GLTextureFormat;
|
import speiger.src.coreengine.rendering.utils.values.textures.GLTextureFormat;
|
||||||
@ -78,6 +78,9 @@ public class NewInputTest {
|
|||||||
FileDrop.INSTANCE.init(bus);
|
FileDrop.INSTANCE.init(bus);
|
||||||
manager.addDevices(Mouse.INSTANCE, Keyboard.INSTANCE, Joystick.INSTANCE, FileDrop.INSTANCE);
|
manager.addDevices(Mouse.INSTANCE, Keyboard.INSTANCE, Joystick.INSTANCE, FileDrop.INSTANCE);
|
||||||
Window window = manager.builder().title("Testing Engine").width(800).height(600).antialis(0).build();
|
Window window = manager.builder().title("Testing Engine").width(800).height(600).antialis(0).build();
|
||||||
|
Window secondWindow = manager.builder().title("Second Window Engine").width(800).height(600).antialis(0).build();
|
||||||
|
Thread.ofPlatform().start(() -> drawSecondScreen(secondWindow));
|
||||||
|
window.setupContext();
|
||||||
shaderTest.register();
|
shaderTest.register();
|
||||||
guiShader.register();
|
guiShader.register();
|
||||||
assets.addListener(GLStateTracker.instance().shaders);
|
assets.addListener(GLStateTracker.instance().shaders);
|
||||||
@ -102,6 +105,10 @@ public class NewInputTest {
|
|||||||
texture.fill(0, half, half, half, 0, 0, 255, 255);
|
texture.fill(0, half, half, half, 0, 0, 255, 255);
|
||||||
texture.process(true);
|
texture.process(true);
|
||||||
window.visible(true);
|
window.visible(true);
|
||||||
|
|
||||||
|
bus.register(MouseEvent.Click.class, T -> {
|
||||||
|
System.out.println("Testing: Button="+T.button()+", Click="+T.press()+", X="+T.x()+", Y="+T.y()+", WindowId="+T.windowId()+", WindowName="+manager.getWindow(T.windowId()).title());
|
||||||
|
});
|
||||||
bus.register(KeyEvent.Key.class, T -> {
|
bus.register(KeyEvent.Key.class, T -> {
|
||||||
if(T.key() == GLFW.GLFW_KEY_T) {
|
if(T.key() == GLFW.GLFW_KEY_T) {
|
||||||
T.cancel();
|
T.cancel();
|
||||||
@ -138,15 +145,15 @@ public class NewInputTest {
|
|||||||
builder.pos(-0.5F, 0.5F, 0).tex(0F, 0F).rgba(-1).endVertex();
|
builder.pos(-0.5F, 0.5F, 0).tex(0F, 0F).rgba(-1).endVertex();
|
||||||
builder.pos(-0.5F, -0.5F, 0).tex(0F, 1F).rgba(-1).endVertex();
|
builder.pos(-0.5F, -0.5F, 0).tex(0F, 1F).rgba(-1).endVertex();
|
||||||
|
|
||||||
Font font = fonts.createFont(1F);
|
// Font font = fonts.createFont(1F);
|
||||||
TestModel model = new TestModel(builder.getBytes());
|
TestModel model = new TestModel(builder.getBytes());
|
||||||
TestModel[] guiModel = new TestModel[1];
|
// TestModel[] guiModel = new TestModel[1];
|
||||||
List<GLDraw> draws = new ObjectArrayList<>();
|
// List<GLDraw> draws = new ObjectArrayList<>();
|
||||||
TexturedBuffer buffer = new TexturedBuffer((K, V) -> {
|
// TexturedBuffer buffer = new TexturedBuffer((K, V) -> {
|
||||||
draws.addAll(K);
|
// draws.addAll(K);
|
||||||
guiModel[0] = new TestModel(V);
|
// guiModel[0] = new TestModel(V);
|
||||||
System.out.println("Testing: "+V.length+" bytes, "+K.size());
|
// System.out.println("Testing: "+V.length+" bytes, "+K.size());
|
||||||
});
|
// });
|
||||||
|
|
||||||
// String s = "The Quick brown fox Jumps over the Lazy dog";
|
// String s = "The Quick brown fox Jumps over the Lazy dog";
|
||||||
float x = 50;
|
float x = 50;
|
||||||
@ -154,15 +161,79 @@ public class NewInputTest {
|
|||||||
float scale = 1F;
|
float scale = 1F;
|
||||||
y /= scale;
|
y /= scale;
|
||||||
TextStyle style = TextStyle.DEFAULT.size(12).bold(false);
|
TextStyle style = TextStyle.DEFAULT.size(12).bold(false);
|
||||||
font.drawText(style, "Testing My Theory", x, y, -1, buffer, scale, true);
|
// font.drawText(style, "Testing My Theory", x, y, -1, buffer, scale, true);
|
||||||
// float offset = font.drawText(style, "The Quick ", 50, y, -1, buffer, scale, false);
|
// float offset = font.drawText(style, "The Quick ", 50, y, -1, buffer, scale, false);
|
||||||
// offset += font.drawText(style, "Brown ", 50+offset, y, -1, buffer, scale, false);
|
// offset += font.drawText(style, "Brown ", 50+offset, y, -1, buffer, scale, false);
|
||||||
// offset += font.drawText(style, "§<c=0x24FF00FF>F§<c=r>ox ", 50+offset, y, -1, buffer, scale, false);
|
// offset += font.drawText(style, "§<c=0x24FF00FF>F§<c=r>ox ", 50+offset, y, -1, buffer, scale, false);
|
||||||
// offset += font.drawText(style, "Jumps ", 50+offset, y, -1, buffer, scale, false);
|
// offset += font.drawText(style, "Jumps ", 50+offset, y, -1, buffer, scale, false);
|
||||||
// offset += font.drawText(style, "over the Lazy dog", 50+offset, y, -1, buffer, scale, true);
|
// offset += font.drawText(style, "over the Lazy dog", 50+offset, y, -1, buffer, scale, true);
|
||||||
// font.drawText(s, 50, 50, -1, buffer, true);
|
// font.drawText(s, 50, 50, -1, buffer, true);
|
||||||
GLStateTracker tracker = GLStateTracker.instance();
|
GLStateTracker tracker = GLStateTracker.instance();
|
||||||
GL11.glClearColor(0.2F, 0.55F, 0.66F, 1F);
|
GL11.glClearColor(0.2F, 0.55F, 0.66F, 1F);
|
||||||
|
while(!window.shouldClose()) {
|
||||||
|
GLFW.glfwPollEvents();
|
||||||
|
if(window.changed()) {
|
||||||
|
window.updateViewport();
|
||||||
|
applyWindowSize(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.beginFrame();
|
||||||
|
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||||
|
texture.bind();
|
||||||
|
shaderTest.bind();
|
||||||
|
model.bindArray();
|
||||||
|
GLStateTracker.drawArrays(GLMode.TRIANGLES.glValue(), 6);
|
||||||
|
model.unbindArray();
|
||||||
|
// guiModel[0].bindArray();
|
||||||
|
// guiShader.bind();
|
||||||
|
// tracker.blend.enable();
|
||||||
|
// tracker.blend.setFunction(GLBlendFactor.SRC_ALPHA, GLBlendFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
|
// for(GLDraw draw : draws) {
|
||||||
|
// tracker.textures.bind(draw.texture());
|
||||||
|
// GLStateTracker.drawArrays(GLMode.TRIANGLES.glValue(), draw.startVertex(), draw.vertexCount());
|
||||||
|
// }
|
||||||
|
// GLStateTracker.instance().blend.disable();
|
||||||
|
// guiModel[0].unbindArray();
|
||||||
|
|
||||||
|
window.handleInput();
|
||||||
|
window.finishFrame();
|
||||||
|
try { Thread.sleep(100); }
|
||||||
|
catch(InterruptedException e) { e.printStackTrace(); }
|
||||||
|
}
|
||||||
|
window.destroy();
|
||||||
|
manager.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawSecondScreen(Window window) {
|
||||||
|
window.setupContext();
|
||||||
|
assets.addListener(GLStateTracker.instance().shaders);
|
||||||
|
Shader<TestShader> secondShader = Shader.createAndRegister(TestShader::new);
|
||||||
|
|
||||||
|
guiShader.register();
|
||||||
|
window.visible(true);
|
||||||
|
GL11.glClearColor(0.4F, 0.55F, 0.36F, 1F);
|
||||||
|
int size = 512;
|
||||||
|
int half = size >> 1;
|
||||||
|
int base = size >> 3;
|
||||||
|
|
||||||
|
DynamicTexture texture = new DynamicTexture(size, size, DynamicTexture.DEFAULT_PARAMETERS);
|
||||||
|
texture.fill(0, 0, size, size, -1);
|
||||||
|
texture.fill(0, 0, half, half, 255, 0, 0, 255);
|
||||||
|
texture.fill(half, 0, half, half, 0, 255, 0, 255);
|
||||||
|
texture.fill(half, half, half, half, 255, 0, 0, 255);
|
||||||
|
texture.fill(0, half, half, half, 0, 0, 255, 255);
|
||||||
|
texture.process(true);
|
||||||
|
|
||||||
|
VertexBuilder builder = new VertexBuilder(255);
|
||||||
|
builder.start(GLMode.TRIANGLES, VertexTypes.TESTING);
|
||||||
|
builder.pos(-0.5F, -0.5F, 0).tex(0F, 1F).rgba(-1).endVertex();
|
||||||
|
builder.pos(0.5F, -0.5F, 0).tex(1F, 1F).rgba(-1).endVertex();
|
||||||
|
builder.pos(0.5F, 0.5F, 0).tex(1F, 0F).rgba(-1).endVertex();
|
||||||
|
builder.pos(0.5F, 0.5F, 0).tex(1F, 0F).rgba(-1).endVertex();
|
||||||
|
builder.pos(-0.5F, 0.5F, 0).tex(0F, 0F).rgba(-1).endVertex();
|
||||||
|
builder.pos(-0.5F, -0.5F, 0).tex(0F, 1F).rgba(-1).endVertex();
|
||||||
|
|
||||||
|
TestModel model = new TestModel(builder.getBytes());
|
||||||
while(!window.shouldClose()) {
|
while(!window.shouldClose()) {
|
||||||
GLFW.glfwPollEvents();
|
GLFW.glfwPollEvents();
|
||||||
if(window.changed()) {
|
if(window.changed()) {
|
||||||
@ -172,32 +243,17 @@ public class NewInputTest {
|
|||||||
window.beginFrame();
|
window.beginFrame();
|
||||||
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
|
||||||
texture.bind();
|
texture.bind();
|
||||||
shaderTest.bind();
|
secondShader.bind();
|
||||||
model.bindArray();
|
model.bindArray();
|
||||||
GLStateTracker.drawArrays(GLMode.TRIANGLES.glValue(), 6);
|
GLStateTracker.drawArrays(GLMode.TRIANGLES.glValue(), 6);
|
||||||
model.unbindArray();
|
model.unbindArray();
|
||||||
guiModel[0].bindArray();
|
|
||||||
guiShader.bind();
|
|
||||||
tracker.blend.enable();
|
|
||||||
tracker.blend.setFunction(GLBlendFactor.SRC_ALPHA, GLBlendFactor.ONE_MINUS_SRC_ALPHA);
|
|
||||||
for(GLDraw draw : draws) {
|
|
||||||
tracker.textures.bind(draw.texture());
|
|
||||||
GLStateTracker.drawArrays(GLMode.TRIANGLES.glValue(), draw.startVertex(), draw.vertexCount());
|
|
||||||
}
|
|
||||||
GLStateTracker.instance().blend.disable();
|
|
||||||
guiModel[0].unbindArray();
|
|
||||||
// NanoVG.nvgBeginFrame(vg, window.width(), window.height(), 1F);
|
|
||||||
// NanoVG.nvgFontSize(vg, 64);
|
|
||||||
// NanoVG.nvgText(vg, 50, 520, "Testing My Theory");
|
|
||||||
// NanoVG.nvgEndFrame(vg);
|
|
||||||
|
|
||||||
window.handleInput();
|
window.handleInput();
|
||||||
window.finishFrame();
|
window.finishFrame();
|
||||||
try { Thread.sleep(100); }
|
try { Thread.sleep(100); }
|
||||||
catch(InterruptedException e) { e.printStackTrace(); }
|
catch(InterruptedException e) { e.printStackTrace(); }
|
||||||
}
|
}
|
||||||
window.destroy();
|
window.destroy();
|
||||||
manager.destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TexturedBuffer implements Font.TexturedBuffer {
|
public static class TexturedBuffer implements Font.TexturedBuffer {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public class PackReloadingTask {
|
|||||||
syncStep.complete(new Object());
|
syncStep.complete(new Object());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return syncStep.thenCombine(currentStep, (k, v) -> value);
|
return syncStep.thenCombine(currentStep, (_, _) -> value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public sealed interface IListableComponent permits GuiComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public default GuiComponent addListener(Runnable runnable, int index) {
|
public default GuiComponent addListener(Runnable runnable, int index) {
|
||||||
return addListener(T -> runnable.run(), index);
|
return addListener(_ -> runnable.run(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public default GuiComponent removeUserActionListener(Consumer<GuiComponent> listener) {
|
public default GuiComponent removeUserActionListener(Consumer<GuiComponent> listener) {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import speiger.src.coreengine.math.vector.matrix.Matrix4f;
|
|||||||
import speiger.src.coreengine.math.vector.matrix.Matrix4fStack;
|
import speiger.src.coreengine.math.vector.matrix.Matrix4fStack;
|
||||||
import speiger.src.coreengine.math.vector.quaternion.Quaternion;
|
import speiger.src.coreengine.math.vector.quaternion.Quaternion;
|
||||||
import speiger.src.coreengine.rendering.guiOld.helper.box.IGuiBox;
|
import speiger.src.coreengine.rendering.guiOld.helper.box.IGuiBox;
|
||||||
|
import speiger.src.coreengine.rendering.input.window.Window;
|
||||||
import speiger.src.coreengine.rendering.models.DrawCall;
|
import speiger.src.coreengine.rendering.models.DrawCall;
|
||||||
import speiger.src.coreengine.rendering.tesselation.buffer.VertexBuilder;
|
import speiger.src.coreengine.rendering.tesselation.buffer.VertexBuilder;
|
||||||
import speiger.src.coreengine.rendering.tesselation.format.VertexFormat;
|
import speiger.src.coreengine.rendering.tesselation.format.VertexFormat;
|
||||||
@ -26,8 +27,13 @@ public class SimpleUIRenderer implements IUIRenderer, AutoCloseable {
|
|||||||
List<UIDrawCall> drawCalls = new ObjectArrayList<>();
|
List<UIDrawCall> drawCalls = new ObjectArrayList<>();
|
||||||
VertexBuilder builder = new VertexBuilder(Short.MAX_VALUE);
|
VertexBuilder builder = new VertexBuilder(Short.MAX_VALUE);
|
||||||
ScissorsManager manager = new ScissorsManager(32);
|
ScissorsManager manager = new ScissorsManager(32);
|
||||||
|
Window window;
|
||||||
|
|
||||||
|
|
||||||
|
public SimpleUIRenderer(Window window) {
|
||||||
|
this.window = window;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
builder.close();
|
builder.close();
|
||||||
|
|||||||
@ -485,7 +485,7 @@ public class GuiScreenBase extends GuiBase
|
|||||||
@Override
|
@Override
|
||||||
public boolean isComponentInFront(GuiComponent comp)
|
public boolean isComponentInFront(GuiComponent comp)
|
||||||
{
|
{
|
||||||
if(!hasFocus() || renderOrder.last() == comp || (renderOrder.last() instanceof IButtonComponent && ((IButtonComponent)renderOrder.last()).isPopup()))
|
if(!hasFocus() || renderOrder.getLast() == comp || (renderOrder.getLast() instanceof IButtonComponent && ((IButtonComponent)renderOrder.getLast()).isPopup()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,11 +181,11 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
|
|||||||
{
|
{
|
||||||
if(selectionMode == SELECTION_MODE_MULTI && Keyboard.isShiftDown())
|
if(selectionMode == SELECTION_MODE_MULTI && Keyboard.isShiftDown())
|
||||||
{
|
{
|
||||||
for(int i = selectedIndexes.lastInt();i<index;i++)
|
for(int i = selectedIndexes.getLastInt();i<index;i++)
|
||||||
{
|
{
|
||||||
selectedIndexes.add(i);
|
selectedIndexes.add(i);
|
||||||
}
|
}
|
||||||
for(int i = selectedIndexes.lastInt();i>index;i--)
|
for(int i = selectedIndexes.getLastInt();i>index;i--)
|
||||||
{
|
{
|
||||||
selectedIndexes.add(i);
|
selectedIndexes.add(i);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -144,8 +144,14 @@ public class Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginFrame() {
|
public void setupContext() {
|
||||||
|
GL.setCapabilities(capabilities);
|
||||||
GLFW.glfwMakeContextCurrent(id);
|
GLFW.glfwMakeContextCurrent(id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beginFrame() {
|
||||||
|
setupContext();
|
||||||
if(flags.isFlagSet(WINDOW_CHANGE)) updateViewport();
|
if(flags.isFlagSet(WINDOW_CHANGE)) updateViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public class Mouse
|
|||||||
window.addCallback(T -> GLFW.glfwSetCursorPosCallback(T, Mouse.this::onDrag));
|
window.addCallback(T -> GLFW.glfwSetCursorPosCallback(T, Mouse.this::onDrag));
|
||||||
window.addCallback(T -> GLFW.glfwSetMouseButtonCallback(T, Mouse.this::onClick));
|
window.addCallback(T -> GLFW.glfwSetMouseButtonCallback(T, Mouse.this::onClick));
|
||||||
window.addCallback(T -> GLFW.glfwSetScrollCallback(T, Mouse.this::onScroll));
|
window.addCallback(T -> GLFW.glfwSetScrollCallback(T, Mouse.this::onScroll));
|
||||||
window.addCallback(T -> GLFW.glfwSetCursorEnterCallback(T, (K, V) -> active = V));
|
window.addCallback(T -> GLFW.glfwSetCursorEnterCallback(T, (_, V) -> active = V));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onDrag(long window, double xpos, double ypos) {
|
protected void onDrag(long window, double xpos, double ypos) {
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import speiger.src.coreengine.assets.base.IAssetProvider;
|
|||||||
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
||||||
|
|
||||||
public class Shader<T extends ShaderProgram> implements Supplier<T> {
|
public class Shader<T extends ShaderProgram> implements Supplier<T> {
|
||||||
boolean registered = false;
|
|
||||||
T program;
|
T program;
|
||||||
Function<IAssetProvider, T> provider;
|
Function<IAssetProvider, T> provider;
|
||||||
|
|
||||||
@ -36,8 +35,6 @@ public class Shader<T extends ShaderProgram> implements Supplier<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
if(registered) throw new IllegalStateException("Shader is already registered!");
|
|
||||||
registered = true;
|
|
||||||
GLStateTracker.instance().shaders.register(this);
|
GLStateTracker.instance().shaders.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@ public class ShaderTracker implements ISimpleRealodableAsset, IManagedAsset {
|
|||||||
IAssetProvider provider;
|
IAssetProvider provider;
|
||||||
|
|
||||||
public void register(Shader<?> shader) {
|
public void register(Shader<?> shader) {
|
||||||
|
if(shaders.contains(shader)) throw new IllegalStateException("Shader is already registered!");
|
||||||
shaders.add(shader);
|
shaders.add(shader);
|
||||||
load(provider, shader);
|
load(provider, shader);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,8 +45,9 @@ public class EventBus
|
|||||||
SubscribeEvent data = t.getAnnotation(SubscribeEvent.class);
|
SubscribeEvent data = t.getAnnotation(SubscribeEvent.class);
|
||||||
if(data == null) return;
|
if(data == null) return;
|
||||||
Consumer<Event> listener = new MethodListener(LOOKUP.unreflect(t).bindTo(obj));
|
Consumer<Event> listener = new MethodListener(LOOKUP.unreflect(t).bindTo(obj));
|
||||||
getListeners(castClass(t.getParameterTypes()[0])).addListener(data.priority(), listener);
|
Class<Event> clz = castClass(t.getParameterTypes()[0]);
|
||||||
list.add(new EventListener(data.value(), listener));
|
getListeners(clz).addListener(data.priority(), listener);
|
||||||
|
list.add(new EventListener(clz, listener));
|
||||||
}
|
}
|
||||||
catch(Exception e) { e.printStackTrace(); }
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
});
|
});
|
||||||
@ -99,11 +100,12 @@ public class EventBus
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Listeners getListeners(Class<? extends Event> event) {
|
protected Listeners getListeners(Class<? extends Event> event) {
|
||||||
//TODO this is abusing undefined behavior!
|
Listeners result = listeners.get(event);
|
||||||
return listeners.computeIfAbsent(event, T -> {
|
if(result == null) {
|
||||||
if(T == Event.class) return new Listeners();
|
result = event == Event.class ? new Listeners() : new Listeners(getListeners(castClass(event.getSuperclass())));
|
||||||
else return new Listeners(getListeners(castClass(event.getSuperclass())));
|
listeners.put(event, result);
|
||||||
});
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -117,22 +119,11 @@ public class EventBus
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static record EventListener(Class<? extends Event> event, Consumer<Event> listener) {}
|
public static record EventListener(Class<? extends Event> event, Consumer<Event> listener) {}
|
||||||
|
public static record MethodListener(MethodHandle handle) implements Consumer<Event> {
|
||||||
public static class MethodListener implements Consumer<Event> {
|
|
||||||
MethodHandle handle;
|
|
||||||
|
|
||||||
public MethodListener(MethodHandle handle) {
|
|
||||||
this.handle = handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(Event t) {
|
public void accept(Event t) {
|
||||||
try {
|
try { handle.invoke(t); }
|
||||||
handle.invoke(t);
|
catch(Throwable e) { e.printStackTrace(); }
|
||||||
}
|
|
||||||
catch(Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,8 +49,7 @@ public class Listeners
|
|||||||
if(parent != null) parent.getListeners(entry, events);
|
if(parent != null) parent.getListeners(entry, events);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Consumer<Event>[] getListeners()
|
public Consumer<Event>[] getListeners() {
|
||||||
{
|
|
||||||
if(rebuild) rebuildListeners();
|
if(rebuild) rebuildListeners();
|
||||||
return listeners;
|
return listeners;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class JavaFileFinder implements IFileFinder {
|
|||||||
if((flags & MULTI_FILE) != 0) file.setMultiSelectionEnabled(true);
|
if((flags & MULTI_FILE) != 0) file.setMultiSelectionEnabled(true);
|
||||||
file.setFileHidingEnabled(false);
|
file.setFileHidingEnabled(false);
|
||||||
file.setFileFilter(new Filter(description, validFormats));
|
file.setFileFilter(new Filter(description, validFormats));
|
||||||
if((flags & SAVE) != 0 && file.showSaveDialog(null) == 0) return ObjectArrayList.wrap(sanitize(file.getSelectedFiles(), validFormats.first()));
|
if((flags & SAVE) != 0 && file.showSaveDialog(null) == 0) return ObjectArrayList.wrap(sanitize(file.getSelectedFiles(), validFormats.getFirst()));
|
||||||
else if((flags & SAVE) == 0 && file.showOpenDialog(null) == 0) return ObjectArrayList.wrap(file.getSelectedFiles());
|
else if((flags & SAVE) == 0 && file.showOpenDialog(null) == 0) return ObjectArrayList.wrap(file.getSelectedFiles());
|
||||||
return new ObjectArrayList<>();
|
return new ObjectArrayList<>();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public class NativeFileFinder implements IFileFinder {
|
|||||||
PointerBuffer output = stack.mallocPointer(1);
|
PointerBuffer output = stack.mallocPointer(1);
|
||||||
if(NativeFileDialog.NFD_SaveDialog(output, toFileFormat(stack, validFormats, description), startPath, "") == NativeFileDialog.NFD_OKAY) {
|
if(NativeFileDialog.NFD_SaveDialog(output, toFileFormat(stack, validFormats, description), startPath, "") == NativeFileDialog.NFD_OKAY) {
|
||||||
File file = new File(output.getStringUTF8());
|
File file = new File(output.getStringUTF8());
|
||||||
if(file.getName().lastIndexOf(".") == -1) file = new File(file.getParent(), file.getName()+"."+validFormats.first());
|
if(file.getName().lastIndexOf(".") == -1) file = new File(file.getParent(), file.getName()+"."+validFormats.getFirst());
|
||||||
files.add(file);
|
files.add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user