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

Function bm_AllocBitmap

bitmap/bitmain.cpp:512–539  ·  view source on GitHub ↗

Allocs a bitmap of w x h size If add_mem is nonzero, adds that to the amount alloced Returns bitmap handle if successful, -1 if otherwise

Source from the content-addressed store, hash-verified

510// If add_mem is nonzero, adds that to the amount alloced
511// Returns bitmap handle if successful, -1 if otherwise
512int bm_AllocBitmap(int w, int h, int add_mem) {
513 int n = 0, i;
514 if (!Bitmaps_initted) {
515 Int3();
516 mprintf(0, "Bitmaps not initted!!!\n");
517 return -1;
518 }
519
520 for (i = 0; i < MAX_BITMAPS; i++) {
521 if (GameBitmaps[i].used == 0) {
522 n = i;
523 break;
524 }
525 }
526 // If we can't find a free slot in which to alloc, bail out
527 if (i == MAX_BITMAPS) {
528 Int3();
529 mprintf(0, "ERROR! Couldn't find a free bitmap to alloc!\n");
530 return -1;
531 }
532 memset(&GameBitmaps[n], 0, sizeof(bms_bitmap));
533 int ret = bm_AllocateMemoryForIndex(n, w, h, add_mem);
534 if (ret >= 0) {
535 GameBitmaps[n].used = 1;
536 GameBitmaps[n].cache_slot = -1;
537 }
538 return ret;
539}
540// Just like bm_AllocBitmap but doesn't actually allocate memory. Useful for paging!
541int bm_AllocNoMemBitmap(int w, int h) {
542 int n = 0, i;

Callers 15

OnInitDialogMethod · 0.85
UpdateTextureViewsMethod · 0.85
OnInitDialogMethod · 0.85
OnImportTinyMethod · 0.85
OnImportSkyMethod · 0.85
OnImportSkyBandMethod · 0.85
bm_pcx_8bit_alloc_fileFunction · 0.85
bm_pcx_24bit_alloc_fileFunction · 0.85
bm_tga_alloc_fileFunction · 0.85
bm_iff_alloc_fileFunction · 0.85
bm_iff_read_animbrushFunction · 0.85

Calls 1

Tested by

no test coverage detected