Start of the texture rewrite

This commit is contained in:
Speiger 2024-04-04 20:13:13 +02:00
parent e1d827223d
commit 7a87adb695
6 changed files with 67 additions and 56 deletions

View File

@ -2,6 +2,8 @@ package speiger.src.coreengine.rendering.textures.base;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import speiger.src.coreengine.rendering.utils.GLStateTracker;
public abstract class BaseTexture implements ITexture { public abstract class BaseTexture implements ITexture {
protected int id; protected int id;
@ -11,66 +13,26 @@ public abstract class BaseTexture implements ITexture {
protected BaseTexture(int id) { protected BaseTexture(int id) {
this.id = id; this.id = id;
track();
}
protected void track() {
GLStateTracker.TEXTURE_TRACKER.registerTexture(this);
} }
@Override @Override
public int id() { public int id() {
// TODO Auto-generated method stub return id;
return 0;
} }
@Override @Override
public void bind() { public void bind(int unit) {
// TODO Auto-generated method stub GLStateTracker.TEXTURES.bind(unit, id);
}
@Override
public void reload() {
// TODO Auto-generated method stub
} }
@Override @Override
public void delete() { public void delete() {
// TODO Auto-generated method stub GL11.glDeleteTextures(id);
GLStateTracker.TEXTURE_TRACKER.deleteTexture(this);
} }
@Override
public int width() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int height() {
// TODO Auto-generated method stub
return 0;
}
@Override
public float minU() {
// TODO Auto-generated method stub
return 0;
}
@Override
public float minV() {
// TODO Auto-generated method stub
return 0;
}
@Override
public float maxU() {
// TODO Auto-generated method stub
return 0;
}
@Override
public float maxV() {
// TODO Auto-generated method stub
return 0;
}
} }

View File

@ -2,15 +2,16 @@ package speiger.src.coreengine.rendering.textures.base;
public interface ITexture { public interface ITexture {
public int id(); public int id();
public void bind(); public default void bind() { bind(0); }
public void bind(int unit);
public void reload(); public void reload();
public void delete(); public void delete();
public int width(); public int width();
public int height(); public int height();
public float minU(); public default float minU() { return 0F; }
public float minV(); public default float minV() { return 0F; }
public float maxU(); public default float maxU() { return 1F; }
public float maxV(); public default float maxV() { return 1F; }
} }

View File

@ -0,0 +1,9 @@
package speiger.src.coreengine.rendering.textures.base;
public class TextureMetadata {
int textureType;
int dataFormat;
int textureFormat;
}

View File

@ -35,7 +35,7 @@ public class TextureTracker implements ISimpleRealodableAsset, IManagedAsset {
@Override @Override
public void onAssetsReloaded(IAssetProvider provider) { public void onAssetsReloaded(IAssetProvider provider) {
textures.filter(((Predicate<ITexture>)reloadable::contains).negate()).forEach(ITexture::delete); textures.filter(Predicate.not(reloadable::contains)).forEach(ITexture::delete);
textures.clear(); textures.clear();
reloadable.peek(ITexture::reload).forEach(textures::add); reloadable.peek(ITexture::reload).forEach(textures::add);
} }

View File

@ -0,0 +1,34 @@
package speiger.src.coreengine.rendering.textures.simple;
import org.lwjgl.stb.STBImage;
import org.lwjgl.system.MemoryUtil;
import speiger.src.coreengine.rendering.textures.base.BaseTexture;
public class SimpleTexture extends BaseTexture {
int width;
int height;
long imageData;
@Override
public void reload() {
}
@Override
public void delete() {
super.delete();
if(imageData == 0L) return;
STBImage.nstbi_image_free(imageData);
imageData = 0L;
}
@Override
public int width() { return width; }
@Override
public int height() { return width; }
private void loadTexture() {
}
}

View File

@ -0,0 +1,5 @@
package speiger.src.coreengine.rendering.utils.values;
public enum GLTextureType {
}