Just wondering if I'm setting up my Projection matrix correctly for a 2D game.
I would like the top left of my screen to be (0, 0). Below is the code I am using.
Thinking something is off because when I draw to the screen the coordinates I need to input for my sprite seem odd.Code:D3DXMATRIX Ortho2D; D3DXMATRIX Identity; D3DXMatrixOrthoLH(&Ortho2D, 640, 480, 0.0f, 1.0f); D3DXMatrixIdentity(&Identity); g_Direct3dDevice->SetTransform(D3DTS_PROJECTION, &Ortho2D); g_Direct3dDevice->SetTransform(D3DTS_WORLD, &Identity); g_Direct3dDevice->SetTransform(D3DTS_VIEW, &Identity);
.bmp 640x480.Code:g_Background->Begin(D3DXSPRITE_OBJECTSPACE); D3DXVECTOR3 center = D3DXVECTOR3(320, 240, 0); D3DXVECTOR3 position = D3DXVECTOR3(0, 0, 0); g_Background->Draw(g_MainMenu, NULL, ¢er, &position, 0xFFFFFFFF);
g_Background is ID3DXSprite. I would think if I wanted to draw my sprite to the upper left.... the center and position vectors would both be (0, 0, 0). Maybe just the way the ID3DXSprite is drawn is confusing me.
Oh yeah my image is being drawn upside down. At first I thought it was because bitmaps store their data upside down, but I tried re-saving as .tga and still its upside down ? huh?
Code:D3DXMatrixOrthoLH(&Ortho2D, 640, 480, 0.0f, 1.0f);Change to negative and all works fine, but that doesn't seem kosher to me.. is this the proper way to do things?Code:D3DXMatrixOrthoLH(&Ortho2D, 640, -480, 0.0f, 1.0f);