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

Function bump_AllocBumpmap

bitmap/bumpmap.cpp:60–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58// Returns bumpmap handle if successful, -1 if otherwise
59
60int bump_AllocBumpmap(int w, int h) {
61 int n; //,i;
62
63 if (Num_of_bumpmaps == MAX_BUMPMAPS)
64 Int3(); // Ran out of bumpmaps!
65
66 n = Free_bumpmap_list[Num_of_bumpmaps++];
67 ASSERT(!(GameBumpmaps[n].flags & BUMPF_USED));
68
69 // If no go on the malloc, bail out with -1
70
71 memset(&GameBumpmaps[n], 0, sizeof(bms_bumpmap));
72
73 GameBumpmaps[n].data = (uint16_t *)mem_malloc(w * h * 2);
74 if (!GameBumpmaps[n].data) {
75 mprintf(0, "NOT ENOUGHT MEMORY FOR BUMPMAP!\n");
76 Int3();
77 return BAD_BUMP_INDEX;
78 }
79
80 GameBumpmaps[n].cache_slot = -1;
81 GameBumpmaps[n].flags = BUMPF_USED | BUMPF_CHANGED;
82 GameBumpmaps[n].width = w;
83 GameBumpmaps[n].height = h;
84
85 Bumpmap_mem_used += (w * h * 2);
86
87 return n;
88}
89
90// Given a handle, frees the bumpmap memory and flags this bumpmap as unused
91void bump_FreeBumpmap(int handle) {

Callers 1

BuildTextureBumpmapsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected