// // R_AllocTexStruct // // Allocates and initializes a new texture_t struct, filling in all needed data // for the given parameters. // static texture_t *R_AllocTexStruct(const char *name, int16_t width, int16_t height, int16_t compcount) { size_t size; texture_t *ret; #ifdef RANGECHECK if(!name || compcount < 0) { I_Error("R_AllocTexStruct: Invalid parameters: %s, %i, %i, %i\n", name, width, height, compcount); } #endif size = sizeof(texture_t) + sizeof(tcomponent_t) * (compcount - 1); ret = (texture_t *)(Z_Calloc(1, size, PU_RENDERER, NULL)); ret->name = ret->namebuf; strncpy(ret->namebuf, name, 8); ret->width = emax<int16_t>(1, width); ret->height = emax<int16_t>(1, height); ret->ccount = compcount; // haleyjd 05/28/14: support non-power-of-two widths if(ret->width & (ret->width - 1)) { ret->flags |= TF_WIDTHNP2; ret->widthmask = ret->width - 1; } else { int j; // SoM: no longer use global lists. This is now done for every texture. for(j = 1; j * 2 <= ret->width; j <<= 1) ; ret->widthmask = j - 1; } ret->heightfrac = ret->height << FRACBITS; R_DetermineFlatSize(ret); return ret; }
// // R_AllocTexStruct // // Allocates and initializes a new texture_t struct, filling in all needed data // for the given parameters. // static texture_t *R_AllocTexStruct(const char *name, uint16_t width, uint16_t height, int16_t compcount) { size_t size; texture_t *ret; int j; #ifdef RANGECHECK if(!width || !height || !name || compcount < 0) { I_Error("R_AllocTexStruct: Invalid parameters: %s, %i, %i, %i\n", name, width, height, compcount); } #endif size = sizeof(texture_t) + sizeof(tcomponent_t) * (compcount - 1); ret = (texture_t *)(Z_Calloc(1, size, PU_RENDERER, NULL)); ret->name = ret->namebuf; strncpy(ret->namebuf, name, 8); ret->width = width; ret->height = height; ret->ccount = compcount; // SoM: no longer use global lists. This is now done for every texture. for(j = 1; j * 2 <= ret->width; j <<= 1) ; ret->widthmask = j - 1; ret->heightfrac = ret->height << FRACBITS; R_DetermineFlatSize(ret); return ret; }