#112329 - pettersson - Fri Dec 15, 2006 8:07 am
hi guys,
working on a small 3d test application, i've encountered a problem. all my objects do not get lit properly. all i can see is ambient color, and i just can't find the error in my code. I've broken down the code to a single lightsource and a single triangle with one normal for every vertex. Here is the triangle code
And here goes the rendering code
and all i get is just a triangle showing its ambient color. So obviously i must be doing something wrong, i just can't see what.
Maybe one of you guys can help me
thanks in advance,
pettersson
working on a small 3d test application, i've encountered a problem. all my objects do not get lit properly. all i can see is ambient color, and i just can't find the error in my code. I've broken down the code to a single lightsource and a single triangle with one normal for every vertex. Here is the triangle code
Code: |
u32 triangle[] = { 12, FIFO_COMMAND_PACK(FIFO_BEGIN, FIFO_NORMAL, FIFO_VERTEX16, FIFO_NORMAL), GL_TRIANGLE, NORMAL_PACK( 0, 0, floattov10(1.0) ), VERTEX_PACK(inttov16(-1),inttov16(-1)), VERTEX_PACK(0,0), NORMAL_PACK( 0, 0, floattov10(1.0) ), FIFO_COMMAND_PACK(FIFO_VERTEX16, FIFO_NORMAL, FIFO_VERTEX16, FIFO_END), VERTEX_PACK(inttov16(1),inttov16(-1)), VERTEX_PACK(0,0), NORMAL_PACK( 0, 0, floattov10(1.0) ), VERTEX_PACK(inttov16(0),inttov16(1)), VERTEX_PACK(0,0), }; |
And here goes the rendering code
Code: |
glReset(); gluPerspective(35, 256.0 / 192.0, 0.1, 40); glLight( 0, RGB15(31,31,31) , 0, 0, floattov10(-1.f) ); gluLookAt( 0.0, 0.0, 3.0, //camera position 0.0, 0.0, 0.0, //look at 0.0, 1.0, 0.0 ); //up glMaterialf(GL_AMBIENT, RGB15(8,8,8)); glMaterialf(GL_DIFFUSE, BIT(15)|RGB15(31,0,0) ); glMaterialf(GL_SPECULAR, BIT(15) | RGB15(31,31,31)); glMaterialf(GL_EMISSION, RGB15(0,0,0)); glMaterialShinyness(); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glPolyFmt( POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 ); glCallList( triangle ); glPopMatrix( 0 ); glFlush(); |
and all i get is just a triangle showing its ambient color. So obviously i must be doing something wrong, i just can't see what.
Maybe one of you guys can help me
thanks in advance,
pettersson