Ejemplo n.º 1
0
GLuint TextureManager::add(string name)
{
	bool ext;
	GLuint id;
	transform (name.begin(), name.end(), name.begin(), ToLower());
	if (names.find(name) != names.end())
	{
		id = names[name];
		items[id]->addref();
		return id;
	}
	
	glGenTextures(1, &id);

	Texture* tex = new Texture(name);
	tex->id = id;
	ext=LoadBLP(id, tex);

	if(!ext)
		gLog("[World of Warcraft Studio - Editor] - Loading Texture from MPQ %s\n", name.c_str());
	else
		gLog("[World of Warcraft Studio - Editor] - Loading Texture from File %s\n", name.c_str());

	do_add(name, id, tex);

	return id;
}
Ejemplo n.º 2
0
GLuint TextureManager::add(wxString name)
{
	GLuint id = 0;

	// if the item already exists, return the existing ID
	if (names.find(name) != names.end()) {
		id = names[name];
		items[id]->addref();
		return id;
	}

	// Else, create the texture

	Texture *tex = new Texture(name);
	if (tex) {
		// clear old texture memory from vid card
		glDeleteTextures(1, &id);
		// create new texture and put it in memory
		glGenTextures(1, &id);

		tex->id = id;
		LoadBLP(id, tex);

		do_add(name, id, tex);
		return id;
	}

	return 0;
}
Ejemplo n.º 3
0
Archivo: blp.c Proyecto: Ralle/Libblp
int BLP2Everything(char *srcbuf, unsigned long srcbuflen, const char *szFileDest) {
	int hFile;
	long r, w, h;
	
	char *rawImageData = NULL;
	unsigned long rawImageSize = 0;
	
	char *processedImageData = NULL;
	unsigned long processedImageSize = 0;
	
	rawImageSize = LoadBLP(NULL, srcbuf, &w, &h, NULL, NULL);
	rawImageData = (char *)malloc(rawImageSize);
	
	LoadBLP(rawImageData, srcbuf, &w, &h, NULL, NULL);
	
	// !!! Assume image data to have 32 bits per pixel !!!

	int quality = 100;
	if(isFileOfType(szFileDest, "jpg")) {
		processedImageSize = MakeJPG(NULL, rawImageData, w, h, quality);
		processedImageData = malloc(processedImageSize);
		MakeJPG(processedImageData, rawImageData, w, h, quality);
	} else if(isFileOfType(szFileDest, "tga")) {
		processedImageSize = MakeTGA(NULL, rawImageData, w, h, 32);
		processedImageData = malloc(processedImageSize);
		MakeTGA(processedImageData, rawImageData, w, h, 32);
	} else {
		free(rawImageData);
		return 0;
	}
	
	free(rawImageData);
        
	hFile = open(szFileDest, O_RDWR | O_CREAT | O_TRUNC, 0644);
	if(hFile == -1) return 0;

	r = pwrite(hFile, processedImageData, processedImageSize, 0);
	close(hFile);
		
	free(processedImageData);
	return 1;
}
Ejemplo n.º 4
0
void TextureManager::reload()
{
	gLog("[World of Warcraft Studio - Editor] - Reloading Textures\n");
	for(map<string, GLuint>::iterator it = names.begin(); it != names.end(); ++it)
	{
		bool ext;
		GLuint id = (*it).second;
		Texture* tex = (Texture*)items[(*it).second];

		ext = LoadBLP(id, tex);

		if(!ext)
			gLog("[World of Warcraft Studio - Editor] - Reloading Texture from MPQ %s\n", (*it).first.c_str());
		else
			gLog("[World of Warcraft Studio - Editor] - Reloading Texture from File %s\n", (*it).first.c_str());
	}
	gLog("[World of Warcraft Studio - Editor] - Finish Reloading Textures\n\n");
}