Engine Upgrade
- Added: Texture Uniform - Added: UniformManager - Upgraded Shader implementations.
This commit is contained in:
parent
c464aaa271
commit
51afb9d82e
36
.classpath
36
.classpath
|
@ -1,18 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="bin/main" path="src/main/java">
|
<classpathentry kind="src" output="bin/main" path="src/main/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="gradle_scope" value="main"/>
|
<attribute name="gradle_scope" value="main"/>
|
||||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="bin/main" path="src/main/resources">
|
<classpathentry kind="src" output="bin/main" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="gradle_scope" value="main"/>
|
<attribute name="gradle_scope" value="main"/>
|
||||||
<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-19/"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
|
||||||
<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>
|
||||||
|
|
|
@ -12,7 +12,7 @@ eclipse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(19)
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(21)
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -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.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package speiger.src.coreengine.assets.reloader;
|
package speiger.src.coreengine.assets.reloader;
|
||||||
|
|
||||||
import java.util.ServiceLoader;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet;
|
import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet;
|
||||||
|
|
|
@ -37,6 +37,17 @@ public class ShaderTracker implements ISimpleRealodableAsset, IManagedAsset {
|
||||||
public boolean isActive() { return activeShaderId != 0; }
|
public boolean isActive() { return activeShaderId != 0; }
|
||||||
public boolean isShaderActive(ShaderProgram program) { return activeShaderId == shaderId(program); }
|
public boolean isShaderActive(ShaderProgram program) { return activeShaderId == shaderId(program); }
|
||||||
public int getActiveShader() { return activeShaderId; }
|
public int getActiveShader() { return activeShaderId; }
|
||||||
|
public ShaderProgram getActiveProgram() {
|
||||||
|
if(isActive()) {
|
||||||
|
for(int i = 0,m=shaders.size();i<m;i++) {
|
||||||
|
ShaderProgram program = shaders.get(i).get();
|
||||||
|
if(activeShaderId == shaderId(program)) {
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private int shaderId(ShaderProgram program) {
|
private int shaderId(ShaderProgram program) {
|
||||||
return program == null ? 0 : program.id();
|
return program == null ? 0 : program.id();
|
||||||
|
|
|
@ -7,8 +7,8 @@ import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap;
|
||||||
public class GlobalUniforms {
|
public class GlobalUniforms {
|
||||||
private Object2ObjectMap<String, IUniform> uniforms = Object2ObjectMap.builder().map();
|
private Object2ObjectMap<String, IUniform> uniforms = Object2ObjectMap.builder().map();
|
||||||
|
|
||||||
public <T extends IUniform> T register(T uniform) {
|
public <T extends IUniform> T register(String uniformId, T uniform) {
|
||||||
uniforms.putIfAbsent(Objects.requireNonNull(uniform.getName()), uniform);
|
uniforms.putIfAbsent(Objects.requireNonNull(uniformId), Objects.requireNonNull(uniform));
|
||||||
return uniform;
|
return uniform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package speiger.src.coreengine.rendering.shader.uniform;
|
package speiger.src.coreengine.rendering.shader.uniform;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.shader.ShaderProgram;
|
|
||||||
|
|
||||||
public interface IAutoUniform extends IUniform {
|
public interface IAutoUniform extends IUniform {
|
||||||
public void bind(ShaderProgram program);
|
public void bind(int programId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package speiger.src.coreengine.rendering.shader.uniform;
|
||||||
import speiger.src.coreengine.rendering.shader.ShaderProgram;
|
import speiger.src.coreengine.rendering.shader.ShaderProgram;
|
||||||
|
|
||||||
public interface IUniform {
|
public interface IUniform {
|
||||||
public String getName();
|
|
||||||
public void registerShader(ShaderProgram program);
|
public void registerShader(ShaderProgram program);
|
||||||
public void removeShader(ShaderProgram program);
|
public void removeShader(ShaderProgram program);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL20;
|
||||||
import speiger.src.collections.ints.maps.impl.hash.Int2IntOpenHashMap;
|
import speiger.src.collections.ints.maps.impl.hash.Int2IntOpenHashMap;
|
||||||
import speiger.src.collections.ints.maps.interfaces.Int2IntMap;
|
import speiger.src.collections.ints.maps.interfaces.Int2IntMap;
|
||||||
import speiger.src.coreengine.rendering.shader.ShaderProgram;
|
import speiger.src.coreengine.rendering.shader.ShaderProgram;
|
||||||
|
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
||||||
import speiger.src.coreengine.utils.io.GameLog;
|
import speiger.src.coreengine.utils.io.GameLog;
|
||||||
|
|
||||||
public abstract class Uniform implements IUniform {
|
public abstract class Uniform implements IUniform {
|
||||||
|
@ -16,9 +17,8 @@ public abstract class Uniform implements IUniform {
|
||||||
positions.setDefaultReturnValue(-1);
|
positions.setDefaultReturnValue(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected boolean contains(int shaderId) {
|
||||||
public String getName() {
|
return positions.containsKey(shaderId);
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getPosition(ShaderProgram program) {
|
protected int getPosition(ShaderProgram program) {
|
||||||
|
@ -45,6 +45,10 @@ public abstract class Uniform implements IUniform {
|
||||||
|
|
||||||
protected void update() {
|
protected void update() {
|
||||||
positions.forEach(this::processChanges);
|
positions.forEach(this::processChanges);
|
||||||
|
if(this instanceof IAutoUniform auto) {
|
||||||
|
int id = GLStateTracker.SHADERS.getActiveShader();
|
||||||
|
if(contains(id)) auto.bind(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processChanges(int programId, int location) {
|
protected void processChanges(int programId, int location) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class UniformManager {
|
||||||
public void bind() {
|
public void bind() {
|
||||||
if(autoUniforms.isEmpty()) return;
|
if(autoUniforms.isEmpty()) return;
|
||||||
for(int i = 0,m=autoUniforms.size();i<m;i++) {
|
for(int i = 0,m=autoUniforms.size();i<m;i++) {
|
||||||
autoUniforms.get(i).bind(owner);
|
autoUniforms.get(i).bind(owner.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package speiger.src.coreengine.rendering.shader.uniform.base;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL41;
|
import org.lwjgl.opengl.GL41;
|
||||||
|
|
||||||
import speiger.src.coreengine.rendering.shader.ShaderProgram;
|
|
||||||
import speiger.src.coreengine.rendering.shader.uniform.IAutoUniform;
|
import speiger.src.coreengine.rendering.shader.uniform.IAutoUniform;
|
||||||
import speiger.src.coreengine.rendering.shader.uniform.Uniform;
|
import speiger.src.coreengine.rendering.shader.uniform.Uniform;
|
||||||
import speiger.src.coreengine.rendering.utils.AllocationTracker;
|
import speiger.src.coreengine.rendering.utils.AllocationTracker;
|
||||||
|
@ -11,7 +10,7 @@ import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
||||||
public class TextureUniform extends Uniform implements IAutoUniform {
|
public class TextureUniform extends Uniform implements IAutoUniform {
|
||||||
final int unit;
|
final int unit;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
public TextureUniform(String name, int unit) {
|
public TextureUniform(String name, int unit) {
|
||||||
super(name);
|
super(name);
|
||||||
this.unit = unit;
|
this.unit = unit;
|
||||||
|
@ -32,7 +31,7 @@ public class TextureUniform extends Uniform implements IAutoUniform {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bind(ShaderProgram program) {
|
public void bind(int programId) {
|
||||||
GLStateTracker.TEXTURES.bind(unit, value);
|
GLStateTracker.TEXTURES.bind(unit, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue