mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-15 17:55:08 +00:00
38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package net.coderbot.iris.rendertarget;
|
|
|
|
import com.gtnewhorizons.angelica.compat.mojang.NativeImage;
|
|
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
import java.util.Random;
|
|
|
|
public class NativeImageBackedNoiseTexture extends DynamicTexture {
|
|
public NativeImageBackedNoiseTexture(int size) {
|
|
super(create(size));
|
|
}
|
|
|
|
private static NativeImage create(int size) {
|
|
NativeImage image = new NativeImage(NativeImage.Format.RGBA, size, size, false);
|
|
Random random = new Random(0);
|
|
|
|
for (int x = 0; x < size; x++) {
|
|
for (int y = 0; y < size; y++) {
|
|
int color = random.nextInt() | (255 << 24);
|
|
|
|
image.setPixelRGBA(x, y, color);
|
|
}
|
|
}
|
|
|
|
return image;
|
|
}
|
|
|
|
@Override
|
|
public void updateDynamicTexture() {
|
|
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
|
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
|
|
super.updateDynamicTexture();
|
|
}
|
|
|
|
}
|