void R_InitMiscTexture (void) { int x, y; byte data[MISC_TEXTURE_SIZE][MISC_TEXTURE_SIZE][4]; OBJZERO(data); /* also use this for bad textures, but without alpha */ for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { data[y][x][0] = gridtexture[x][y] * 255; data[y][x][3] = 255; } } r_noTexture = R_LoadImageData("***r_notexture***", (byte *) data, 8, 8, it_effect); R_UploadTexture((unsigned int *)data, 8, 8, r_noTexture); for (x = 0; x < MISC_TEXTURE_SIZE; x++) { for (y = 0; y < MISC_TEXTURE_SIZE; y++) { data[y][x][0] = rand() % 255; data[y][x][1] = rand() % 255; data[y][x][2] = rand() % 48; data[y][x][3] = rand() % 48; } } r_warpTexture = R_LoadImageData("***r_warptexture***", (byte *)data, MISC_TEXTURE_SIZE, MISC_TEXTURE_SIZE, it_effect); R_UploadTexture((unsigned int *)data, MISC_TEXTURE_SIZE, MISC_TEXTURE_SIZE, r_warpTexture); /* empty pic in the texture chain for cinematic frames */ R_LoadImageData("***cinematic***", NULL, VID_NORM_WIDTH, VID_NORM_HEIGHT, it_pic); }
/** * \brief Load raw image into video memory. * \param[in] name Name of texture image. * \param[in] tex Texture structure. * \param[in] data Image data. * \param[in] width Width of image in pixels. * \param[in] height Height of image in pixels. * \param[in] type Texture type * \param[in] bytes Number of bytes of image data * \return Pointer to filled out texture_t structure. */ PUBLIC void TM_LoadTexture_DB( const char *name, texture_t *tex, W8 *data, int width, int height, texturetype_t type, W16 bytes ) { if( strlen( name ) >= sizeof( tex->name ) ) { Com_DPrintf( "TM_LoadTexture: \"%s\" is too long\n", name ); } com_strlcpy( tex->name, name, MAX_GAMEPATH ); tex->registration_sequence = texture_registration_sequence; tex->width = width; tex->height = height; tex->type = type; tex->bytes = bytes; switch( type ) { case TT_Pic: tex->MipMap = false; tex->WrapS = Clamp; tex->WrapT = Clamp; tex->MinFilter = NearestMipMapOff; tex->MagFilter = Nearest; break; case TT_Wall: tex->MipMap = true; tex->WrapS = Repeat; tex->WrapT = Repeat; tex->MinFilter = LinearMipMapLinear; tex->MagFilter = Linear; break; case TT_Sprite: tex->MipMap = true; tex->WrapS = Repeat; tex->WrapT = Repeat; tex->MinFilter = LinearMipMapLinear; tex->MagFilter = Nearest; break; default: tex->MipMap = false; tex->WrapS = Clamp; tex->WrapT = Clamp; tex->MinFilter = NearestMipMapOff; tex->MagFilter = Nearest; break; } R_UploadTexture( tex, data ); }
/** * \brief Load raw image into video memory. * \param[in] name Name of texture image. * \param[in] data Image data. * \param[in] width Width of image in pixels. * \param[in] height Height of image in pixels. * \param[in] type Texture type * \param[in] bytes Image data byte length * \return Pointer to filled out texture_t structure. * \note Any texture that was not touched on this registration sequence will be freed. */ PUBLIC texture_t *TM_LoadTexture( const char *name, W8 *data, int width, int height, texturetype_t type, W16 bytes ) { texture_t *tex; int i; if( strlen( name ) >= sizeof( tex->name ) ) { Com_DPrintf( "TM_LoadTexture: \"%s\" is too long\n", name ); return r_notexture; } // find a free texture_t space for( i = 0, tex = ttextures; i < numttextures; ++i, ++tex ) { if( ! tex->texnum ) { break; } } if( i == numttextures ) { if( numttextures == MAX_TEXTURES ) { Com_DPrintf( "MAX_TEXTURES reached\n" ); return r_notexture; } numttextures++; } tex = &ttextures[ i ]; com_strlcpy( tex->name, name, MAX_GAMEPATH ); tex->registration_sequence = texture_registration_sequence; tex->width = width; tex->height = height; tex->type = type; tex->bytes = bytes; switch( type ) { case TT_Pic: tex->MipMap = false; tex->WrapS = Clamp; tex->WrapT = Clamp; tex->MinFilter = NearestMipMapOff; tex->MagFilter = Nearest; break; case TT_Wall: tex->MipMap = true; tex->WrapS = Repeat; tex->WrapT = Repeat; tex->MinFilter = LinearMipMapLinear; tex->MagFilter = Linear; break; case TT_Sprite: tex->MipMap = true; tex->WrapS = Repeat; tex->WrapT = Repeat; tex->MinFilter = LinearMipMapLinear; tex->MagFilter = Nearest; break; default: tex->MipMap = false; tex->WrapS = Clamp; tex->WrapT = Clamp; tex->MinFilter = NearestMipMapOff; tex->MagFilter = Nearest; break; } R_UploadTexture( tex, data ); return tex; }