Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prelit vertices wont light up

Status
Not open for further replies.

Rouslan

Technical User
Sep 7, 2002
27
CA
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:
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);
}

 
One thing I forgot to mention is I am using DirectX 7 and C++.NET (although I suppose you can guess the directX 7 part because of the LPDIRECT3DDEVICE7).
 
Never mind, I figured it out. It turns out I had to disable lighting explicitly when initializing direct3D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top