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
Display image in quadrilateral
Which version of DirectX are you using?
If you're using DirectX 9 you can this way:
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,
This solution will display sprite in regular Rectangle shape, but i want to display in irregular rectangle like
[attachment=5516:Untitled.png]
This solution will display sprite in regular Rectangle shape, but i want to display in irregular rectangle like
[attachment=5516:Untitled.png]
Yes am using DirectX 9,
This solution will display sprite in 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,
This solution will display sprite in 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)
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
Popular Topics
Advertisement