(String name, byte[] pic, int width, int height, int type, int bits)
| 1289 | ================ |
| 1290 | */ |
| 1291 | image_t GL_LoadPic(String name, byte[] pic, int width, int height, int type, int bits) { |
| 1292 | image_t image; |
| 1293 | int i; |
| 1294 | |
| 1295 | // find a free image_t |
| 1296 | for (i = 0; i<numgltextures ; i++) |
| 1297 | { |
| 1298 | image = gltextures[i]; |
| 1299 | if (image.texnum == 0) |
| 1300 | break; |
| 1301 | } |
| 1302 | |
| 1303 | if (i == numgltextures) |
| 1304 | { |
| 1305 | if (numgltextures == MAX_GLTEXTURES) |
| 1306 | Com.Error (Defines.ERR_DROP, "MAX_GLTEXTURES"); |
| 1307 | |
| 1308 | numgltextures++; |
| 1309 | } |
| 1310 | image = gltextures[i]; |
| 1311 | |
| 1312 | if (name.length() > Defines.MAX_QPATH) |
| 1313 | Com.Error(Defines.ERR_DROP, "Draw_LoadPic: \"" + name + "\" is too long"); |
| 1314 | |
| 1315 | image.name = name; |
| 1316 | image.registration_sequence = registration_sequence; |
| 1317 | |
| 1318 | image.width = width; |
| 1319 | image.height = height; |
| 1320 | image.type = type; |
| 1321 | |
| 1322 | |
| 1323 | if (type == it_skin && bits == 8) |
| 1324 | R_FloodFillSkin(pic, width, height); |
| 1325 | |
| 1326 | // load little pics into the scrap |
| 1327 | if (image.type == it_pic && bits == 8 && image.width < 64 && image.height < 64) { |
| 1328 | pos_t pos = new pos_t(0, 0); |
| 1329 | int j, k; |
| 1330 | |
| 1331 | int texnum = Scrap_AllocBlock(image.width, image.height, pos); |
| 1332 | |
| 1333 | if (texnum == -1) { |
| 1334 | // replace goto nonscrap |
| 1335 | |
| 1336 | image.scrap = false; |
| 1337 | |
| 1338 | image.texnum = TEXNUM_IMAGES + image.getId(); // image pos in array |
| 1339 | GL_Bind(image.texnum); |
| 1340 | |
| 1341 | if (bits == 8) { |
| 1342 | image.has_alpha = |
| 1343 | GL_Upload8(pic, width, height, (image.type != it_pic && image.type != it_sky), image.type == it_sky); |
| 1344 | } |
| 1345 | else { |
| 1346 | int[] tmp = new int[pic.length / 4]; |
| 1347 | |
| 1348 | for (i = 0; i < tmp.length; i++) { |
no test coverage detected