More work on the GPU API
This commit is contained in:
parent
bc078abea4
commit
c1f6c5ec10
2
.project
2
.project
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>GameProject-SimpleJavaEngine</name>
|
<name>SimpleJavaEngine</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
|||||||
@ -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(VERSION(9.1.0))
|
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||||
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/Java/jdk-25.0.2+10
|
java.home=C\:/Program Files/Java/jdk25
|
||||||
jvm.arguments=
|
jvm.arguments=
|
||||||
offline.mode=false
|
offline.mode=false
|
||||||
override.workspace.settings=true
|
override.workspace.settings=true
|
||||||
|
|||||||
15
build.gradle
15
build.gradle
@ -7,10 +7,23 @@ tasks.withType(JavaCompile) {
|
|||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
eclipse {
|
eclipse {
|
||||||
classpath {
|
classpath {
|
||||||
downloadJavadoc = true
|
downloadJavadoc = true
|
||||||
downloadSources = true
|
downloadSources = true
|
||||||
|
file {
|
||||||
|
whenMerged { cp ->
|
||||||
|
cp.entries.forEach { entry ->
|
||||||
|
// Target the core LWJGL modules
|
||||||
|
if (entry.kind == 'lib' && entry.path.contains('org.lwjgl')) {
|
||||||
|
// Dynamically add a JPMS modular export rule to the Eclipse compiler
|
||||||
|
def rule = new org.gradle.plugins.ide.eclipse.model.AccessRule('accessible', 'org/lwjgl/system/**')
|
||||||
|
entry.accessRules.add(rule)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +42,7 @@ repositories {
|
|||||||
name = "Speiger Maven"
|
name = "Speiger Maven"
|
||||||
url = "https://maven.speiger.com/repository/main"
|
url = "https://maven.speiger.com/repository/main"
|
||||||
}
|
}
|
||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url "https://central.sonatype.com/repository/maven-snapshots" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
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-9.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
package speiger.src.coreengine.api.buffer;
|
|
||||||
|
|
||||||
public interface VertexBuffer {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package speiger.src.coreengine.api.core;
|
|
||||||
|
|
||||||
public interface GraphicsCommandQueue {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package speiger.src.coreengine.api.core;
|
|
||||||
|
|
||||||
public interface GraphicsResource {
|
|
||||||
public void remove();
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
package speiger.src.coreengine.api.texture;
|
|
||||||
|
|
||||||
public abstract class Texture {
|
|
||||||
protected final TextureType type = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.buffer;
|
||||||
|
|
||||||
|
public enum BufferState {
|
||||||
|
STATIC_DRAW,
|
||||||
|
STATIC_READ,
|
||||||
|
STATIC_COPY,
|
||||||
|
STREAM_DRAW,
|
||||||
|
STREAM_READ,
|
||||||
|
STREAM_COPY,
|
||||||
|
DYNAMIC_DRAW,
|
||||||
|
DYNAMIC_READ,
|
||||||
|
DYNAMIC_COPY;
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.buffer;
|
||||||
|
|
||||||
|
import java.nio.Buffer;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
|
import speiger.src.coreengine.graphics.api.core.GraphicsResource;
|
||||||
|
|
||||||
|
public abstract class VertexBuffer implements GraphicsResource {
|
||||||
|
protected final BufferState usage;
|
||||||
|
protected int size;
|
||||||
|
|
||||||
|
public VertexBuffer(BufferState usage, int size) {
|
||||||
|
this.usage = usage;
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BufferState usage() {
|
||||||
|
return usage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract VertexBuffer allocate(int totalBytes);
|
||||||
|
public abstract VertexBuffer set(long pointer, int totalBytes);
|
||||||
|
public VertexBuffer set(ByteBuffer buffer) {
|
||||||
|
return set(MemoryUtil.memAddress(buffer), buffer.remaining());
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract VertexBuffer fill(long pointer, int totalBytes, int offset);
|
||||||
|
public VertexBuffer fill(int offset, ByteBuffer buffer) {
|
||||||
|
return fill(MemoryUtil.memAddress(buffer), buffer.remaining(), offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract VertexBuffer read(long pointer, int totalbytes, int offset);
|
||||||
|
public VertexBuffer read(Buffer buffer, int totalBytes, int offset) {
|
||||||
|
return read(MemoryUtil.memAddress(buffer), totalBytes, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package speiger.src.coreengine.api.core;
|
package speiger.src.coreengine.graphics.api.core;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.input.window.Window;
|
import speiger.src.coreengine.rendering.input.window.Window;
|
||||||
|
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.core;
|
||||||
|
|
||||||
|
public interface GraphicsCommandQueue {
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
package speiger.src.coreengine.api.core;
|
package speiger.src.coreengine.graphics.api.core;
|
||||||
|
|
||||||
import speiger.src.coreengine.api.buffer.VertexBuffer;
|
import speiger.src.coreengine.graphics.api.buffer.VertexBuffer;
|
||||||
import speiger.src.coreengine.api.texture.Texture;
|
import speiger.src.coreengine.graphics.api.texture.Texture;
|
||||||
import speiger.src.coreengine.rendering.input.window.Window;
|
import speiger.src.coreengine.rendering.input.window.Window;
|
||||||
|
|
||||||
public interface GraphicsDevice {
|
public interface GraphicsDevice {
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.core;
|
||||||
|
|
||||||
|
public interface GraphicsResource extends AutoCloseable {
|
||||||
|
public boolean isRemoved();
|
||||||
|
public void remove();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default void close() {
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package speiger.src.coreengine.api.core;
|
package speiger.src.coreengine.graphics.api.core;
|
||||||
|
|
||||||
public interface GraphicsSurface {
|
public interface GraphicsSurface {
|
||||||
public void setVsync(boolean value);
|
public void setVsync(boolean value);
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.sampler;
|
||||||
|
|
||||||
|
public abstract class Sampler {
|
||||||
|
SamplerSettings settings;
|
||||||
|
|
||||||
|
public Sampler(SamplerSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SamplerSettings settings() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.sampler;
|
||||||
|
|
||||||
|
public class SamplerSettings {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.texture;
|
||||||
|
|
||||||
|
import speiger.src.coreengine.graphics.api.core.GraphicsResource;
|
||||||
|
|
||||||
|
public abstract class Texture implements GraphicsResource {
|
||||||
|
final TextureSettings settings;
|
||||||
|
|
||||||
|
public Texture(TextureSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextureSettings settings() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,128 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.texture;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
import speiger.src.collections.objects.lists.ImmutableObjectList;
|
||||||
|
import speiger.src.coreengine.graphics.api.texture.states.StencilType;
|
||||||
|
import speiger.src.coreengine.graphics.api.texture.states.SwizzleMask;
|
||||||
|
import speiger.src.coreengine.graphics.api.texture.states.TextureFormat;
|
||||||
|
import speiger.src.coreengine.graphics.api.texture.states.TextureType;
|
||||||
|
|
||||||
|
public record TextureSettings(TextureType type, TextureFormat internal, TextureFormat external, boolean generateMipmapping, OptionalInt baseLevel, OptionalInt maxLevel, List<Optional<SwizzleMask>> swizzle, Optional<StencilType> stencilType) {
|
||||||
|
|
||||||
|
public Builder copy() { return new Builder(this); }
|
||||||
|
public static Builder builder() { return new Builder(); }
|
||||||
|
|
||||||
|
public boolean hasSwizzle() {
|
||||||
|
for(int i = 0;i<4;i++) {
|
||||||
|
if(swizzle().get(i).isPresent()) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
TextureFormat internalFormat;
|
||||||
|
TextureFormat externalFormat;
|
||||||
|
TextureType type;
|
||||||
|
boolean generateMipmapping = false;
|
||||||
|
OptionalInt baseLevel = OptionalInt.empty();
|
||||||
|
OptionalInt maxLevel = OptionalInt.empty();
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Optional<SwizzleMask>[] swizzle = new Optional[] {Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()};
|
||||||
|
Optional<StencilType> stencilType = Optional.empty();
|
||||||
|
|
||||||
|
private Builder() {}
|
||||||
|
private Builder(TextureSettings settings) {
|
||||||
|
type = settings.type;
|
||||||
|
internalFormat = settings.internal;
|
||||||
|
externalFormat = settings.external;
|
||||||
|
generateMipmapping = settings.generateMipmapping;
|
||||||
|
baseLevel = settings.baseLevel;
|
||||||
|
maxLevel = settings.maxLevel;
|
||||||
|
settings.swizzle.toArray(swizzle);
|
||||||
|
stencilType = settings.stencilType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextureSettings build() {
|
||||||
|
return new TextureSettings(
|
||||||
|
Objects.requireNonNull(type, "Texture Type shouldn't be null"),
|
||||||
|
Objects.requireNonNull(internalFormat, "Internal Format shouldn't be null"),
|
||||||
|
Objects.requireNonNull(externalFormat, "External Format shouldn't be null"),
|
||||||
|
generateMipmapping, baseLevel, maxLevel, new ImmutableObjectList<>(swizzle), stencilType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder type(TextureType type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder format(TextureFormat format) {
|
||||||
|
this.internalFormat = format;
|
||||||
|
this.externalFormat = format;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder internal(TextureFormat format) {
|
||||||
|
this.internalFormat = format;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder external(TextureFormat format) {
|
||||||
|
this.externalFormat = format;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder swizzle(SwizzleMask red, SwizzleMask green, SwizzleMask blue, SwizzleMask alpha) {
|
||||||
|
swizzle[0] = Optional.ofNullable(red);
|
||||||
|
swizzle[1] = Optional.ofNullable(green);
|
||||||
|
swizzle[2] = Optional.ofNullable(blue);
|
||||||
|
swizzle[3] = Optional.ofNullable(alpha);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder swizzleRed(SwizzleMask mask) {
|
||||||
|
swizzle[0] = Optional.ofNullable(mask);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder swizzleGreen(SwizzleMask mask) {
|
||||||
|
swizzle[1] = Optional.ofNullable(mask);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder swizzleBlue(SwizzleMask mask) {
|
||||||
|
swizzle[2] = Optional.ofNullable(mask);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder swizzleAlpha(SwizzleMask mask) {
|
||||||
|
swizzle[3] = Optional.ofNullable(mask);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder stencil(StencilType type) {
|
||||||
|
stencilType = Optional.ofNullable(type);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder generateMipmapping(boolean value) {
|
||||||
|
this.generateMipmapping = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder mipMapping(int base, int max) {
|
||||||
|
this.baseLevel = OptionalInt.of(base);
|
||||||
|
this.maxLevel = OptionalInt.of(max);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder clearmMipMapping() {
|
||||||
|
this.baseLevel = OptionalInt.empty();
|
||||||
|
this.maxLevel = OptionalInt.empty();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.texture.states;
|
||||||
|
|
||||||
|
public enum StencilType {
|
||||||
|
DEPTH_COMPONENT,
|
||||||
|
STENCIL_INDEX
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.texture.states;
|
||||||
|
|
||||||
|
public enum SwizzleMask {
|
||||||
|
ZERO,
|
||||||
|
ONE,
|
||||||
|
RED,
|
||||||
|
GREEN,
|
||||||
|
BLUE,
|
||||||
|
ALPHA;
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package speiger.src.coreengine.graphics.api.texture.states;
|
||||||
|
|
||||||
|
public enum TextureFormat {
|
||||||
|
R,
|
||||||
|
RGB,
|
||||||
|
RGBA,
|
||||||
|
DEPTH,
|
||||||
|
DEPTH_STENCIL,
|
||||||
|
LUMINANCE,
|
||||||
|
LUMINANCE_ALPHA
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package speiger.src.coreengine.api.texture;
|
package speiger.src.coreengine.graphics.api.texture.states;
|
||||||
|
|
||||||
public enum TextureType {
|
public enum TextureType {
|
||||||
TEXTURE_1D,
|
TEXTURE_1D,
|
||||||
@ -10,6 +10,7 @@ import org.lwjgl.opengl.GL43;
|
|||||||
import org.lwjgl.system.Configuration;
|
import org.lwjgl.system.Configuration;
|
||||||
import org.lwjgl.util.freetype.FreeType;
|
import org.lwjgl.util.freetype.FreeType;
|
||||||
|
|
||||||
|
|
||||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
import speiger.src.coreengine.assets.AssetLocation;
|
import speiger.src.coreengine.assets.AssetLocation;
|
||||||
import speiger.src.coreengine.assets.AssetManager;
|
import speiger.src.coreengine.assets.AssetManager;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user