I know this is a cross post but it's just not getting anywhere on the beginers forum and I guess its more suited for here anyway.
Well I can get pretransformed vertices on the screen just fine but its the non-pretransformed ones that I can't get to show up, Nothing is failing, and all values seem to be what they should, and sprites render fine. This is very frusterating, and again everything works perfectly when im using pretransformed vertices.
vertices:
D3DXVECTOR3 vertices[4000];
D3DXVECTOR2 texture_coords[4000];
D3DCOLOR colors[4000];
vertices[0].x=-10;
vertices[0].y=10;
vertices[0].z=2;
colors[0]=D3DCOLOR_ARGB(122,0,255,0);
texture_coords[0].x=0;
texture_coords[0].y=0;
vertices[1].x=10;
vertices[1].y=10;
vertices[1].z=2;
colors[1]=D3DCOLOR_ARGB(122,0,255,0);
texture_coords[1].x=1;
texture_coords[1].y=0;
vertices[2].x=-10;
vertices[2].y=-10;
vertices[2].z=2;
colors[2]=D3DCOLOR_ARGB(122,0,255,0);
texture_coords[2].x=0;
texture_coords[2].y=1;
vertices[3].x=10;
vertices[3].y=-10;
vertices[3].z=2;
colors[3]=D3DCOLOR_ARGB(122,0,255,0);
texture_coords[3].x=1;
texture_coords[3].y=1;
//(im not using textures so that can be ignored)
Game->Display.LoadVertexData(vertices,texture_coords,colors,4);
in the header:
struct CUSTOM_VERTEX{
float x,y,z/*,rhw*//*,tu,tv*/;
DWORD color;
};
#define CustomFVF (D3DFVF_XYZ|D3DFVF_DIFFUSE)
fill vertex buffer:
void DISPLAY::LoadVertexData(D3DXVECTOR3 *coordinates,D3DXVECTOR2 *texture_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;
}
for(int index=0;index<number_of_vertices;index++)
{
screen_vertices[index].x=coordinates[index].x;
screen_vertices[index].y=coordinates[index].y;
screen_vertices[index].z=coordinates[index].z;
// screen_vertices[index].tu=texture_coordinates[index].x;
// screen_vertices[index].tv=texture_coordinates[index].y;
screen_vertices[index].color=colors[index];
// screen_vertices[index].rhw=0.5f;
}
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]=2;
starts[1]=1999;
primitive_count[1]=30;
Game->Display.RenderVertices(starts,primitive_count,1);
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(300,300),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);
D3DXMATRIX World,View,Perspective;
D3DXMatrixIdentity(&World);
D3DRenderDevice->SetTransform(D3DTS_WORLD,&World);
D3DXMatrixPerspectiveFovLH(&Perspective,
D3DX_PI/4,//verticle FOV, (90º)
1024/768,//viewing aspect ratio
1,//minimum distance clip
100//maximum distance clip
);
D3DRenderDevice->SetTransform(D3DTS_PROJECTION,&Perspective);
D3DXMatrixLookAtLH(&View,
&D3DXVECTOR3(0,0,-1),//camera vector
&D3DXVECTOR3(0,0,0), //camera target
&D3DXVECTOR3(0,1,0));//up
D3DRenderDevice->SetTransform(D3DTS_VIEW,&View);
for(int index=0;index<number_of_unique_primitive_sets;index++)
tester=D3DRenderDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,vertice_starts[index],number_of_primitives[index]);
}
any help or ideas are appreciated.