Jump to content
  • Advertisement
Sign in to follow this  

How to implement the projective texrue using DirectX?

This topic is 5037 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

Hi, Happy new year! I'm new to DirectX and don't know how to implement the projective texrue. For example I project a texture onto a plane! Could you give me some suggestions or a simple example? Thank you in advance!

Share this post

Link to post
Share on other sites
Sorry, I implemented such codes using OpenGL before and new to DirectX, so I want to know how to implement it using DirectX:)
Any suggestions? Thank you.

Share this post

Link to post
Share on other sites
See the "Special Effects" section of the SDK documentation for instructions on how to enable projective texturing on fixed-function T&L pipe. If you're using shaders with your OGL implementation, you already have the knowledge to do so in DX also - provided you can use vertex shaders to begin with.

Do ask more info if needed [smile]

Share this post

Link to post
Share on other sites
Hi, Nik02
I did it just following the "Special Effect" part of SDK.
First I used SetTexture to bind a texture, and then called the following code
and set the texture matrix using the following code:
D3DXMATRIXA16 matView;
D3DXVECTOR3 vEyePt(0, 0, 6);
D3DXVECTOR3 vLookatPt(0, 0, -5);
D3DXVECTOR3 vUpVec(0, 1, 0);
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);

D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );

D3DXMATRIXA16 matScale;
D3DXMatrixScaling(&matScale, 0.5, 0.5, 1);

D3DXMATRIXA16 matTranslate;
D3DXMatrixTranslation(&matTranslate, 0.5, 0.5, 0);

D3DXMATRIXA16 matTexture;
matTexture = matTranslate*matScale*matProj*matView;

g_pd3dDevice->SetTransform(D3DTS_TEXTURE0, &matTexture);
At last I called SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_PROJECTED | D3DTTFF_COUNT3) and drawed a plane.
But I can't get the correct result , what's wrong with my methods?
Thank you!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!