Welcome! Log In Create A New Profile

Advanced

How Do I Show A PNG?

Posted by filfat 
How Do I Show A PNG?
May 04, 2012 12:27PM
i use the newest devkitpro and dont know how i shows a image so plz help me
Re: How Do I Show A PNG?
June 06, 2012 02:56PM
If you use Wire3D it's just a matter of a few lines of code:

// create a texture from a png (width and height have to be a power of two)
Texture2D* pTex = WIRE_NEW Texture2D(Importer::LoadPNG("pic.png", false));

// create a renderable object (a quad) and attach the texture
Geometry* pGeo = StandardMesh::CreateQuad(0 /* vertex colors */, 1 /* uvs */);
pGeo->SetMaterial(WIRE_NEW Material);
pGeo->GetMaterial()->AddTexture(pTex, Material::BM_REPLACE);

// scale the quad to the size of the png
pGeo->World.SetScale(Vector3F(pTex->GetImage()->GetBound(0), pTex->GetImage()->GetBound(1), 0));

// create a camera with orthogonal projection
Camera* pCamera = WIRE_NEW Camera(/* isPerspective */ false);

In the mainloop you just render the quad using the camera
GetRenderer()->ClearBuffers();
GetRenderer()->PreDraw(pCamera);
GetRenderer()->Draw(pGeo);
GetRenderer()->PostDraw();
GetRenderer()->DisplayBackBuffer();

Have a look at the samples of Wire3D. If you know C++, it's pretty self explanatory.
Re: How Do I Show A PNG?
June 11, 2012 09:12AM
oh thanks!
Sorry, only registered users may post in this forum.

Click here to login