Exemple #1
0
void EC_ChatBubble::Refresh()
{
    if (renderer_.expired() ||!billboardSet_ || !billboard_)
        return;

    // If no messages in the log, hide the chat bubble.
    if (messages_.size() == 0)
    {
        billboardSet_->setVisible(false);
        return;
    }
    else
        billboardSet_->setVisible(true);

    // Get pixmap with chat bubble and text rendered to it.
    QPixmap pixmap = GetChatBubblePixmap();
    if (pixmap.isNull())
        return;

    // Create texture
    QImage img = pixmap.toImage();
    Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream((void*)img.bits(), img.byteCount()));
    std::string tex_name("ChatBubbleTexture" + renderer_.lock()->GetUniqueObjectName());
    Ogre::TextureManager &manager = Ogre::TextureManager::getSingleton();
    Ogre::Texture *tex = dynamic_cast<Ogre::Texture *>(manager.create(tex_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME).get());
    assert(tex);

    tex->loadRawData(stream, img.width(), img.height(), Ogre::PF_A8R8G8B8);

    // Set new material with the new texture name in it.
    std::string newMatName = std::string("material") + renderer_.lock()->GetUniqueObjectName(); 
    Ogre::MaterialPtr material = OgreRenderer::CloneMaterial("UnlitTexturedSoftAlpha", newMatName);
    OgreRenderer::SetTextureUnitOnMaterial(material, tex_name);
    billboardSet_->setMaterialName(newMatName);
}
Exemple #2
0
 void GlobalMap::loadResource(Ogre::Resource *resource)
 {
     Ogre::Texture* tex = static_cast<Ogre::Texture*>(resource);
     Ogre::ConstImagePtrList list;
     list.push_back(&mOverlayImage);
     tex->_loadImages(list);
 }
Exemple #3
0
void gkTextureLoader::loadResource(Ogre::Resource* resource)
{
	Ogre::Texture* texture = static_cast<Ogre::Texture*>(resource);

	if (!m_stream)
	{
		gkPrintf("Warning: Skipping image %s no packed file information is present!", texture->getName().c_str());
		return;
	}

	Ogre::DataStreamPtr stream(OGRE_NEW Ogre::MemoryDataStream(m_stream->ptr(), m_stream->size()));

	Ogre::Image ima;
	ima.load(stream);

	texture->setUsage(Ogre::TU_DEFAULT);
	texture->setTextureType(Ogre::TEX_TYPE_2D);
	texture->setNumMipmaps(gkEngine::getSingleton().getUserDefs().defaultMipMap);
	texture->setWidth(ima.getWidth());
	texture->setHeight(ima.getHeight());
	texture->setDepth(ima.getDepth());
	texture->setFormat(ima.getFormat());

	Ogre::ConstImagePtrList ptrs;
	ptrs.push_back(&ima);
	texture->_loadImages(ptrs);
}
    void CharacterPreview::loadResource(Ogre::Resource *resource)
    {
        Ogre::Texture* tex = dynamic_cast<Ogre::Texture*>(resource);
        if (!tex)
            return;

        tex->createInternalResources();

        mRenderTarget = NULL;
        mViewport = NULL;
        mRecover = true;
    }
