SetVertexShader problem

Started by
7 comments, last by Todilo 18 years, 8 months ago
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.
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.
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
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.

Coder knows all...
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.
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);

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]
Andre Loker | Personal blog on .NET
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).

This topic is closed to new replies.

Advertisement