Jump to content
  • Advertisement
Sign in to follow this  
Todilo

SetVertexShader problem

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

I am VERY new att directx programming(and almost programming in general) and the book I am using(programming role-playing games with directx) uses dx8 but I want to write it in dx9 but unfortunatly I get some errors that I do not know how to fix¨ Code: #define VERTEXFVF (D3DFVF_XYZRHW | D3DFVF_TEX1) SetVertexShader(VERTEXFVF); I get the error: 'SetVertexShader' : cannot convert parameter 1 from 'const int' to 'struct IDirect3DVertexShader9 *' I have tried looking through the msdn library but I couldnt find anything that made sence to a n00b like me.

Share this post


Link to post
Share on other sites
Advertisement
You want SetFVF not SetVertexShader. Open up the DX SDK help file from your start menu and get used to typing in a function in the index to see what parameters it expects, I have to do it regularly.

Share this post


Link to post
Share on other sites
I am assuming that you have the latest DirectX 9 SDK or the DIrectX8 SDK that came with the book you are learning from.

If you do not then you can get the latest one from the Microsoft website.

To answer your question.

#define VERTEXFVF (D3DFVF_XYZRHW | D3DFVF_TEX1)

What you are doing here is declaring a flexible vertex format which defines the layout of the struct you declare for the vertex.

This is NOT what you set as the vertex shader. In fact it is far from it. You have to first create a vertex shader. Once you have a shader you then tell it what FVF you want it to use.

I would suggest delving into the SDKs for the articles that explain how to get a blank window up and running onwards, up to rotating a mesh.

These are a very good introduction into the API. Don't let the book take you too far ahead of yourself otherwise you will only get confused. First start of with simple vertex buffers and the like and move on to shaders only when you have to.

Hope i have helped.

ace

Share this post


Link to post
Share on other sites
Quote:
Original post by Todilo
I am VERY new att directx programming(and almost programming in general) and the book I am using(programming role-playing games with directx) uses dx8 but I want to write it in dx9 but unfortunatly I get some errors that I do not know how to fix¨

Code:
#define VERTEXFVF (D3DFVF_XYZRHW | D3DFVF_TEX1)
SetVertexShader(VERTEXFVF);

I get the error: 'SetVertexShader' : cannot convert parameter 1 from 'const int' to 'struct IDirect3DVertexShader9 *'

I have tried looking through the msdn library but I couldnt find anything that made sence to a n00b like me.

The problem is that SetFVF use to be SetVertexShader in Direct3D 8, but the 2 were separated in Direct3D 9. Most of the Direct3D8 code from the book would work, I assume, but you'll have to watch out for similar changes. When you encounter such a problem, try to check the documentation section "DirectX Graphics->Converting To DirectX 9.0" - it lists the changes between 8 and 9. For example, the problem you just encountered is listed under "Vertex Declaration changes" in the aforementioned documentation page.

Share this post


Link to post
Share on other sites
I scratched my head so much that I almost became bald. First I would like to thank you all for your answers which unfortunatly did not help me solve the problem but get a better understanding. I looked through
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/convertingtodirectx9.asp

But frankly I did not understand it. I mean I see the problem but I can't come up with a solution.

http://pastebin.com/329257

Line 224 is where the problem is.

And again thank you for your support.

Share this post


Link to post
Share on other sites
Quote:
Original post by Todilo
I scratched my head so much that I almost became bald. First I would like to thank you all for your answers which unfortunatly did not help me solve the problem but get a better understanding. I looked through
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/convertingtodirectx9.asp

But frankly I did not understand it. I mean I see the problem but I can't come up with a solution.

http://pastebin.com/329257

Line 224 is where the problem is.

And again thank you for your support.

It's ok, no need for panic! You're still at the beginning, so take it easy [smile]

As for your problem, replace this line:
g_pD3DDevice->SetVertexShader(VERTEXFVF);

With this line:
g_pD3DDevice->SetFVF(VERTEXFVF);

Share this post


Link to post
Share on other sites
Please read the answers. Chris81 told you to use SetFVF instead of SetVertexShader.

Regards,
Andre

[edit]This was not meant to be rude, though! Have fun :)[/edit]

Share this post


Link to post
Share on other sites
ohh now I remember :D. I did as christ told me even though I didnt really think it would work, and well it didnt because I just got a flashing window. Forgot to include the texture though. But I put the texture.bmp in the same folder but still only a a empty screen that exists as soon as it launches.

Edit: I changed it to windowed mode and now it works :D.

Thank you VERY much (especially "Coder" for giving me my hopes back).

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!