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

Method GL_Upload32

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

Source from the content-addressed store, hash-verified

1037 IntBuffer tex = Lib.newIntBuffer(512 * 256, ByteOrder.LITTLE_ENDIAN);
1038
1039 boolean GL_Upload32(int[] data, int width, int height, boolean mipmap) {
1040 int samples;
1041 int scaled_width, scaled_height;
1042 int i, c;
1043 int comp;
1044
1045 Arrays.fill(scaled, 0);
1046 // Arrays.fill(paletted_texture, (byte)0);
1047 paletted_texture.clear();
1048 for (int j=0; j<256*256; j++) paletted_texture.put(j,(byte)0);
1049
1050 uploaded_paletted = false;
1051
1052 for (scaled_width = 1; scaled_width < width; scaled_width <<= 1);
1053 if (gl_round_down.value > 0.0f && scaled_width > width && mipmap)
1054 scaled_width >>= 1;
1055 for (scaled_height = 1; scaled_height < height; scaled_height <<= 1);
1056 if (gl_round_down.value > 0.0f && scaled_height > height && mipmap)
1057 scaled_height >>= 1;
1058
1059 // let people sample down the world textures for speed
1060 if (mipmap) {
1061 scaled_width >>= (int) gl_picmip.value;
1062 scaled_height >>= (int) gl_picmip.value;
1063 }
1064
1065 // don't ever bother with >256 textures
1066 if (scaled_width > 256)
1067 scaled_width = 256;
1068 if (scaled_height > 256)
1069 scaled_height = 256;
1070
1071 if (scaled_width < 1)
1072 scaled_width = 1;
1073 if (scaled_height < 1)
1074 scaled_height = 1;
1075
1076 upload_width = scaled_width;
1077 upload_height = scaled_height;
1078
1079 if (scaled_width * scaled_height > 256 * 256)
1080 Com.Error(Defines.ERR_DROP, "GL_Upload32: too big");
1081
1082 // scan the texture for any non-255 alpha
1083 c = width * height;
1084 samples = gl_solid_format;
1085
1086 for (i = 0; i < c; i++) {
1087 if ((data[i] & 0xff000000) != 0xff000000) {
1088 samples = gl_alpha_format;
1089 break;
1090 }
1091 }
1092
1093 if (samples == gl_solid_format)
1094 comp = gl_tex_solid_format;
1095 else if (samples == gl_alpha_format)
1096 comp = gl_tex_alpha_format;

Callers 2

GL_Upload8Method · 0.95
GL_LoadPicMethod · 0.95

Calls 9

ErrorMethod · 0.95
PrintfMethod · 0.95
GL_ResampleTextureMethod · 0.95
GL_LightScaleTextureMethod · 0.95
GL_MipMapMethod · 0.95
glTexImage2DMethod · 0.65
glTexParameterfMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected