MCPcopy Create free account
hub / github.com/demoth/jake2 / GL_Upload8

Method GL_Upload8

client/src/main/java/jake2/client/render/fast/Image.java:1233–1282  ·  view source on GitHub ↗
(byte[] data, int width, int height, boolean mipmap, boolean is_sky)

Source from the content-addressed store, hash-verified

1231 int[] trans = new int[512 * 256];
1232
1233 boolean GL_Upload8(byte[] data, int width, int height, boolean mipmap, boolean is_sky) {
1234
1235 Arrays.fill(trans, 0);
1236
1237 int s = width * height;
1238
1239 if (s > trans.length)
1240 Com.Error(Defines.ERR_DROP, "GL_Upload8: too large");
1241
1242 if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && is_sky) {
1243 gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, width, height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, ByteBuffer.wrap(data));
1244
1245 gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
1246 gl.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
1247
1248 // TODO check this
1249 return false;
1250 }
1251 else {
1252 int p;
1253 for (int i = 0; i < s; i++) {
1254 p = data[i] & 0xff;
1255 trans[i] = d_8to24table[p];
1256
1257 if (p == 255) { // transparent, so scan around for another color
1258 // to avoid alpha fringes
1259 // FIXME: do a full flood fill so mips work...
1260 if (i > width && (data[i - width] & 0xff) != 255)
1261 p = data[i - width] & 0xff;
1262 else if (i < s - width && (data[i + width] & 0xff) != 255)
1263 p = data[i + width] & 0xff;
1264 else if (i > 0 && (data[i - 1] & 0xff) != 255)
1265 p = data[i - 1] & 0xff;
1266 else if (i < s - 1 && (data[i + 1] & 0xff) != 255)
1267 p = data[i + 1] & 0xff;
1268 else
1269 p = 0;
1270 // copy rgb components
1271
1272 // ((byte *)&trans[i])[0] = ((byte *)&d_8to24table[p])[0];
1273 // ((byte *)&trans[i])[1] = ((byte *)&d_8to24table[p])[1];
1274 // ((byte *)&trans[i])[2] = ((byte *)&d_8to24table[p])[2];
1275
1276 trans[i] = d_8to24table[p] & 0x00FFFFFF; // only rgb
1277 }
1278 }
1279
1280 return GL_Upload32(trans, width, height, mipmap);
1281 }
1282 }
1283
1284 /*
1285 ================

Callers 2

Scrap_UploadMethod · 0.95
GL_LoadPicMethod · 0.95

Calls 4

ErrorMethod · 0.95
GL_Upload32Method · 0.95
glTexImage2DMethod · 0.65
glTexParameterfMethod · 0.65

Tested by

no test coverage detected