0

enum ImageType

This commit is contained in:
2019-06-04 12:38:35 +03:00
parent 62a1985db3
commit 716c70ce9f
8 changed files with 61 additions and 40 deletions

View File

@@ -0,0 +1,12 @@
package dmx.lwjake2.render;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
public enum ImageType {
SKIN,
SPRITE,
WALL,
PICTURE,
SKY
}

View File

@@ -18,8 +18,11 @@
package lwjake2.render;
import dmx.lwjake2.render.ImageType;
import lwjake2.Defines;
import static dmx.lwjake2.render.ImageType.SKIN;
public class image_t {
public static final int MAX_NAME_SIZE = Defines.MAX_QPATH;
@@ -30,8 +33,8 @@ public class image_t {
// quake 2 variables
public String name=""; // game path, including extension
// enum imagetype_t
public int type;
public ImageType type;
public int width, height; // source image
public int upload_width, upload_height; // after power of two and picmip
public int registration_sequence; // 0 = free
@@ -51,7 +54,7 @@ public class image_t {
// don't clear the id
// wichtig !!!
name = "";
type = 0;
type = SKIN;
width = height = 0;
upload_width = upload_height = 0;
registration_sequence = 0; // 0 = free

View File

@@ -46,17 +46,7 @@ public abstract class Base extends LWJGLBase {
*
* model skin sprite frame wall texture pic
*/
// enum imagetype_t
static final int it_skin = 0;
static final int it_sprite = 1;
static final int it_wall = 2;
static final int it_pic = 3;
static final int it_sky = 4;
// enum modtype_t
static final int mod_bad = 0;

View File

@@ -18,6 +18,7 @@
package lwjake2.render.lwjgl;
import dmx.lwjake2.render.ImageType;
import lwjake2.Defines;
import lwjake2.ErrorCode;
import lwjake2.client.VID;
@@ -31,6 +32,8 @@ import java.nio.IntBuffer;
import org.lwjgl.opengl.GL11;
import static dmx.lwjake2.render.ImageType.PICTURE;
/**
* Draw
* (gl_draw.c)
@@ -46,7 +49,7 @@ public abstract class Draw extends Image {
*/
void Draw_InitLocal() {
// load console characters (don't bilerp characters)
draw_chars = GL_FindImage("pics/conchars.pcx", it_pic);
draw_chars = GL_FindImage("pics/conchars.pcx", PICTURE);
GL_Bind(draw_chars.texnum);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
@@ -103,9 +106,9 @@ public abstract class Draw extends Image {
if (!name.startsWith("/") && !name.startsWith("\\"))
{
fullname = "pics/" + name + ".pcx";
image = GL_FindImage(fullname, it_pic);
image = GL_FindImage(fullname, PICTURE);
} else {
image = GL_FindImage(name.substring(1), it_pic);
image = GL_FindImage(name.substring(1), PICTURE);
}
return image;
}

View File

@@ -18,6 +18,7 @@
package lwjake2.render.lwjgl;
import dmx.lwjake2.render.ImageType;
import lwjake2.Defines;
import lwjake2.ErrorCode;
import dmx.lwjake2.UnpackLoader;
@@ -44,6 +45,8 @@ import org.lwjgl.opengl.ARBMultitexture;
import org.lwjgl.opengl.EXTSharedTexturePalette;
import org.lwjgl.opengl.GL11;
import static dmx.lwjake2.render.ImageType.*;
/**
* Image
*
@@ -260,7 +263,7 @@ public abstract class Image extends Main {
for (i = 0; i < numgltextures; i++) {
glt = gltextures[i];
if (glt.type != it_pic && glt.type != it_sky) {
if (glt.type != PICTURE && glt.type != SKY) {
GL_Bind(glt.texnum);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max);
@@ -330,16 +333,16 @@ public abstract class Image extends Main {
texels += image.upload_width * image.upload_height;
switch (image.type) {
case it_skin :
case SKIN:
VID.Printf(Defines.PRINT_ALL, "M");
break;
case it_sprite :
case SPRITE:
VID.Printf(Defines.PRINT_ALL, "S");
break;
case it_wall :
case WALL:
VID.Printf(Defines.PRINT_ALL, "W");
break;
case it_pic :
case PICTURE:
VID.Printf(Defines.PRINT_ALL, "P");
break;
default :
@@ -1305,7 +1308,7 @@ public abstract class Image extends Main {
This is also used as an entry point for the generated r_notexture
================
*/
image_t GL_LoadPic(String name, byte[] pic, int width, int height, int type, int bits) {
image_t GL_LoadPic(String name, byte[] pic, int width, int height, ImageType type, int bits) {
image_t image;
int i;
@@ -1337,11 +1340,11 @@ public abstract class Image extends Main {
image.type = type;
if (type == it_skin && bits == 8)
if (image.type == SKIN && bits == 8)
R_FloodFillSkin(pic, width, height);
// load little pics into the scrap
if (image.type == it_pic && bits == 8 && image.width < 64 && image.height < 64) {
if (image.type == PICTURE && bits == 8 && image.width < 64 && image.height < 64) {
pos_t pos = new pos_t(0, 0);
int j, k;
@@ -1356,7 +1359,7 @@ public abstract class Image extends Main {
GL_Bind(image.texnum);
image.has_alpha =
GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky);
GL_Upload8(pic, width, height, (image.type != PICTURE && image.type != SKY), image.type == SKY);
image.upload_width = upload_width; // after power of 2 and scales
image.upload_height = upload_height;
@@ -1395,7 +1398,7 @@ public abstract class Image extends Main {
GL_Bind(image.texnum);
if (bits == 8) {
image.has_alpha = GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky);
image.has_alpha = GL_Upload8(pic, width, height, (image.type != PICTURE && image.type != SKY), image.type == SKY);
}
else {
int[] tmp = new int[pic.length / 4];
@@ -1407,7 +1410,7 @@ public abstract class Image extends Main {
tmp[i] |= ((pic[4 * i + 3] & 0xFF) << 24); // & 0xFF000000;
}
image.has_alpha = GL_Upload32(tmp, width, height, (image.type != it_pic && image.type != it_sky));
image.has_alpha = GL_Upload32(tmp, width, height, (image.type != PICTURE && image.type != SKY));
}
image.upload_width = upload_width; // after power of 2 and scales
image.upload_height = upload_height;
@@ -1440,7 +1443,7 @@ public abstract class Image extends Main {
byte[] pix = new byte[mt.width * mt.height];
System.arraycopy(raw, mt.offsets[0], pix, 0, pix.length);
image = GL_LoadPic(name, pix, mt.width, mt.height, it_wall, 8);
image = GL_LoadPic(name, pix, mt.width, mt.height, WALL, 8);
return image;
}
@@ -1452,7 +1455,7 @@ public abstract class Image extends Main {
Finds or loads the given image
===============
*/
image_t GL_FindImage(String name, int type) {
image_t GL_FindImage(String name, ImageType type) {
image_t image;
// // TODO loest das grossschreibungs problem
@@ -1517,7 +1520,7 @@ public abstract class Image extends Main {
===============
*/
protected image_t R_RegisterSkin(String name) {
return GL_FindImage(name, it_skin);
return GL_FindImage(name, SKIN);
}
IntBuffer texnumBuffer=BufferUtils.createIntBuffer(1);
@@ -1547,7 +1550,7 @@ public abstract class Image extends Main {
if (image.registration_sequence == 0)
continue;
// don't free pics
if (image.type == it_pic)
if (image.type == PICTURE)
continue;
// free it

View File

@@ -18,6 +18,7 @@
package lwjake2.render.lwjgl;
import dmx.lwjake2.render.ImageType;
import lwjake2.Defines;
import lwjake2.Globals;
import lwjake2.client.VID;
@@ -37,6 +38,9 @@ import org.lwjgl.opengl.EXTSharedTexturePalette;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import static dmx.lwjake2.render.ImageType.SPRITE;
import static dmx.lwjake2.render.ImageType.WALL;
/**
* Misc
*
@@ -81,7 +85,7 @@ public abstract class Misc extends Mesh {
}
}
r_particletexture = GL_LoadPic("***particle***", data, 8, 8, it_sprite, 32);
r_particletexture = GL_LoadPic("***particle***", data, 8, 8, SPRITE, 32);
//
// also use this for bad textures, but without alpha
@@ -96,7 +100,7 @@ public abstract class Misc extends Mesh {
data[y * 32 + x * 4 + 3] = (byte)255;
}
}
r_notexture = GL_LoadPic("***r_notexture***", data, 8, 8, it_wall, 32);
r_notexture = GL_LoadPic("***r_notexture***", data, 8, 8, WALL, 32);
}
// /*

View File

@@ -18,6 +18,7 @@
package lwjake2.render.lwjgl;
import dmx.lwjake2.render.ImageType;
import lwjake2.Defines;
import lwjake2.ErrorCode;
import lwjake2.client.VID;
@@ -49,6 +50,8 @@ import java.util.Vector;
import org.lwjgl.BufferUtils;
import static dmx.lwjake2.render.ImageType.*;
/**
* Model
*
@@ -546,7 +549,7 @@ public abstract class Model extends Surf {
name = "textures/" + in.texture + ".wal";
out[i].image = GL_FindImage(name, it_wall);
out[i].image = GL_FindImage(name, WALL);
if (out[i].image == null) {
VID.Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n');
out[i].image = r_notexture;
@@ -1108,7 +1111,7 @@ public abstract class Model extends Surf {
if (n > -1) {
skinNames[i] = skinNames[i].substring(0, n);
}
mod.skins[i] = GL_FindImage(skinNames[i], it_skin);
mod.skins[i] = GL_FindImage(skinNames[i], SKIN);
}
// set the model arrays
@@ -1157,7 +1160,7 @@ public abstract class Model extends Surf {
for (int i=0 ; i<sprout.numframes ; i++)
{
mod.skins[i] = GL_FindImage(sprout.frames[i].name, it_sprite);
mod.skins[i] = GL_FindImage(sprout.frames[i].name, SPRITE);
}
mod.type = mod_sprite;
@@ -1219,13 +1222,13 @@ public abstract class Model extends Surf {
{
sprout = (qfiles.dsprite_t)mod.extradata;
for (i=0 ; i<sprout.numframes ; i++)
mod.skins[i] = GL_FindImage(sprout.frames[i].name, it_sprite);
mod.skins[i] = GL_FindImage(sprout.frames[i].name, SPRITE);
}
else if (mod.type == mod_alias)
{
pheader = (qfiles.dmdl_t)mod.extradata;
for (i=0 ; i<pheader.num_skins ; i++)
mod.skins[i] = GL_FindImage(pheader.skinNames[i], it_skin);
mod.skins[i] = GL_FindImage(pheader.skinNames[i], SKIN);
// PGM
mod.numframes = pheader.num_frames;
// PGM

View File

@@ -18,6 +18,7 @@
package lwjake2.render.lwjgl;
import dmx.lwjake2.render.ImageType;
import lwjake2.Defines;
import lwjake2.ErrorCode;
import lwjake2.Globals;
@@ -30,6 +31,8 @@ import lwjake2.util.Vec3Cache;
import org.lwjgl.opengl.GL11;
import static dmx.lwjake2.render.ImageType.SKY;
/**
* Warp
*
@@ -693,7 +696,7 @@ public abstract class Warp extends Model {
pathname = "env/" + skyname + suf[i] + ".tga";
}
sky_images[i] = GL_FindImage(pathname, it_sky);
sky_images[i] = GL_FindImage(pathname, SKY);
if (sky_images[i] == null)
sky_images[i] = r_notexture;