Original Post
I''ve been looking at my code for hours. And I cant figure out why it isn''t rendering.
I turn on ambient lighting, enable the z-buffer, turn off culling. but it still wont render.
I begin the scene (it works), i set the shader, set the stream source, then I draw the primitive, then I end the scene, switch to the backbuffer.
But it still doesn''t work.
u r what u bcome
D3DXMATRIX proj;
//Set up projection matrix
D3DXMatrixPerspectiveFovLH(
D3DXMatrixIdentity(&proj), //matrix
D3DX_PI/4, //fovy
float(this->m_Width) / float(this->m_Height), //aspect
0.1f, //nearZ
1000.0f); //farZ
Direct3DDevice8->SetTransform(D3DTS_PROJECTION, &proj);
//Set up view matrix
D3DXVECTOR3 eye(0.0f, 0.0f, -5.0f), where(0.0f, 0.0f, 0.0f), up(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(
D3DXMatrixIdentity(&proj), //matrix
&eye, //eye
&where, //where
&up); //up
Direct3DDevice8->SetTransform(D3DTS_VIEW, &proj);
Direct3DDevice8->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
if (SUCCEEDED(Direct3DDevice8->BeginScene()))
{
Vertex *verts = 0;
//generate new points
if (SUCCEEDED(Point->Lock(0, sizeof(Vertex) * 3, (BYTE**) &verts, 0)))
{
for (int x = 0; x < 3; x++)
{
verts[x].x = float(rand()) * OneOverRAND_MAX;
verts[x].y = float(rand()) * OneOverRAND_MAX;
verts[x].z = float(rand()) * OneOverRAND_MAX;
verts[x].diffuse = D3DCOLOR_XRGB(rand() & 255, rand() & 255, rand() & 255);
}
Point->Unlock();
} else {
OutputDebugString("Frame(): Locking of buffer failed.\n");
}
Direct3DDevice8->SetVertexShader(VertexFVF);
Direct3DDevice8->SetStreamSource(0, Point, sizeof(Vertex));
Direct3DDevice8->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 1);
Direct3DDevice8->EndScene();
Direct3DDevice8->Present(NULL, NULL, NULL, NULL);
} else {
OutputDebugString("Frame(): Begin scene failed.\n");
}
return TRUE;
oh, i forgot to mention, I set the view & projection matrixes.
IDirect3DVertexBuffer *Point
u r what u bcome