Sign in to follow this  

DirectX Coordinate System

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

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Jacob84
The 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 Jacob84
Also 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 this post


Link to post
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. :)

Share this post


Link to post
Share on other sites

This topic is 4864 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this