3D using light and texture together

Post Reply
dheart88
Posts: 44
Joined: Sun Dec 13, 2009 3:00 pm

3D using light and texture together

Post by dheart88 » Fri Apr 16, 2010 6:03 am

Is it possible to use light and texture together? I can't see the differences of light implementation...

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: 3D using light and texture together

Post by elhobbs » Fri Apr 16, 2010 7:47 am

Yes it is possible. Make sure you not setting the vertex color after you send the required normal commands as this will override the color calculated by the normal command. Also, did you set the ambient, diffuse, and specular color materials?

dheart88
Posts: 44
Joined: Sun Dec 13, 2009 3:00 pm

Re: 3D using light and texture together

Post by dheart88 » Fri Apr 16, 2010 9:51 am

will it work if i use calllist? all my objects are exported from 3dsmax (3ds format into bin)

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: 3D using light and texture together

Post by elhobbs » Fri Apr 16, 2010 1:49 pm

yes, though the same issues apply.

dheart88
Posts: 44
Joined: Sun Dec 13, 2009 3:00 pm

Re: 3D using light and texture together

Post by dheart88 » Sun Apr 18, 2010 7:33 pm

can you pls give me some example? It didn't work in my place... is it because I use RGB16 instead of RGBA?

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: 3D using light and texture together

Post by elhobbs » Mon Apr 19, 2010 1:55 pm

this is the code I use:

per frame I call:

Code: Select all

        glLight(0, RGB15(31,31,31) , floattov10(r_vright[0]), floattov10(r_vright[1]), floattov10(r_vright[2])); 
per object that will use lighting I turn on the light and set the colors

Code: Select all

glPolyFmt(POLY_ALPHA(31) | POLY_CULL_FRONT | POLY_ID(6) | POLY_FORMAT_LIGHT0 | (1 << 13)); 
glColor3b(shadelight,shadelight,shadelight);
glMaterialf(GL_AMBIENT, RGB8(ambientlight,ambientlight,ambientlight)); 
glMaterialf(GL_DIFFUSE, RGB8(shadelight,shadelight,shadelight)); 
glMaterialf(GL_SPECULAR, RGB8(shadelight,shadelight,shadelight)); 
 
then for each point of each triangle I send the normal, the texcoord, and then the vertex - in that order.

dheart88
Posts: 44
Joined: Sun Dec 13, 2009 3:00 pm

Re: 3D using light and texture together

Post by dheart88 » Wed Apr 21, 2010 9:11 am

Thx for your help.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests