SimpleJavaEngine/src/main/java/speiger/src/coreengine/rendering/textures/base/ITexture.java

57 lines
1.7 KiB
Java

package speiger.src.coreengine.rendering.textures.base;
import java.awt.image.BufferedImage;
import java.nio.ByteBuffer;
import speiger.src.coreengine.assets.AssetLocation;
import speiger.src.coreengine.assets.reloader.IReloadableResource;
import speiger.src.coreengine.rendering.textures.normal.DirectTexture;
import speiger.src.coreengine.rendering.textures.normal.SimpleTexture;
import speiger.src.coreengine.rendering.textures.stb.STBDirectTexture;
import speiger.src.coreengine.rendering.textures.stb.STBTexture;
public interface ITexture extends IReloadableResource
{
public int getTextureId();
public void bindTexture();
public void deleteTexture();
public int getWidth();
public int getHeight();
public float getUMin();
public float getVMin();
public float getUMax();
public float getVMax();
public ITexture makeReloadable();
public default float getInterpolatedU(float u){return getUMin() + ((getUMax() - getUMin()) * u);}
public default float getInterpolatedV(float v){return getUMin() + ((getUMax() - getUMin()) * v);}
public static ITexture simple(AssetLocation location) {
return new STBTexture(location);
}
public static ITexture direct(ByteBuffer stbImageData, int width, int height) {
return new STBDirectTexture(stbImageData, width, height);
}
public static ITexture direct(long stbImageData, int width, int height) {
return new STBDirectTexture(stbImageData, width, height);
}
public static ITexture direct(BufferedImage imageData) {
return new STBDirectTexture(imageData);
}
public static ITexture awtSimple(AssetLocation location) {
return new SimpleTexture(location);
}
public static ITexture awtDirect(BufferedImage imageData) {
return new DirectTexture(imageData);
}
}