Search code examples
c++directxdirect3drenderer

DirectX primitive rendering at the wrong position


So I'm recoding my rendering engine, starting with the basics. I'm running is to a very weird issue. I'm simply rendering a triangle, but the position is all wrong.

Here's what I'm getting (can't post image cause I don't have enough rep yet): Incorrect Result

That's obviously not what I'm trying to do.

Here's are my vertices I'm defining, what my vertex structure looks like, and what my FVF looks like:

CDirect3DHelper::VERTEX vertices[] =
{
    { 300, -300, 0, 1, D3DCOLOR_XRGB(0, 0, 255) },
    { 0, 300, 0, 1, D3DCOLOR_XRGB(0, 255, 0) },
    { -300, -300, 0, 1, D3DCOLOR_XRGB(255, 0, 0) }
}

struct VERTEX
{
    float x, y, z, rhw;
    DWORD color;
};

static const DWORD FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE;

Anyone have any idea what's wrong? I feel like I'm missing something really stupid.

Thanks!


Solution

  • The coordinates are outside your screen. The X and Y value of the vertex are in screen space where top left is 0,0 and right bottom is width,height