This topic is now archived and is closed to further replies.

Questions about vertices

This topic is 5626 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''m getting kind of confused about the co-ordinate systems of vertices. I have a create vertices function that looks something like this.
  void CVertex::Create(float fp_fX,float fp_fY,float fp_fZ,
					 float fp_fR,float fp_fG,float fp_fB,
					 float fp_fU,float fp_fV)
	posX = fp_fX;  //X co-ord

	posY = fp_fY;  //Y co-ord

	posZ = fp_fZ;  //Z co-ord

	colour = D3DCOLOR_XRGB((BYTE)(fp_fR*255), (BYTE)(fp_fG*255), (BYTE)(fp_fB*255));

	textU = fp_fU;  //Texture position

	textV = fp_fV;  //Texture position

Now i''m working on the assumption that the co-ordinates of the screen start from (0,0,0) at the bottom left off the monitor screen!!! So why is it that when I do this
  CVertex* vtxQuad;
vtxQuad = (CVertex*)Vertices.GetMemoryPointer();
vtxQuad[0].Create(0, 0, 0, 1, 0, 0, 0, 1);
vtxQuad[1].Create(0, 0.5, 0, 0, 1, 0, 0, 0);
vtxQuad[2].Create(0.5, 0, 0, 0, 1, 0, 1, 1);
vtxQuad[3].Create(0.5, 0.5, 0, 0, 0, 1, 1, 0);

It creates a square much bigger than I thought (I presumed that the co-ords worked on pixel position) in the upper right quadrant of the screen????????

Share this post

Link to post
Share on other sites
If you use transformed vertices (includes D3DFVF_XYZRHW), then the vertices relate to pixels, with (0,0) being the top left corner, and (799,599) being the bottom right on a 800x600 screen.

If you use non-transformed verices (D3DFVF_XYZ), then the points are in world space, and where they appear on the screen depends on the position and direction of the camera.

HTH, Steve

DirectX Programmer
Soon to be the new Bill Gates

Share this post

Link to post
Share on other sites