I'm absolutely new to DirectX and I'd like to draw some untransformed primitives with the most basic Direct3D configuration (for learning purposes). I already drew some primitives with transformed vertices, that is vertices with the D3DFVF_XYZRHW flag set.
Now I'm trying to get the same output with untransformed vertices, but I don't get any visuals on the screen. I changed my FVF and adjusted the vertices but didn't set any transformation matrix (world, view, projection) yet. Is it necessary to set any of those matrices? I'd assume that everything would work just like with transformed vertices when no matrices are set, but obviously that's not the case.
What area (in world-coordinates) is visible by default? What do I have to do in order to make it work?
This is basically what I do:
struct Vertex
{
float x, y, z;
D3DCOLOR color;
static const DWORD format = D3DFVF_XYZ | D3DFVF_DIFFUSE;
};
const Vertex vertices[] = {
{0.0f, 0.8f, 0.5f, D3DCOLOR_XRGB(255, 255, 255)},
{0.8f, -0.8f, 0.5f, D3DCOLOR_XRGB(255, 255, 255)},
{-0.8f, -0.8f, 0.5f, D3DCOLOR_XRGB(255, 255, 255)}
};
pd3dDevice->CreateVertexBuffer(sizeof(vertices), 0, Vertex::format, D3DPOOL_DEFAULT, &pVB, NULL);
VOID* vertexData = 0;
pVB->Lock(0, sizeof(vertices), &vertexData, 0);
memcpy(vertexData, vertices, sizeof(vertices));
pVB->Unlock();
D3DMATRIX matrixIdentitiy;
ZeroMemory(&matrixIdentitiy, sizeof(matrixIdentitiy));
matrixIdentitiy._11 = 1.0f;
matrixIdentitiy._22 = 1.0f;
matrixIdentitiy._33 = 1.0f;
matrixIdentitiy._44 = 1.0f;
pd3dDevice->SetTransform(D3DTS_WORLD, &matrixIdentitiy);
pd3dDevice->SetTransform(D3DTS_VIEW, &matrixIdentitiy);
pd3dDevice->SetTransform(D3DTS_PROJECTION, &matrixIdentitiy);
pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 0.0f, 0);
pd3dDevice->BeginScene();
pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
pd3dDevice->SetRenderState(D3DRS_CLIPPING, FALSE);
pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );
pd3dDevice->SetStreamSource(0, pVB, 0, sizeof(Vertex));
pd3dDevice->SetFVF(Vertex::format);
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
pd3dDevice->EndScene();
pd3dDevice->Present(NULL, NULL, NULL, NULL);
Thanks in advance!
EDIT: Now i got it, lighting was enabled, stupid beginner's mistake. Thanks for your help anyway!