MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LoadTextureImage

Function LoadTextureImage

Descent3/gametexture.cpp:544–614  ·  view source on GitHub ↗

Given a filename, loads either the bitmap or vclip found in that file. If type is not NULL, sets it to 1 if file is animation, otherwise sets it to zero

Source from the content-addressed store, hash-verified

542// Given a filename, loads either the bitmap or vclip found in that file. If type
543// is not NULL, sets it to 1 if file is animation, otherwise sets it to zero
544int LoadTextureImage(const char *filename, int *type, int texture_size, int mipped, int pageable, int format) {
545 int anim = 0, bm_handle;
546 char extension[10];
547 int w, h;
548
549 int len = strlen(filename);
550
551 if (len < 4)
552 return -1;
553
554 strncpy(extension, &filename[len - 3], 5);
555
556 if ((!strnicmp("oaf", extension, 3)) || (!strnicmp("ifl", extension, 3)) || (!strnicmp("abm", extension, 3)))
557 anim = 1;
558
559 if (type != NULL)
560 *type = anim;
561
562 if (anim)
563 bm_handle = AllocLoadVClip(IGNORE_TABLE(filename), texture_size, mipped, pageable, format);
564 else {
565 if (pageable)
566 bm_handle = bm_AllocLoadFileNoMemBitmap(IGNORE_TABLE(filename), mipped, format);
567 else
568 bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), mipped, format);
569
570 if (bm_handle < 1)
571 return -1;
572
573 if (texture_size == NORMAL_TEXTURE) {
574 w = TEXTURE_WIDTH;
575 h = TEXTURE_HEIGHT;
576 } else if (texture_size == SMALL_TEXTURE) {
577 // Make small textures a quarter of the size of normal textures
578 w = TEXTURE_WIDTH / 2;
579 h = TEXTURE_HEIGHT / 2;
580 } else if (texture_size == TINY_TEXTURE) {
581 // Make these tinys an eigth of the size of normal textures
582 w = TEXTURE_WIDTH / 4;
583 h = TEXTURE_HEIGHT / 4;
584 } else if (texture_size == HUGE_TEXTURE) {
585 // Make these tinys an eigth of the size of normal textures
586 w = TEXTURE_WIDTH * 2;
587 h = TEXTURE_HEIGHT * 2;
588 } else
589 return bm_handle;
590
591 // If differing size, resize!
592 if (!pageable && (w != bm_w(bm_handle, 0) || h != bm_h(bm_handle, 0))) {
593 int dest_bm;
594
595 mprintf(0, "WARNING: Resizing bitmap %s from %d x %d to %d x %d!\n", GameBitmaps[bm_handle].name,
596 bm_w(bm_handle, 0), bm_h(bm_handle, 0), w, h);
597
598 dest_bm = bm_AllocBitmap(w, h, mipped * ((w * h * 2) / 3));
599 ASSERT(dest_bm >= 0);
600
601 if (mipped)

Callers 13

OnWtexdlgAddnewMethod · 0.85
OnLoadBitmapMethod · 0.85
LoadITLFileMethod · 0.85
OnAddNewSmallMethod · 0.85
OnAddNewTinyMethod · 0.85
OnAddNewHugeMethod · 0.85
OnImportBitmapMethod · 0.85
OnHotspotTgaMethod · 0.85
CustomCallBackFunction · 0.85
InitFireballsFunction · 0.85
LoadWeaponFireImageFunction · 0.85

Calls 8

AllocLoadVClipFunction · 0.85
bm_AllocLoadFileBitmapFunction · 0.85
bm_wFunction · 0.85
bm_hFunction · 0.85
bm_AllocBitmapFunction · 0.85
bm_ScaleBitmapToBitmapFunction · 0.85
bm_FreeBitmapFunction · 0.85

Tested by

no test coverage detected