Pages a texture into memory, optionally resizing it if in low mem mode Doesn't resize if resize is false
| 640 | // Pages a texture into memory, optionally resizing it if in low mem mode |
| 641 | // Doesn't resize if resize is false |
| 642 | void PageInTexture(int n, bool resize) { |
| 643 | static int super_low_mem = -1; |
| 644 | |
| 645 | if (super_low_mem == -1) { |
| 646 | if (Mem_superlow_memory_mode || FindArg("-dedicated")) |
| 647 | super_low_mem = 1; |
| 648 | else |
| 649 | super_low_mem = 0; |
| 650 | } |
| 651 | if (GameTextures[n].used == 0) |
| 652 | return; |
| 653 | |
| 654 | texture *texp = &GameTextures[n]; |
| 655 | |
| 656 | bm_data(texp->bm_handle, 0); |
| 657 | |
| 658 | #ifndef EDITOR |
| 659 | if (resize == true && (Mem_low_memory_mode || Low_vidmem)) |
| 660 | { |
| 661 | if (!(texp->flags & (TF_TEXTURE_32 | TF_TEXTURE_256)) && !(texp->flags & TF_PROCEDURAL)) { |
| 662 | int bm_handle = texp->bm_handle; |
| 663 | int w = TEXTURE_WIDTH, h = TEXTURE_HEIGHT; |
| 664 | |
| 665 | if (texp->flags & TF_TEXTURE_64) { |
| 666 | w /= 2; |
| 667 | h /= 2; |
| 668 | } |
| 669 | |
| 670 | w /= 2; |
| 671 | h /= 2; |
| 672 | |
| 673 | if (super_low_mem) |
| 674 | { |
| 675 | if (w != 32 || h != 32) { |
| 676 | w = 32; |
| 677 | h = 32; |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | if ((w != bm_w(bm_handle, 0) || h != bm_h(bm_handle, 0))) { |
| 682 | int dest_bm; |
| 683 | int mipped = 0; |
| 684 | int saved = 0; |
| 685 | |
| 686 | if (texp->flags & TF_TEXTURE_64) |
| 687 | saved = 6144; |
| 688 | else |
| 689 | saved = 24576; |
| 690 | |
| 691 | if (bm_mipped(bm_handle)) |
| 692 | mipped = 1; |
| 693 | |
| 694 | if (mipped) |
| 695 | saved += (saved / 3); |
| 696 | |
| 697 | Total_memory_saved += saved; |
| 698 | |
| 699 | mprintf(0, "Low mem: Resizing bitmap %s to %d x %d!\n", GameBitmaps[bm_handle].name, w, h); |
no test coverage detected