# DirectX Coordinate System

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

## Recommended Posts

Hi All! Just introducing myself in DirectX programming, first following the tutorials that i've found on http://www.andypike.com/tutorials/directx8/. I've a question with the directx coordinate system. The triangle that is painted on tutorial 2 has the following coordinates: - 250,100 (RED) - 400,350 (GREEN) - 100,350 (BLUE) I've been thinking in this coordinates and the triangle (i mean the triangle that appears on the window) with this coordinates is "transformed" (or something like that). The transformation seems to be vertical (red vertex appears UP) but it has no sense with the coordinates (i think!) Also I've tried to apply some matrix transformation (rotation & camera settings) but without effect. My vertex format: struct CUSTOMVERTEX { FLOAT x, y, z, rhw; DWORD colour; }; Thanks in advance!!! :) :) :)

##### Share on other sites
Coordinates are counted from the top left of the screen at 0,0. They increase as you go down and right.
So a positive increase in the Y direction would put you further down the screen.

So indeed 250, 100 will be "above" the other two on the screen. Green should be furthest right, and blue furthest left.

##### Share on other sites
The vertices are pre-transformed, which means they won't be run through any transformations in the pipeline. They're declared in screen-coordinates, and as 0,0 is the top left corner on the screen, y=100 is higher than y=350.

##### Share on other sites
Quote:
 Original post by Jacob84The transformation seems to be vertical (red vertex appears UP) but it has no sense with the coordinates (i think!)

The pixels at the top of the screen are start at 0, so of course red is higher than green and blue.
Quote:
 Original post by Jacob84Also I've tried to apply some matrix transformation (rotation & camera settings) but without effect. My vertex format:

You can't do transformations with RHW(well I don't think you can). Take it out and build an orthographic matrix.

Edit: >_<, damn it those where fast.

##### Share on other sites
Great...

Thank you very much... aprox 5 minutes 3 answers.+

This forum is fantastic, thanks!

Jacob

##### Share on other sites
If you want to do transforms and stuff you'll have to use world space not screen space. So your vertex struct would have to be something like:

#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
struct VERTEXDATA
{
FLOAT x, y, z;
DWORD color;
};

rhw is screen coordinates. :)

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
17
5. 5

• 33
• 13
• 12
• 10
• 12
• ### Forum Statistics

• Total Topics
632575
• Total Posts
3007150

×