# Problem w/ RHW in my Vertex Class (C++)

This topic is 4352 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Whenever I declare my Vertex class, I currently use x/y/z/color/u/v, and my DrawPrimitiveUP() calls work fine. However, if I add in a rhw value in between z and color (and adjust the D3DFVF_'s accordingly), I have to change my z value to 0.0f and my stuff hardly even shows up on the screen (shows up at the top left). (My rhw is set to 1.0f at this point.) I don't see why this is happening, I've never had to change my rhw code. Here's an example of what makes a "point" show up at the top left of the screen instead of in the middle where it should be:
// NOTE:  MAJOR clipping in this file - I just have the bare minimum
// as to what code is wrong

#define D3DFVF_CUSTOM (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)

struct CVertex
{
float x, y, z, rhw;
DWORD color;
float u, v;
};

CVertex vtxPoint;

void Setup()
{
// major clip here
vtxPoint.x = 0.0f;
vtxPoint.y = 0.0f;
vtxPoint.z = 0.0f;
vtxPoint.rhw = 1.0f;
vtxPoint.color = 0xffffffff;
vtxPoint.u = 0.0f;
vtxPoint.v = 0.0f;
}

void Render()
{
pd3dDevice->SetFVF(D3DFVF_CUSTOM);
pd3dDevice->DrawPrimitiveUP(D3DPT_POINTLIST, 1, &vtxPoint, sizeof(CVertex));
}


Yes, my Matrixes are setup correctly (even if I remove all my matrix setup code it still renders wrong). The only way to make that point back where it should be is to remove the RHW value and set the z back to 1.0f.

##### Share on other sites
D3DFVF_XYZRHW is a PRE-transformed vertex; that is, you're explicitly telling Direct3D that you've done all the vertex processing and that it should just pass it through to the clipping/rasterization stages.

Your matrix setup will be ignored as will any materials/lighting. With a vertex defined at <0,0,0,1> it should indeed be in the top-left corner. Setting Z to larger values will move it "back" behind other 3D geometry (if there is any). Pre-transformed geometry has its coordinates in screen-space.

hth
Jack

##### Share on other sites
Ah! Sorry for my stupidity. I'm using things yet I don't even know what they do... Thanks for the help. I found a new method of rendering 2D things though, at least :D.

• 47
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631374
• Total Posts
2999647
×