Пример #1
0
void GameTacMap::init(puint8_t bitmapData, size_t dataSize)
{
	EllipseElement::init();
	TGAFileHeader* pHeader = (TGAFileHeader*)bitmapData;
	bmpWidth			   = pHeader->width;
	bmpHeight			   = pHeader->height;
	textureHandle = gos_NewTextureFromMemory(gos_Texture_Solid, ".tga", bitmapData, dataSize, 0);
	char path[256];
	strcpy(path, artPath);
	strcat(path, "viewingrect.tga");
	viewRectHandle = mcTextureManager->loadTexture(path, gos_Texture_Alpha, 0);
	strcpy(path, artPath);
	strcat(path, "blip.tga");
	blipHandle = mcTextureManager->loadTexture(path, gos_Texture_Alpha, 0);
}
Пример #2
0
//----------------------------------------------------------------------
// MC_TextureNode
DWORD MC_TextureNode::get_gosTextureHandle (void)	//If texture is not in VidRAM, cache a texture out and cache this one in.
{
	if (gosTextureHandle == 0xffffffff)
	{
		//Somehow this texture is bad.  Probably we are using a handle which got purged between missions.
		// Just send back, NO TEXTURE and we should be able to debug from there because the tri will have no texture!!
		return 0x0;
	}
	
	if (gosTextureHandle != CACHED_OUT_HANDLE)
	{
		lastUsed = turn;
		return gosTextureHandle;
	}
	else
	{
		if ((mcTextureManager->currentUsedTextures >= MAX_MC2_GOS_TEXTURES) && !mcTextureManager->flushCache())
			return 0x0;		//No texture!
	   
		if (width == 0)
			return 0;		//These faces have no texture!!

		if (!textureData)
			return 0x0;		//No Texture.  Cache is out of RAM!!

		if (width > 0xf0000000)
		{
			//------------------------------------------
			// Cache this badboy IN.
			// Badboys are now LZ Compressed in texture cache.
			// Uncompress, then memcpy.
			long origSize = LZDecomp(MC_TextureManager::lzBuffer2,(MemoryPtr)textureData,lzCompSize);
			if (origSize != (long)(width & 0x0fffffff))
				STOP(("Decompressed to different size from original!  Txm:%s  Width:%d  DecompSize:%d",nodeName,(width & 0x0fffffff),origSize));

			if (origSize >= MAX_LZ_BUFFER_SIZE)
				STOP(("Texture TOO large: %s",nodeName));
			
			gosTextureHandle = gos_NewTextureFromMemory(key,nodeName,MC_TextureManager::lzBuffer2,(width & 0x0fffffff),hints);
			mcTextureManager->currentUsedTextures++;
			lastUsed = turn;
			
			return gosTextureHandle;
		}
		else
		{
			gosTextureHandle = gos_NewEmptyTexture(key,nodeName,width,hints);
			mcTextureManager->currentUsedTextures++;
			
			//------------------------------------------
			// Cache this badboy IN.
			TEXTUREPTR pTextureData;
			gos_LockTexture(gosTextureHandle, 0, 0, &pTextureData);
		 
			//-------------------------------------------------------
			// Create a block of cache memory to hold this texture.
			DWORD txmSize = pTextureData.Height * pTextureData.Height * sizeof(DWORD);
			gosASSERT(textureData);
			
			LZDecomp(MC_TextureManager::lzBuffer2,(MemoryPtr)textureData,lzCompSize);
			memcpy(pTextureData.pTexture,MC_TextureManager::lzBuffer2,txmSize);
			 
			//------------------------
			// Unlock the texture
			gos_UnLockTexture(gosTextureHandle);
			 
			lastUsed = turn;
			return gosTextureHandle;
		}
	}
}