Display image in quadrilateral

Started by
5 comments, last by renega_666 12 years, 7 months ago
Hello,

I am drawing a texture using Sprite.Draw(...) function, My requirement to display this texture in quadrilateral whose co-ordinate provide by user. How can i do this? Any code sample would be great.

Thanks,
Firoz Khan
Advertisement
Which version of DirectX are you using?

If you're using DirectX 9 you can this way:

LPD3DXSPRITE pSprite=NULL;
If (FAILED(D3DXCreateSprite(pDevice,&pSprite))
{
//Handle fail
}

//Define position
D3DXVECTOR3 spritePos;

spritePos;.x=10.0f;
spritePos;.y=20.0f;
spritePos;.z=0.0f;

//Draw
pSprite->Begin(D3DXSPRITE_ALPHABLEND);
pSprite->Draw(pTexture,NULL,NULL,&spritePos;,0xFFFFFFFF);
pSprite->End();
Yes am using DirectX 9, E:Untitled.pngE:Untitled.png

This solution will display sprite iE:Untitled.pngn regular Rectangle shape, but i want to display in irregular rectangle like

[attachment=5516:Untitled.png]

Yes am using DirectX 9, E:Untitled.pngE:Untitled.png

This solution will display sprite iE:Untitled.pngn regular Rectangle shape, but i want to display in irregular rectangle like

[attachment=5516:Untitled.png]



Just render it with a perspective projection and apply a rotation on your quad (you might need to adjust the pivot point of the quad though)

[quote name='khancoder' timestamp='1316611501' post='4864190']
Yes am using DirectX 9, E:Untitled.pngE:Untitled.png

This solution will display sprite iE:Untitled.pngn regular Rectangle shape, but i want to display in irregular rectangle like

[attachment=5516:Untitled.png]



Just render it with a perspective projection and apply a rotation on your quad (you might need to adjust the pivot point of the quad though)
[/quote]


Thanks for reply could you please share some sample, as i m new to this area.
Render a textured quad instead of a sprite. If you want the texture to be warped properly when your quad is converted to triangles you might need to use a shader that correctly calculates the texcoords.
Well, drawing a quad is a really simple task but I don't have any sample here that you could compile and run.
I suggest you to begin by learning the basic stuff: what is a primitive, what is a vertex buffer, what is a projection matrix, transform matrix,etc... Afterwards you should have a good grasp on how to render a simple textured quad.

Here are a series of tutorials that covers the basic: http://www.two-kings.de/tutorials/dxgraphics/ (I personnaly started with them a few months ago)

This topic is closed to new replies.

Advertisement