Jump to content
  • Advertisement
Sign in to follow this  

Display image in quadrilateral

This topic is 2434 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

[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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!