Jump to content
  • Advertisement
Sign in to follow this  
Jovan

SetVertexShader error :

This topic is 4843 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 recently picked up DirectX and I am using drunken hyena and andy pike as tutorial websites. Unfortunately I came across a slight error while trying to convert andy pike's DX8 tutorial into DX9 (if thats even the case). g_pD3DDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX); error C2664: 'IDirect3DDevice9::SetVertexShader' : cannot convert parameter 1 from 'int' to 'IDirect3DVertexShader9 *' Without this line, the program compiles/runs fine but I cannot see the triangle it's supposed to create. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Once you have set the shader there is a SetFVF() method which needs to be invoked to set the FVF you are passing in there. SetVertexShader is now a method of D3DXEFFECT interface.

ace

Share this post


Link to post
Share on other sites
Thanks a lot, but even with those modifications, the triangle still won't appear. Is there something I am missing?

struct CreateVertex
{
float x;
float y;
float z;
float rhw;

DWORD colour;
};

const DWORD VertexFVF = (D3DFVF_XYZ | D3DFVF_DIFFUSE);


VOID* pVertices;

//Store each point of the triangle together with it's colour
CreateVertex cvVertices[] =
{
{250.0f, 100.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0),}, //Vertex 1 - Red (250, 100)
{400.0f, 350.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0),}, //Vertex 2 - Green (400, 350)
{100.0f, 350.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255),}, //Vertex 3 - Blue (100, 350)
};

//Create the vertex buffer from our device
if(FAILED(g_pD3DDevice->CreateVertexBuffer(3 * sizeof(CreateVertex),
0, VertexFVF,
D3DPOOL_DEFAULT, &g_pVertexBuffer, NULL)))
{
return E_FAIL;
}

g_pD3DDevice->SetStreamSource(0, g_pVertexBuffer, sizeof(CreateVertex), NULL);
g_pD3DDevice->SetVertexShader(NULL);
g_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
g_pD3DDevice->SetFVF(VertexFVF);



I also unlocked the vertex buffer.

Share this post


Link to post
Share on other sites
Quote:
Original post by Jovan
struct CreateVertex
{
float x;
float y;
float z;
float rhw;

DWORD colour;
};

const DWORD VertexFVF = (D3DFVF_XYZRHW | D3DFVF_DIFFUSE);


Share this post


Link to post
Share on other sites
As Konfusius said, you have the wrong FVF defined. But you are also calling the SetFVF routine after DrawPrimitive. DrawPrimitive is the final call, it's the big dog. It takes the render states, the texture settings, the fixed function pipeline settings, and then commences drawing. I haven't done 2D in a while, but you may also need to change D3DCOLOR_XRGB to D3DCOLOR_ARGB and set the alpha values to 255. It will depend on your render states if it matters.

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!