All I do is switch my FVF from (D3DFVF_XYZRHW|D3DFVF_DIFFUSE) to (D3DFVF_XYZ|D3DFVF_DIFFUSE) and I dont see any vertices any more. I'm not doing any SetTransforms, because I'm assuming I dont have to if the default view is at 0,0,0 looking off as z increases with y+ going up, but maybe I need some (to be applied to the object vertices?)? When I do use camera and world transformations I notice no difference. here is the code:
for(vertex_index=0;vertex_index<4000;vertex_index++)
{
vertices[vertex_index].x=(rand()%2000-1000)/(float)100;
vertices[vertex_index].y=(rand()%2000-1000)/(float)100;
vertices[vertex_index].z=(rand()%2000-1000)/(float)100;
colors[vertex_index]=D3DCOLOR_ARGB(rand()%255,rand()%255,rand()%255,rand()%255);
}
Game->Display.LoadVertexData(vertices,colors,4000);
void DISPLAY::LoadVertexData(D3DXVECTOR3 *coordinates,D3DCOLOR *colors,int number_of_vertices)
{
VOID* pVertices;
if(FAILED(D3DVertexBuffer->Lock(0,0,(void**) &pVertices,D3DLOCK_DISCARD/*entire buffer is overwritten*/)))
{
MessageBox(window,"Failed to lock the vertex buffer!","Damn!",MB_ICONEXCLAMATION | MB_OK);
return;
}
int index=0;
while(index<number_of_vertices)//dont ask why im using a while() instead of a for() here, i dont know :|
{
screen_vertices[index].x=coordinates[index].x;
screen_vertices[index].y=coordinates[index].y;
screen_vertices[index].z=coordinates[index].z;
screen_vertices[index].color=colors[index];
index++;
}
memcpy(pVertices,screen_vertices,sizeof(screen_vertices));
if(FAILED(D3DVertexBuffer->Unlock()))
MessageBox(window,"Failed to unlock the vertex buffer!","Damn!",MB_ICONEXCLAMATION | MB_OK);
}
inline void Refresh()
{
Game->Display.BeginRendering();
int primitive_count[2];
int starts[2];
// Game->Display.SetTexture(1);
starts[0]=0;
primitive_count[0]=1000;
starts[1]=1999;
primitive_count[1]=1000;
Game->Display.RenderVertices(starts,primitive_count,2);
Game->Display.BeginSpriteRendering();
if(Game->fps_display)
{
Game->Text.D3DDrawText("FPS",D3DXVECTOR2(0,0),&D3DXVECTOR2(.5,.8));
Game->Text.D3DDrawText(1/Time.TimeMultiple,D3DXVECTOR2(40,0),NULL);
}
// Game->Display.DrawSpriteToBuffer(1,&D3DXVECTOR2(200,200),NULL,NULL,NULL,NULL);
Game->Display.EndSpriteRendering();
Game->Display.EndRendering();
}
void DISPLAY::RenderVertices(int *vertice_starts,int *number_of_primitives,int number_of_unique_primitive_sets)
{
D3DRenderDevice->SetStreamSource(0,D3DVertexBuffer,0,sizeof(CUSTOM_VERTEX));
D3DRenderDevice->SetFVF(CustomFVF);
for(int index=0;index<number_of_unique_primitive_sets;index++)
D3DRenderDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,vertice_starts[index],number_of_primitives[index]);
}
the ONLY change I made was to the FVF, everything worked when i was using pretransformed vertices. That being the case I have a feeling there is something obvious I forgot or didn't know I needed to do.
[Edited by - Unliterate on September 2, 2004 9:06:15 PM]