add texture options (filtering broken for now)
This commit is contained in:
parent
937fd4bfb7
commit
1bf4578ad8
8 changed files with 92 additions and 31 deletions
|
@ -21,14 +21,20 @@ public class TextureUtil
|
|||
private static final IntBuffer BUFFER = ByteBuffer.allocateDirect(4194304 << 2).order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
public static final DynamicTexture MISSING = new DynamicTexture(16, 16);
|
||||
public static final int[] MISSING_DATA = MISSING.getData();
|
||||
|
||||
public static void uploadTexture(int[] data, int w, int h, int x, int y)
|
||||
{
|
||||
int i = 4194304 / w;
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MIN_FILTER, GL46.GL_NEAREST);
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAG_FILTER, GL46.GL_NEAREST);
|
||||
|
||||
public static void setParams(boolean filter, boolean mips, boolean linear, float aniso) {
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MIN_FILTER, filter ? (mips ? (linear ? GL46.GL_LINEAR_MIPMAP_LINEAR : GL46.GL_LINEAR_MIPMAP_NEAREST) : GL46.GL_LINEAR) : (mips ? (linear ? GL46.GL_NEAREST_MIPMAP_LINEAR : GL46.GL_NEAREST_MIPMAP_NEAREST) : GL46.GL_NEAREST));
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAG_FILTER, filter ? GL46.GL_LINEAR : GL46.GL_NEAREST);
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_S, GL46.GL_REPEAT);
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_T, GL46.GL_REPEAT);
|
||||
GL46.glTexParameterf(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAX_ANISOTROPY, aniso);
|
||||
}
|
||||
|
||||
public static void uploadTexture(int[] data, int w, int h, int x, int y, boolean params)
|
||||
{
|
||||
int i = 4194304 / w;
|
||||
if(params)
|
||||
setParams(false, false, false, 1.0f);
|
||||
int l;
|
||||
|
||||
for (int j = 0; j < w * h; j += w * l)
|
||||
|
@ -51,10 +57,7 @@ public class TextureUtil
|
|||
int h = img.getHeight();
|
||||
int k = 4194304 / w;
|
||||
int[] data = new int[k * w];
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MIN_FILTER, GL46.GL_NEAREST);
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_MAG_FILTER, GL46.GL_NEAREST);
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_S, GL46.GL_REPEAT);
|
||||
GL46.glTexParameteri(GL46.GL_TEXTURE_2D, GL46.GL_TEXTURE_WRAP_T, GL46.GL_REPEAT);
|
||||
setParams(false, false, false, 1.0f);
|
||||
|
||||
for (int l = 0; l < w * h; l += w * k)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue