void textureLoad(Texture *tex)
{	bitmap *bm;
	char flname[1024];

//	tex->flags &= texture_clearmask;
//	tex->flags |= flags;

//	texturelog->log("Attempting to load texture %s",tex->name);

	if (fileExists(tex->name))										// Check to see if the path + filename is valid ...
		txtcpy(flname, sizeof(flname), tex->name);					// if so, load that
	else
		fileFindInPath(flname, sizeof(flname), tex->name, texpath);	// Find the texture with our texture path

	if (!flname[0])													// nothing found ... fail
	{	texturelog->log("*** %s *** Missing texture.  Looked in %s",tex->name,texpath);
		if (!bm_MissingTexture)
		{	bm_MissingTexture = newbitmap("Missing Texture Standin",1,1,bitmap_ARGB32);
			*(uint32 *)(bm_MissingTexture->pixel) = 0xFFFF00FF;		// Purple
		}
		textureFromBitmap(bm_MissingTexture, tex);
		estimatedtexmemused += 4;
	}	else
	{	bm = newbitmap(flname,0);
		textureFromBitmap(bm, tex);
		deleteBitmap(bm);
	}
	if (tex->oemdata)
		texturelog->log("Create %i: %s",tex->texmemused/1024,flname);
}
Beispiel #2
0
    static inline GloxTexture* textureFromBitmapFile( const char* filename ) {
        std::ifstream ifs;
        ifs.open( filename, std::ifstream::binary );

        if( ! ifs.is_open() ) { return NULL; }
        return textureFromBitmap( ifs );
    }
Texture *newTextureFromFile(const char *texname,uintf flags)
{	// Search the current texture directory to locate a suitable texture file
	bitmap *bm;
	char flname[1024];
	if (!texname) return NULL;
	if (!texname[0]) return NULL;

	// Look for an already loaded texture with the same name
	fileNameInfo(texname);
	tprintf(flname,sizeof(flname),"%s.%s",fileactualname,fileextension);
	Texture *tex = usedTexture;
	while (tex)
	{	if (txticmp(flname,tex->name)==0)
		{	// Texture already loaded
			tex->refcount++;
			return tex;
		}
		tex = tex->next;
	}

	// Allocate a new texture cell
	tex = newTexture(flname, 0, 0);	// ### This forces the texture to be 2D!!!
	tex->flags &= texture_clearmask;
	tex->flags |= flags;

	if (fileExists(texname))										// Check to see if the path + filename is valid ...
		txtcpy(flname, sizeof(flname), texname);					// if so, load that
	else
		fileFindInPath(flname, sizeof(flname), tex->name, texpath);	// Find the texture with our texture path

	if (!flname[0])													// nothing found ... fail
	{	texturelog->log("*** %s *** Missing texture.  Looked in %s",tex->name,texpath);
		if (!bm_MissingTexture)
		{	bm_MissingTexture = newbitmap("Missing Texture Standin",1,1,bitmap_ARGB32);
			*(uint32 *)(bm_MissingTexture->pixel) = 0xFFFF00FF;		// Purple
		}
		textureFromBitmap(bm_MissingTexture, tex);
		estimatedtexmemused += 4;
	}	else
	{	bm = newbitmap(flname,0);
		textureFromBitmap(bm, tex);
		deleteBitmap(bm);
	}
	if (tex->oemdata)
		texturelog->log("Create %i: %s",tex->texmemused/1024,flname);
	return tex;
}