×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Prelit vertices wont light up

Prelit vertices wont light up

Prelit vertices wont light up

(OP)
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:
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:
void cube::draw(LPDIRECT3DDEVICE7 device)
{
    device->DrawIndexedPrimitive
        (D3DPT_TRIANGLELIST,D3DFVF_LVERTEX,verts,8,cube_index,36,0);
}


RE: Prelit vertices wont light up

(OP)
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).

RE: Prelit vertices wont light up

(OP)
Never mind, I figured it out. It turns out I had to disable lighting explicitly when initializing direct3D.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close