void OnePixelMaterialGenerator::loadResource(Ogre::Resource* resource)
{

	Ogre::Texture* texture = static_cast<Ogre::Texture*>(resource);
	static Ogre::uchar data[3] = {0xFF, 0x7F, 0x7F};

	Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&data, 3, false, true));
	Ogre::Image image;
	image.loadRawData(stream, 1,1,1, Ogre::PF_R8G8B8);
	Ogre::ConstImagePtrList images({&image});

	texture->_loadImages(images);
}
Exemple #6
0
void TexturePreviewEditor::OpenOgreTexture(const QString& name)
{
    if (name.contains(".dds"))
    {
        LogWarning("currently cannot show .dds files. ");
        // Set black background image that will be replaced once the real image has been received.
        QImage emptyImage = QImage(QSize(256, 256), QImage::Format_ARGB32);
        emptyImage.fill(qRgba(0,0,0,0));
        if ( imageLabel_ != 0)
            imageLabel_->setPixmap(QPixmap::fromImage(emptyImage));

        return;
    }

    Ogre::ResourcePtr res = Ogre::TextureManager::getSingleton().getByName(name.toStdString().c_str());
    Ogre::Texture* tex = static_cast<Ogre::Texture* >(res.get());
    if (!tex)
    {
        LogWarning("Failed to open Ogre texture " + name.toStdString() + " .");
        return;
    }

    int width = tex->getWidth();
    int height = tex->getHeight();
    Ogre::Box bounds(0, 0, width, height);
    Ogre::uchar* pixelData = new Ogre::uchar[width * height * 4];
    Ogre::PixelBox pixels(bounds, Ogre::PF_A8R8G8B8, pixelData);
    tex->getBuffer()->blitToMemory(pixels);
    
    // Create image of texture, and show it into label.

    u8* p = static_cast<u8 *>(pixels.data);
    int widthPixels = pixels.getWidth();
    int heightPixels= pixels.getHeight();
    
    QImage img = ConvertToQImage(p, widthPixels, heightPixels, 4);

    if(!img.isNull() && imageLabel_ != 0)
    {
        imageLabel_->setPixmap(QPixmap::fromImage(img));
        imageLabel_->show();
    }

    delete[] pixelData;
}
void TestGame::DrawPlanetMap(Logic::PlanetJustGenerateEvent *evnt){

	std::map<Logic::BaseCountry*,std::vector<Logic::CountryTile>>::iterator CntrItr;
	std::vector<Logic::CountryTile>::iterator TileItr;
	int tilesize=TILESIZE;
	bool why;
	Ogre::Vector3 tempVect;
	int maxX = (int)Logic::BaseAsset::GetSigleton("MAP_X"),maxY=(int)Logic::BaseAsset::GetSigleton("MAP_Y");
	Ogre::SceneNode* node,*capitalNode,*mapnode =mSceneMgr->getRootSceneNode()->createChildSceneNode("Map");
	mapnode->translate(-maxX/2*tilesize,-maxY/2*tilesize,0);

	Ogre::Entity* entNinja = 0;

	
	Ogre::FontPtr font = Ogre::FontManager::getSingleton().getResourceIterator().begin()->second; 

	// Make sure the texture is not WRITE_ONLY, we need to read the buffer to do the blending with the font (get the alpha for example)




	int j =0;
	for(CntrItr=evnt->allTiles.begin();CntrItr!=evnt->allTiles.end(); CntrItr++){

		Ogre::ManualObject* manual = mSceneMgr->createManualObject("CountryObject"+CntrItr->first->mName);

		Ogre::Texture* texture = Ogre::TextureManager::getSingleton().createManual("CountryText"+CntrItr->first->mName,"General",Ogre::TEX_TYPE_2D,512, 512, 0, Ogre::PF_FLOAT32_RGBA , Ogre::TU_DEFAULT).getPointer();
		Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("CountryMaterial"+CntrItr->first->mName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		//Draw the background to the new texture
		Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();

		// Lock the pixel buffer and get a pixel box
		pixelBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD!
		const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();

		float *pDest = static_cast<float*>(pixelBox.data);
		Ogre::ColourValue *temp = &CntrItr->first->mColor;
		// Fill in some pixel data. This will give a semi-transparent blue,
		// but this is of course dependent on the chosen pixel format.
		
		for (size_t k = 0; k < 512; k++)
			for(size_t q = 0; q < 512; q++)
			{
				*pDest++ =temp->b; // B
				*pDest++ = temp->g;
				*pDest++ =temp->r;
				*pDest++ = 0; // A*/
				
				/* *pDest++ = 255; // B
        *pDest++ =   0; // G
        *pDest++ =   0; // R
        *pDest++ = 127; // A*/
			}

			// Unlock the pixel buffer
			pixelBuffer->unlock();






			///WriteToTexture(Logic::LogicStd::IntToString(j),Ogre::TexturePtr(texture),Ogre::Image::Box(25,275,370,500),font,Ogre::ColourValue(1.0,1.0,1.0,1.0),'c');
			 mat->getTechnique(0)->getPass(0)->createTextureUnitState("CountryText"+CntrItr->first->mName);
			// mat->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
			j++;
			// specify the material (by name) and rendering type
			manual->begin("CountryMaterial"+CntrItr->first->mName, Ogre::RenderOperation::OT_TRIANGLE_LIST);
			int i=0;
			for(TileItr= CntrItr->second.begin();TileItr!= CntrItr->second.end();TileItr++){
				
				tempVect = calculateActualPointFromCenter(CntrItr->first->mCapital.mPosition,(*TileItr).mPosition);
				tempVect =tempVect*tilesize;
				manual->position(tempVect.x-tilesize/2,tempVect.y+tilesize/2,tempVect.z);
				//manual->colour(CntrItr->first->mColor);
				manual->position(tempVect.x+tilesize/2,tempVect.y+tilesize/2,tempVect.z);
				//manual->colour(CntrItr->first->mColor);
				manual->position(tempVect.x+tilesize/2,tempVect.y-tilesize/2,tempVect.z);
				//manual->colour(CntrItr->first->mColor);
				manual->position(tempVect.x-tilesize/2,tempVect.y-tilesize/2,tempVect.z);
				//manual->colour(CntrItr->first->mColor);
				manual->triangle(i*4+0,i*4+2,i*4+1);
				manual->triangle(i*4+0,i*4+3,i*4+2);

				//manual->quad(i*4+0,i*4+2,i*4+3,i*4+1);
				i++;
			}


			// tell Ogre, your definition has finished
			manual->end();

			// add ManualObject to the RootSceneNode (so it will be visible)
			node =mapnode->createChildSceneNode();
			entNinja= mSceneMgr->createEntity("Capital/"+CntrItr->first->mName, "capital.mesh");
			entNinja->setCastShadows(true);
			entNinja->setMaterialName("CountryMaterial"+CntrItr->first->mName);
			Control::ClickHelper* helpr = 	new Control::ClickHelper(Logic::CHT_COUNTRY);
			helpr->target = CntrItr->first;
			entNinja->setUserAny(Ogre::Any(helpr));
			CntrItr->first->mNode = node;
			capitalNode = node->createChildSceneNode();
			capitalNode->attachObject(entNinja);
			capitalNode->pitch(Ogre::Degree(90));
			node->attachObject(manual);
			// I move the SceneNode so that it is visible to the camera.
			tempVect = 	Ogre::Vector3(CntrItr->first->mCapital.mPosition.x*tilesize,CntrItr->first->mCapital.mPosition.y*tilesize,-10);
			node->translate(tempVect);


	} 
	mapnode->pitch(Ogre::Degree(-45));


}
Exemple #8
0
void
Terrain::loadResource(Ogre::Resource* resource)
{
	const Ogre::String& name = resource->getName();
    if (name.find("<Lightmap>") !=Ogre::String::npos)
	{
       Ogre::String::size_type left_parentheses = name.find_first_of('(');
       Ogre::String::size_type right_parentheses = name.find_last_of(')');
        if (left_parentheses ==Ogre::String::npos ||
            right_parentheses ==Ogre::String::npos)
        {
            OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR,
                "Unorganised lightmap texture name '" + name + "'",
                "Terrain::loadResource");
        }

        Ogre::StringVector vec = Ogre::StringUtil::split(
            name.substr(left_parentheses + 1, right_parentheses - left_parentheses - 1), ",", 2);
        if (vec.size() != 2)
        {
            OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR,
                "Unorganised lightmap texture name '" + name + "'",
                "Terrain::loadResource");
        }

        int nPosX = Ogre::StringConverter::parseInt(vec[0]);
        int nPosZ = Ogre::StringConverter::parseInt(vec[1]);
        if (nPosX < 0 || nPosX >= mData->mNumTilePerX ||
            nPosZ < 0 || nPosZ >= mData->mNumTilePerZ)
        {
            OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR,
                "Unorganised lightmap texture name '" + name + "'",
                "Terrain::loadResource");
        }

        Ogre::uint uWidth, uHeight;
        if (getLightmapQuality() == LMQ_LOW)
        {
            uWidth = mData->mTileSize * 2;
            uHeight = mData->mTileSize * 2;
        }
        else
        {
            uWidth = mData->mTileSize * 8;
            uHeight = mData->mTileSize * 8;
        }

		Ogre::Texture* pTexture = static_cast<Ogre::Texture*>(resource);
        if (pTexture->getWidth() != uWidth || pTexture->getHeight() != uHeight)
        {
            pTexture->freeInternalResources();
            pTexture->setWidth(uWidth);
            pTexture->setHeight(uHeight);
        }
		pTexture->createInternalResources();

		Ogre::HardwarePixelBufferSharedPtr bufferPtr = pTexture->getBuffer();
        size_t l = nPosX * mData->mTileSize * 8;
        size_t t = nPosZ * mData->mTileSize * 8;
        size_t r = l + mData->mTileSize * 8;
        size_t b = t + mData->mTileSize * 8;
        if (r > mData->mLightmapImage->getWidth())
            r = mData->mLightmapImage->getWidth();
        if (b > mData->mLightmapImage->getHeight())
            b = mData->mLightmapImage->getHeight();
		bufferPtr->blitFromMemory(
			mData->mLightmapImage->getPixelBox().getSubVolume(Ogre::Box(l, t, r, b)));
	}
	else
	{
		for (AtlasArray::const_iterator it = mAtlases.begin(); it != mAtlases.end(); ++it)
		{
			if (it->texture.get() == resource)
			{
                assert(!it->image.isNull());
				it->texture->loadImage(*it->image);
				break;
			}
		}
	}
}
void saveAsDotScene(const QString& path, QFile& file, Ogre::SceneManager* sceneManager)
{
    Ogre::MeshSerializer* mMeshSerializer = new Ogre::MeshSerializer();
    Ogre::MaterialSerializer* mMaterialSerializer = new Ogre::MaterialSerializer();

    int idCounter = 3;
    if (!file.open(QIODevice::WriteOnly))
    {
        /* show wrror message if not able to open file */
        QMessageBox::warning(0, "Read only", "The file is in read only mode");
    }
    else
    {
        Ogre::SceneManager::MovableObjectIterator iterator = sceneManager->getMovableObjectIterator("Entity");
        QXmlStreamWriter* xmlWriter = new QXmlStreamWriter();
        xmlWriter->setAutoFormatting(true);
        xmlWriter->setDevice(&file);
        xmlWriter->writeStartElement("scene");
        xmlWriter->writeAttribute("formatVersion","");

        xmlWriter->writeStartElement("nodes");
        while(iterator.hasMoreElements())
        {
            Ogre::Entity* e = static_cast<Ogre::Entity*>(iterator.getNext());
            Ogre::Any any = e->getParentNode()->getUserAny();
            Ogre::String widgetType("");
            if(!any.isEmpty()){
                widgetType = any_cast<Ogre::String>(any);
            }
            Ogre::String tmp(widgetType + ":" + e->getParentNode()->getName());
            QString nodeName(tmp.c_str());
            xmlWriter->writeStartElement("node");
            xmlWriter->writeAttribute("name", nodeName);
            xmlWriter->writeAttribute("id", QString::number(idCounter++));


            xmlWriter->writeStartElement("position");
            xmlWriter->writeAttribute("x", QString::number(e->getParentNode()->getPosition().x));
            xmlWriter->writeAttribute("y", QString::number(e->getParentNode()->getPosition().y));
            xmlWriter->writeAttribute("z", QString::number(e->getParentNode()->getPosition().z));
            xmlWriter->writeEndElement();

            xmlWriter->writeStartElement("scale");
            xmlWriter->writeAttribute("x", QString::number(e->getParentNode()->getScale().x));
            xmlWriter->writeAttribute("y", QString::number(e->getParentNode()->getScale().y));
            xmlWriter->writeAttribute("z", QString::number(e->getParentNode()->getScale().z));
            xmlWriter->writeEndElement();

            xmlWriter->writeStartElement("entity");
            xmlWriter->writeAttribute("name", nodeName);
            xmlWriter->writeAttribute("meshFile", nodeName.toLower() + QString(".mesh") );
            xmlWriter->writeAttribute("static", QString("false"));
            xmlWriter->writeEndElement();

            const Mesh* mesh = e->getMesh().getPointer();


            mMeshSerializer->exportMesh(mesh,String(path.toStdString() +
                                                    nodeName.toLower().toStdString() +
                                                    ".mesh" ));


            std::cout << "numeber" <<  mesh->getNumSubMeshes() << std::endl;


            for(int i = 0; i < e->getNumSubEntities(); i++){


                Ogre::Material *mat = static_cast<Ogre::Material*>
                        (Ogre::MaterialManager::getSingletonPtr()->getByName(e->getSubEntity(i)->getMaterialName()).getPointer());

                //e->getMesh().get()->getSubMesh()
                if(mat->getTechnique(0)->getPass(0)->getNumTextureUnitStates() !=0){
                Ogre::String str = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName();

            Ogre::MaterialPtr mMatPtr =e->getSubEntity(i)->getMaterial()    ;

            mMaterialSerializer->exportMaterial(mMatPtr ,
                                                String(path.toStdString() +
                                                       nodeName.toLower().toStdString() +
                                                       QString::number(i).toStdString() + ".material" ));
            Ogre::TexturePtr* mTexPtr = new Ogre::TexturePtr(Ogre::TextureManager::getSingletonPtr()->getByName(str));
            Ogre::Texture* mTex = mTexPtr->getPointer();
            Ogre::PixelFormat pxf = mTex->getFormat();
            Ogre::Image mImage;
            mTex->convertToImage(mImage);
            std::cout << str << std::endl;
            mImage.save(String(path.toStdString() +
                                 str));
                }
}
            //material file merge

            for(int i = 0; i < e->getNumSubEntities(); i++){
                Ogre::Material *mat = static_cast<Ogre::Material*>
                        (Ogre::MaterialManager::getSingletonPtr()->getByName(e->getSubEntity(i)->getMaterialName()).getPointer());


                QString mMatFilePath = QString((path.toStdString() +
                                               nodeName.toLower().toStdString() +
                                                ".material").c_str()) ;


                 QFile mFile(mMatFilePath);
                 if (!mFile.open(QIODevice::Append))
                 {
                     /* show wrror message if not able to open file */
                     QMessageBox::warning(0, "Read only", "The file is in read only mode");
                 }
                 else{
                     QTextStream out(&mFile);

                     QString mTempMatPath = QString((path + nodeName.toLower() + QString::number(i) + ".material"));

                     QFile mTempMatFile(mTempMatPath);
                     mTempMatFile.open(QIODevice::ReadOnly);

                     QTextStream src(&mTempMatFile);

                     mFile.write(src.readAll().toStdString().c_str());
                     mTempMatFile.remove();

                 }



            }


            xmlWriter->writeEndElement();


        }

        xmlWriter->writeEndElement();
        xmlWriter->writeEndDocument();
        delete xmlWriter;
    }

    delete mMeshSerializer;
    delete mMaterialSerializer;
}
Exemple #10
0
void OgreInfo::diagnose(std::ostream& outputStream)
{
	Ogre::SceneManagerEnumerator::SceneManagerIterator sceneManagerI = Ogre::Root::getSingleton().getSceneManagerIterator();
	while (sceneManagerI.hasMoreElements()) {
		Ogre::SceneManager* sceneManager = sceneManagerI.getNext();
		outputStream << "Scenemanager(" << sceneManager->getTypeName() << ") " << sceneManager->getName() << std::endl;
		outputStream << " Number of scene nodes: " << countNodes(sceneManager->getRootSceneNode()) << std::endl;
		outputStream << " Movable objects:" << std::endl;
		unsigned int movableObjectCounter = 0;
		Ogre::Root::MovableObjectFactoryIterator movableObjectFactoryI = Ogre::Root::getSingleton().getMovableObjectFactoryIterator();
		while (movableObjectFactoryI.hasMoreElements()) {
			Ogre::MovableObjectFactory* factory = movableObjectFactoryI.getNext();
			std::string type(factory->getType());
			{
				Ogre::SceneManager::MovableObjectIterator I = sceneManager->getMovableObjectIterator(type);
				while (I.hasMoreElements()) {
					movableObjectCounter++;
					Ogre::MovableObject* movable = I.getNext();
					if (movable->getMovableType() == "Light") {
						Ogre::Light* light = static_cast<Ogre::Light*> (movable);
						outputStream << "  * Light " << light->getName() << "(" << (light->isInScene() ? "in scene" : "not in scene") << ")" << std::endl;
						outputStream << "   Pos: " << light->getDerivedPosition() << std::endl;
						outputStream << "   Direction: " << light->getDerivedDirection() << std::endl;

					} else {
						std::stringstream ssPosAndOrientation;
						if (movable->getParentSceneNode() && movable->isInScene()) {
							ssPosAndOrientation << " pos: " << movable->getParentSceneNode()->getPosition() << " orientation: " << movable->getParentSceneNode()->getOrientation();
						}
						outputStream << "  * " << type << " " << movable->getName() << "(" << (movable->isInScene() ? "in scene" : "not in scene") << ")" << ssPosAndOrientation.str() << std::endl;
						//					outputStream << "  Pos: " << light->getDerivedPosition() << std::endl;
						//					outputStream << "  Direction: " << light->getDerivedDirection() << std::endl;
					}
				}
			}
		}

		outputStream << " Number of movable objects: " << movableObjectCounter << std::endl;

		outputStream << " Cameras:" << std::endl;
		{
			Ogre::SceneManager::CameraIterator I = sceneManager->getCameraIterator();
			while (I.hasMoreElements()) {
				Ogre::Camera* camera = I.getNext();
				outputStream << "  Camera " << camera->getName() << "(" << (camera->isInScene() ? "in scene" : "not in scene") << ")" << std::endl;
				outputStream << "  Pos: " << camera->getDerivedPosition() << std::endl;
				outputStream << "  Direction: " << camera->getDerivedDirection() << std::endl;
				outputStream << "  Clip distances: " << camera->getNearClipDistance() << " - " << camera->getFarClipDistance() << std::endl;
			}
		}

	}

	size_t resourceMemoryUsage = 0;
	outputStream << "Resource Managers:" << std::endl;
	Ogre::ResourceGroupManager::ResourceManagerIterator I = Ogre::ResourceGroupManager::getSingleton().getResourceManagerIterator();
	while (I.hasMoreElements()) {
		std::string name = I.peekNextKey();
		Ogre::ResourceManager* manager = I.getNext();
		outputStream << " Resource Manager: " << name << std::endl;
		if (manager->getMemoryBudget() == std::numeric_limits<size_t>::max()) {
			outputStream << "  Memory budget: not set" << std::endl;
		} else {
			outputStream << "  Memory budget: " << manager->getMemoryBudget() << " bytes" << std::endl;
		}
		outputStream << "  Memory usage:  " << manager->getMemoryUsage() << " bytes" << std::endl;
		resourceMemoryUsage += manager->getMemoryUsage();

		Ogre::ResourceManager::ResourceMapIterator resourceI = manager->getResourceIterator();
		if (resourceI.hasMoreElements()) {
			outputStream << "  Resources: " << std::endl;
			int resourceCount = 0;
			int loadedResourceCount = 0;
			while (resourceI.hasMoreElements()) {
				Ogre::ResourcePtr resource = resourceI.getNext();
				if (resource->isLoaded()) {
					std::string reloadable = resource->isReloadable() ? " reloadable" : "";
					outputStream << "   " << resource->getName() << " ( " << resource->getSize() << " bytes)" << reloadable;
					Ogre::Texture* texture = dynamic_cast<Ogre::Texture*>(resource.get());
					if (texture) {
						outputStream << texture->getWidth() << "x" << texture->getHeight() << " ";
					}
					outputStream << std::endl;
					loadedResourceCount++;
				}
				resourceCount++;
			}
			outputStream << "  Total number of resources: " << resourceCount << std::endl;
			outputStream << "  Number of loaded resources: " << loadedResourceCount << std::endl;
		}
	}

	outputStream << "Total memory usage for all resource manager: " << resourceMemoryUsage << " bytes" << std::endl;

	outputStream << std::flush;
}
HCURSOR	CUIIconsManager::CreateAsWinCursor(LPCTSTR szIconName)
{
	try{
	//-------------------------------------------------------
	//CEGUI Image
	const CEGUI::Image* pIconImage = GetIcon(szIconName);
	if(!pIconImage) return NULL;

	//-------------------------------------------------------
	//CEGUI ImageSet
	CEGUI::Imageset* pImageset = CEGUI::ImagesetManager::getSingleton().getImageset(pIconImage->getImagesetName());
	if(!pImageset) return NULL;

	//-------------------------------------------------------
	//CEGUI Ogre Texture
	CEGUI::OgreCEGUITexture* pCEGUIOgreTexture = (CEGUI::OgreCEGUITexture*)(pImageset->getTexture());
	if(!pCEGUIOgreTexture) return NULL;

	//-------------------------------------------------------
	//Ogre Texture
	Ogre::Texture* pOgreTexture = pCEGUIOgreTexture->getOgreTexture().get();
	if(!pOgreTexture) return NULL;

	//-------------------------------------------------------
	//Ogre HardwarePixelBuffer
	Ogre::HardwarePixelBuffer* pOgreHardPixBuf = pOgreTexture->getBuffer().get();
	if(!pOgreHardPixBuf) return NULL;

	//-------------------------------------------------------
	//Blt to Ogre PixelBox
	const static INT s_CursorWidth  = 32;
	const static INT s_CursorHeight = 32;

	CEGUI::Rect rectAtImage = pIconImage->getSourceTextureArea();
	const Ogre::PixelBox thePixBox(s_CursorWidth, s_CursorHeight, 1, Ogre::PF_R8G8B8A8, new char[s_CursorWidth*s_CursorHeight*Ogre::PixelUtil::getNumElemBytes(Ogre::PF_R8G8B8A8)]);
	pOgreHardPixBuf->blitToMemory(
		Ogre::Image::Box((INT)rectAtImage.d_left, (INT)rectAtImage.d_top, (INT)rectAtImage.d_right, (INT)rectAtImage.d_bottom), thePixBox);

	//-------------------------------------------------------
	//Create Windows Bitmap as XOR Mask

	HDC hMainDC			= ::GetDC(NULL);
	HDC hXorMaskDC		= ::CreateCompatibleDC(hMainDC); 
	HBITMAP hXorMask	= ::CreateCompatibleBitmap(hMainDC, s_CursorWidth, s_CursorHeight);
	::SelectObject(hXorMaskDC, hXorMask);

	//-------------------------------------------------------
	//Get per Pixel Color to XOR Mask
	for(register INT x=0; x<s_CursorWidth; x++)
	{
		for(register INT y=0; y<s_CursorHeight; y++)
		{
			Ogre::ColourValue col;
			VOID* pColData = (thePixBox.rowPitch*y + x)* Ogre::PixelUtil::getNumElemBytes(thePixBox.format) + 
							 (unsigned char*)thePixBox.data;

			Ogre::PixelUtil::unpackColour( &col, thePixBox.format, pColData);

			::SetPixel(hXorMaskDC, x, y, RGB(col.r*255, col.g*255, col.b*255));
		}
	}
	delete[] thePixBox.data;
	::DeleteDC(hXorMaskDC); hXorMaskDC = NULL;

	//-------------------------------------------------------
	//Create AND Mask
	HDC hAndMaskDC	= ::CreateCompatibleDC(hMainDC); 
	HBITMAP hAndMask	= ::CreateCompatibleBitmap(hMainDC, s_CursorWidth, s_CursorHeight);
	::SelectObject(hAndMaskDC, hAndMask);

	RECT rect;
	::SetRect(&rect, 0, 0, s_CursorWidth, s_CursorHeight);
	::FillRect(hAndMaskDC, &rect, (HBRUSH)::GetStockObject(BLACK_BRUSH));

	::DeleteDC(hAndMaskDC); hAndMaskDC = NULL;

	//-------------------------------------------------------
	//Create Crusor
	ICONINFO iconinfo = {0};
	iconinfo.fIcon		= FALSE;
	iconinfo.xHotspot	= 0;
	iconinfo.yHotspot	= 0;
	iconinfo.hbmMask	= hAndMask;
	iconinfo.hbmColor	= hXorMask;

	HCURSOR hRetCursor = ::CreateIconIndirect(&iconinfo);

	//-------------------------------------------------------
	//Release
	::DeleteObject(hAndMask);
	::DeleteObject(hXorMask);
	::ReleaseDC(NULL,hMainDC);

	return hRetCursor;
	
	}catch(...)
	{
		return 0;
	}
}