diff --git a/src/lwjake2/qcommon/qfiles.java b/src/lwjake2/qcommon/qfiles.java index dee8e7b..585fef0 100644 --- a/src/lwjake2/qcommon/qfiles.java +++ b/src/lwjake2/qcommon/qfiles.java @@ -47,52 +47,6 @@ public class qfiles { /* ======================================================================== - TGA files are used for sky planes - - ======================================================================== - */ - public static class tga_t { - - // targa header - public int id_length, colormap_type, image_type; // unsigned char - public int colormap_index, colormap_length; // unsigned short - public int colormap_size; // unsigned char - public int x_origin, y_origin, width, height; // unsigned short - public int pixel_size, attributes; // unsigned char - - public ByteBuffer data; // (un)compressed data - - public tga_t(byte[] dataBytes) { - this(ByteBuffer.wrap(dataBytes)); - } - - public tga_t(ByteBuffer b) { - // is stored as little endian - b.order(ByteOrder.LITTLE_ENDIAN); - - // fill header - id_length = b.get() & 0xFF; - colormap_type = b.get() & 0xFF; - image_type = b.get() & 0xFF; - colormap_index = b.getShort() & 0xFFFF; - colormap_length = b.getShort() & 0xFFFF; - colormap_size = b.get() & 0xFF; - x_origin = b.getShort() & 0xFFFF; - y_origin = b.getShort() & 0xFFFF; - width = b.getShort() & 0xFFFF; - height = b.getShort() & 0xFFFF; - pixel_size = b.get() & 0xFF; - attributes = b.get() & 0xFF; - - // fill data - data = b.slice(); - } - - } - - /* - ======================================================================== - .MD2 triangle model file format ======================================================================== diff --git a/src/lwjake2/render/lwjgl/Image.java b/src/lwjake2/render/lwjgl/Image.java index 13fd8be..4766490 100644 --- a/src/lwjake2/render/lwjgl/Image.java +++ b/src/lwjake2/render/lwjgl/Image.java @@ -45,6 +45,7 @@ import org.lwjgl.opengl.ARBMultitexture; import org.lwjgl.opengl.EXTSharedTexturePalette; import org.lwjgl.opengl.GL11; import ru.di9.lwjake2.PcxFile; +import ru.di9.lwjake2.TgaFile; /** * Image @@ -542,7 +543,7 @@ public abstract class Image extends Main { int row, column; byte[] raw; ByteBuffer buf_p; - qfiles.tga_t targa_header; + TgaFile targa_header; byte[] pic = null; // @@ -556,16 +557,16 @@ public abstract class Image extends Main { return null; } - targa_header = new qfiles.tga_t(raw); + targa_header = new TgaFile(ByteBuffer.wrap(raw)); - if (targa_header.image_type != 2 && targa_header.image_type != 10) + if (targa_header.getImageType() != 2 && targa_header.getImageType() != 10) Com.Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n"); - if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24)) + if (targa_header.getColormapType() != 0 || (targa_header.getPixelSize() != 32 && targa_header.getPixelSize() != 24)) Com.Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); - columns = targa_header.width; - rows = targa_header.height; + columns = targa_header.getWidth(); + rows = targa_header.getHeight(); numPixels = columns * rows; if (dim != null) { @@ -575,22 +576,22 @@ public abstract class Image extends Main { pic = new byte[numPixels * 4]; // targa_rgba; - if (targa_header.id_length != 0) - targa_header.data.position(targa_header.id_length); // skip TARGA image comment + if (targa_header.getIdLength() != 0) + targa_header.getData().position(targa_header.getIdLength()); // skip TARGA image comment - buf_p = targa_header.data; + buf_p = targa_header.getData(); byte red,green,blue,alphabyte; red = green = blue = alphabyte = 0; int packetHeader, packetSize, j; - if (targa_header.image_type==2) { // Uncompressed, RGB images + if (targa_header.getImageType()==2) { // Uncompressed, RGB images for(row=rows-1; row>=0; row--) { pixbuf = row * columns * 4; for(column=0; column=0; row--) { pixbuf = row * columns * 4; @@ -627,7 +628,7 @@ public abstract class Image extends Main { packetSize = 1 + (packetHeader & 0x7f); if ((packetHeader & 0x80) != 0) { // run-length packet - switch (targa_header.pixel_size) { + switch (targa_header.getPixelSize()) { case 24: blue = buf_p.get(); green = buf_p.get(); @@ -662,7 +663,7 @@ public abstract class Image extends Main { } else { // non run-length packet for(j=0;j