Sign in to follow this  

No Overloaded Function Takes 4 Arguments Error

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

Im trying to follow the "Introduction to 3D Game Programming with DirectX 9" book and have worked up to the colours chapter. In the book they create a color vertex struct as so:
struct MyColorVertex
{
	float x, y, z;
	D3DCOLOR color;
	static const DWORD FVF;
};

And then create the vertices using (it has been locked):
MyColorVertex* v;

..Lock Code..

v[0] = MyColorVertex(-1.0f, 0.0f, 2.0f, D3DCOLOR_XRGB(255, 0, 0));

..Unlock Code..

When I compile I get the error: No Overloaded Function Takes 4 Arguments What am I doing wrong?

Share this post


Link to post
Share on other sites
Quote:
Original post by mengha
v[0] = MyColorVertex(-1.0f, 0.0f, 2.0f, D3DCOLOR_XRGB(255, 0, 0));


Here, you are attempting to create a new vertex using a constructor that accepts 4 parameters. So, you need to add code for a constructor that accepts x, y, z, color, and copies them into the struct's member variables.

roos

Share this post


Link to post
Share on other sites

struct Vertex
{
Vertex(){};
Vertex(float x, float y, float z, D3DCOLOR Color)
{
mx = x; my = y; mz = z; mColor = Color;
};
float mx, my, mz;
D3DCOLOR mColor;
static const DWORD FVF;
};




simple as that, you might find it helpful to download the demo programs from the books website so if you run into any trouble you can refer to it and see what they did.

Share this post


Link to post
Share on other sites
Quote:
Original post by Jemburula
*** Source Snippet Removed ***

simple as that


Almost!


Vertex(float x, float y, float z, D3DCOLOR Color) :
mx(x), my(y), mz(z), mColor(Color)
{}

Share this post


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