TextureManager: palette get/set
This commit is contained in:
16
src/main/java/dmx/lwjake2/render/TextureManager.java
Normal file
16
src/main/java/dmx/lwjake2/render/TextureManager.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package dmx.lwjake2.render;
|
||||||
|
|
||||||
|
public class TextureManager {
|
||||||
|
|
||||||
|
private static int[] colorTable = new int[256];
|
||||||
|
|
||||||
|
public static void setColorPalette(int[] palette) {
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
colorTable[i] = palette[i] & 0x00FFFFFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getColorPalette(int index) {
|
||||||
|
return colorTable[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package lwjake2.client;
|
package lwjake2.client;
|
||||||
|
|
||||||
|
import dmx.lwjake2.render.TextureManager;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import lwjake2.game.Cmd;
|
import lwjake2.game.Cmd;
|
||||||
import lwjake2.game.cvar_t;
|
import lwjake2.game.cvar_t;
|
||||||
@@ -103,7 +104,7 @@ public final class V {
|
|||||||
|
|
||||||
int i = r_numparticles++;
|
int i = r_numparticles++;
|
||||||
|
|
||||||
int c = particle_t.colorTable[color];
|
int c = TextureManager.getColorPalette(color);
|
||||||
c |= (int) (alpha * 255) << 24;
|
c |= (int) (alpha * 255) << 24;
|
||||||
particle_t.colorArray.put(i, c);
|
particle_t.colorArray.put(i, c);
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package lwjake2.client;
|
package lwjake2.client;
|
||||||
|
|
||||||
|
import dmx.lwjake2.render.TextureManager;
|
||||||
import lwjake2.Defines;
|
import lwjake2.Defines;
|
||||||
import lwjake2.util.Lib;
|
import lwjake2.util.Lib;
|
||||||
|
|
||||||
@@ -32,14 +33,11 @@ public class particle_t {
|
|||||||
private static ByteBuffer colorByteArray = Lib.newByteBuffer(Defines.MAX_PARTICLES * Lib.SIZEOF_INT, ByteOrder.LITTLE_ENDIAN);
|
private static ByteBuffer colorByteArray = Lib.newByteBuffer(Defines.MAX_PARTICLES * Lib.SIZEOF_INT, ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3);
|
public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3);
|
||||||
public static int[] colorTable = new int[256];
|
|
||||||
public static IntBuffer colorArray = colorByteArray.asIntBuffer();
|
public static IntBuffer colorArray = colorByteArray.asIntBuffer();
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void setColorPalette(int[] palette) {
|
public static void setColorPalette(int[] palette) {
|
||||||
for (int i=0; i < 256; i++) {
|
TextureManager.setColorPalette(palette);
|
||||||
colorTable[i] = palette[i] & 0x00FFFFFF;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ByteBuffer getColorAsByteBuffer() {
|
public static ByteBuffer getColorAsByteBuffer() {
|
||||||
|
|||||||
Reference in New Issue
Block a user