Ejemplo n.º 1
0
void CzPlatformImaging::getTextureInfo(CzTexture texture, CzTextureinfo& texture_info)
{
	CIwTexture* t = static_cast<CIwTexture*>(texture);
	texture_info.Width = t->GetWidth();
	texture_info.Height = t->GetHeight();
	texture_info.Format = toCzImageFormat(t->GetFormat());
	texture_info.Filter = t->GetFiltering();
}
Ejemplo n.º 2
0
void Graphics::DrawTexture(const Rect& screenCoords, int textureId, const Rect& textureCoord, float xOffset, float yOffset)
{
    static CIwSVec2 textureUVs[4];
    static CIwSVec2 screenXY[4];
    static CIwMaterial material;

    CIwTexture* texture = (CIwTexture*)ResourceManager::GetInstance().GetTexture(textureId)->GetData();
    if (!texture)
        return;

    material.Reset();
    material.SetAlphaMode(CIwMaterial::ALPHA_BLEND);
    material.SetTexture(texture);

    int16 width = texture->GetWidth();
    int16 height = texture->GetHeight();

    static const int16 uvSize = 4096;

    // screen coordinates
    screenXY[0] = CIwSVec2((int16)(screenCoords.left + xOffset), (int16)(screenCoords.top + yOffset));
    screenXY[1] = CIwSVec2((int16)(screenCoords.left + xOffset), (int16)(screenCoords.bottom + yOffset));
    screenXY[2] = CIwSVec2((int16)(screenCoords.right + xOffset), (int16)(screenCoords.top + yOffset));
    screenXY[3] = CIwSVec2((int16)(screenCoords.right + xOffset), (int16)(screenCoords.bottom + yOffset));

    // texture's UV coordinates
    textureUVs[0] = CIwSVec2(((int16)textureCoord.left * uvSize) / width, ((int16)textureCoord.top * uvSize) / height);
    textureUVs[1] = CIwSVec2(((int16)textureCoord.left * uvSize) / width, ((int16)textureCoord.bottom * uvSize) / height);
    textureUVs[2] = CIwSVec2(((int16)textureCoord.right * uvSize) / width, ((int16)textureCoord.top * uvSize) / height);
    textureUVs[3] = CIwSVec2(((int16)textureCoord.right * uvSize) / width, ((int16)textureCoord.bottom * uvSize) / height);

    IwGxSetMaterial(&material);
    IwGxSetUVStream(textureUVs);

    IwGxSetColStream(NULL);
    IwGxSetVertStreamScreenSpace(screenXY, 4);
    IwGxDrawPrims(IW_GX_QUAD_STRIP, NULL, 4);

    IwGxFlush();
}
Ejemplo n.º 3
0
CzTexture CzPlatformImaging::CreateTexture(CzTexture source, CzImage::eFormat format)
{
	CIwImage::Format f = toMarmImageFormat(format);
	if (f == CIwImage::FORMAT_UNDEFINED)
		return NULL;
	CIwTexture* t = static_cast<CIwTexture*>(source);

	CIwImage* image = new CIwImage();
	image->SetFormat(f);
	image->SetWidth(t->GetWidth());
	image->SetHeight(t->GetHeight());
	t->GetImage().ConvertToImage(image);

	CIwTexture* texture = new CIwTexture();
	texture->_SetFlags( CIwTexture::NO_CHROMA_KEY_F );
	texture->SetMipMapping(t->GetMipMapping());
	texture->SetFiltering(t->GetFiltering());
	texture->SetModifiable(t->GetModifiable());
	texture->CopyFromImage(image);

	delete image;

	return (CzTexture)texture;
}
Ejemplo n.º 4
0
void MapBackground::DownloadTiles()
{
	CIwTexture* tx = (CIwTexture*)IwGetResManager()->GetResNamed("logo", IW_GX_RESTYPE_TEXTURE);
	uint32 w1 = tx->GetWidth();
	uint32 h1 = tx->GetHeight();

	//static CIwSVec2 uvs[4] =
	//{
	//	CIwSVec2(0 << 12, 0 << 12),
	//	CIwSVec2(0 << 12, 1 << 12),
	//	CIwSVec2(1 << 12, 1 << 12),
	//	CIwSVec2(1 << 12, 0 << 12),
	//};

	static CIwSVec2 uvs[4] =
	{
		CIwSVec2((0 << 12) + 10, (0 << 12) + 10),
		CIwSVec2((0 << 12) + 10, (1 << 12) - 10),
		CIwSVec2((1 << 12) - 10, (1 << 12) - 10),
		CIwSVec2((1 << 12) - 10, (0 << 12) + 10),
	};
	
	int w = w1/2;
	int h = h1/2;

	int counter = 0;

	while (true)
	{
		IwGetHTTPQueue()->Update();
		IwGetNotificationHandler()->Update();
		IwGetMultiplayerHandler()->Update();

		IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);

		CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
		pMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
		pMat->SetTexture(tx);
		IwGxSetMaterial(pMat);

		CIwMat rotMat;
		rotMat.SetIdentity();
		double perCentAngle = (counter / 80.0);
		iwangle degAng = (iwangle)(IW_GEOM_ONE * perCentAngle);

		rotMat.SetRotZ(degAng);
		rotMat.t.z = -0x200;

		IwGxSetViewMatrix(&rotMat);

		CIwSVec3* pWSCoords= IW_GX_ALLOC(CIwSVec3, 4);
		pWSCoords[0].x = -w; pWSCoords[0].y = -h;
		pWSCoords[1].x = -w; pWSCoords[1].y = h;
		pWSCoords[2].x = w; pWSCoords[2].y = h;
		pWSCoords[3].x = w; pWSCoords[3].y = -h;
		pWSCoords[0].z = pWSCoords[1].z = pWSCoords[2].z = pWSCoords[3].z = 0;

		if (!g_bInProgress)
		{
			MapTile* pNextDownload = GetNextDownload(NULL);
			if (pNextDownload)
			{
				IwGetNotificationHandler()->PushNotification((int)this, pNextDownload->szImageUrl, 10*1000);
				g_bInProgress = true;
				LoadMapTileImage(pNextDownload);
			}
			else
			{
				IwGetNotificationHandler()->ClearNotification((int)this);
				break;
			}
		}

		IwGxSetVertStreamWorldSpace(pWSCoords, 4);
		IwGxSetUVStream(uvs);
		IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
		IwGetNotificationHandler()->Render();

		IwGxFlush();
		IwGxSwapBuffers();
		s3eDeviceYield(50);

		counter++;
	}
}