Engine Upgrade
- Added: Texture Uniform - Added: UniformManager - Upgraded Shader implementations.
This commit is contained in:
parent
c464aaa271
commit
51afb9d82e
|
@ -12,7 +12,7 @@
|
|||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||
</attributes>
|
||||
</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="output" path="bin/default"/>
|
||||
</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 {
|
||||
mavenCentral()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package speiger.src.coreengine.assets.reloader;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
|
||||
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 isShaderActive(ShaderProgram program) { return activeShaderId == shaderId(program); }
|
||||
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) {
|
||||
return program == null ? 0 : program.id();
|
||||
|
|
|
@ -7,8 +7,8 @@ import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap;
|
|||
public class GlobalUniforms {
|
||||
private Object2ObjectMap<String, IUniform> uniforms = Object2ObjectMap.builder().map();
|
||||
|
||||
public <T extends IUniform> T register(T uniform) {
|
||||
uniforms.putIfAbsent(Objects.requireNonNull(uniform.getName()), uniform);
|
||||
public <T extends IUniform> T register(String uniformId, T uniform) {
|
||||
uniforms.putIfAbsent(Objects.requireNonNull(uniformId), Objects.requireNonNull(uniform));
|
||||
return uniform;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package speiger.src.coreengine.rendering.shader.uniform;
|
||||
|
||||
import speiger.src.coreengine.rendering.shader.ShaderProgram;
|
||||
|
||||
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;
|
||||
|
||||
public interface IUniform {
|
||||
public String getName();
|
||||
public void registerShader(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.interfaces.Int2IntMap;
|
||||
import speiger.src.coreengine.rendering.shader.ShaderProgram;
|
||||
import speiger.src.coreengine.rendering.utils.GLStateTracker;
|
||||
import speiger.src.coreengine.utils.io.GameLog;
|
||||
|
||||
public abstract class Uniform implements IUniform {
|
||||
|
@ -16,9 +17,8 @@ public abstract class Uniform implements IUniform {
|
|||
positions.setDefaultReturnValue(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
protected boolean contains(int shaderId) {
|
||||
return positions.containsKey(shaderId);
|
||||
}
|
||||
|
||||
protected int getPosition(ShaderProgram program) {
|
||||
|
@ -45,6 +45,10 @@ public abstract class Uniform implements IUniform {
|
|||
|
||||
protected void update() {
|
||||
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) {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class UniformManager {
|
|||
public void bind() {
|
||||
if(autoUniforms.isEmpty()) return;
|
||||
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 speiger.src.coreengine.rendering.shader.ShaderProgram;
|
||||
import speiger.src.coreengine.rendering.shader.uniform.IAutoUniform;
|
||||
import speiger.src.coreengine.rendering.shader.uniform.Uniform;
|
||||
import speiger.src.coreengine.rendering.utils.AllocationTracker;
|
||||
|
@ -32,7 +31,7 @@ public class TextureUniform extends Uniform implements IAutoUniform {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void bind(ShaderProgram program) {
|
||||
public void bind(int programId) {
|
||||
GLStateTracker.TEXTURES.bind(unit, value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue