I am trying to learn direct3D and I came across a problem that has me stumped. I created a program that was supposed to display 16 cubes using prelit vertices but whenever I run the program the cubes are pitch black.
My cube class constructor is as follows:
I have tried different values for the colors but they are always black
Eventually each cube is draw with:
My cube class constructor is as follows:
Code:
cube::cube(D3DVECTOR origin,D3DVECTOR size,float R,float G,float B)
{
verts=new D3DLVERTEX[8];
D3DVECTOR extent=origin+size;
D3DCOLOR clr[8];
float luma[8]={0.7f,1.0f,0.5f,0.8f,0.15f,0.45f,0.35f,0.65f};
for(int i=0;i<8;i++)clr[i]=D3DRGB(R*luma[i],G*luma[i],B*luma[i]);
verts[0]=D3DLVERTEX(D3DVECTOR(origin.x,origin.y,origin.z),clr[0],0,0.0f,0.0f);
verts[1]=D3DLVERTEX(D3DVECTOR(origin.x,extent.y,origin.z),clr[1],0,0.0f,0.0f);
verts[2]=D3DLVERTEX(D3DVECTOR(extent.x,origin.y,origin.z),clr[2],0,0.0f,0.0f);
verts[3]=D3DLVERTEX(D3DVECTOR(extent.x,extent.y,origin.z),clr[3],0,0.0f,0.0f);
verts[4]=D3DLVERTEX(D3DVECTOR(extent.x,origin.y,extent.z),clr[4],0,0.0f,0.0f);
verts[5]=D3DLVERTEX(D3DVECTOR(extent.x,extent.y,extent.z),clr[5],0,0.0f,0.0f);
verts[6]=D3DLVERTEX(D3DVECTOR(origin.x,origin.y,extent.z),clr[6],0,0.0f,0.0f);
verts[7]=D3DLVERTEX(D3DVECTOR(origin.x,extent.y,extent.z),clr[7],0,0.0f,0.0f);
}
I have tried different values for the colors but they are always black
Eventually each cube is draw with:
Code:
void cube::draw(LPDIRECT3DDEVICE7 device)
{
device->DrawIndexedPrimitive
(D3DPT_TRIANGLELIST,D3DFVF_LVERTEX,verts,8,cube_index,36,0);
}