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();
}
Esempio n. 2
0
void CzPlatformRender::DrawPrimitives(CzRenderPrim3* prims, CzRenderMaterial* materials, int num_prims, bool single_material)
{
	while (num_prims-- > 0)
	{
		CIwMaterial::AlphaMode am = (CIwMaterial::AlphaMode)materials->AlphaMode;	// TODO Add proper method to map Marmalade Alpha mode to Marmalade
		int vc = prims->VertCount;

		// Set up vertex streams
		if (prims->UVs != NULL)
			IwGxSetUVStream((CIwFVec2*)prims->UVs, 0);
		else
			IwGxSetUVStream(NULL);
		if (prims->ModelSpace)
			IwGxSetVertStreamModelSpace((CIwFVec3*)prims->Verts, vc);
		else
			IwGxSetVertStreamViewSpace((CIwFVec3*)prims->Verts, vc);
		IwGxSetColStream((CIwColour*)prims->Colours);
		IwGxSetNormStream((CIwFVec3*)prims->Normals);

		CzTexture texture = materials->Image->getTexture();
		CIwTexture* mt = static_cast<CIwTexture*>(texture);
		bool filter;
		if (materials->Image->isFilterSet())
			filter = mt->GetFiltering();
		else
			filter = materials->Filter;

		// Only create new render material if something important has changed
		if (texture != CurrentTexture || CurrentAlphaMode != materials->AlphaMode || CurrentFilter != filter || CurrentTexture == NULL || CurrentTiled != materials->Tiled)
		{
			CIwMaterial* mat = IW_GX_ALLOC_MATERIAL();
			mat->SetTexture(mt);
			mat->SetDepthWriteMode(CIwMaterial::DEPTH_WRITE_DISABLED);
			mat->SetClamping(!materials->Tiled);
			mat->SetFiltering(filter);
			mat->SetAlphaMode(am);
			mat->SetCullMode(CIwMaterial::CULL_BACK);
//			mat->SetCullMode(CIwMaterial::CULL_NONE);
			IwGxSetMaterial(mat);
			CurrentTexture = texture;
			CurrentAlphaMode = materials->AlphaMode;
			CurrentTiled = materials->Tiled;
			CurrentFilter = filter;
		}
		else
		{
			RedundantTextureCalls++;
		}
	
		// Render the primitive
		IwGxDrawPrims(CzToIwGxPrimType[prims->Type], prims->Indices, prims->IndicesCount);

		// Move to next primitive
		prims++;
		if (!single_material)
			materials++;
	}
}
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;
}