#158015 - AntonioND - Tue Jun 03, 2008 3:25 pm
Hello everybody!
I'm coding a 3D game, but I just can't make the lights work in real DS (in iDeaS they seem to work...). I have read all 3D examples of libnds where light is used, and changed my code a lots of times, but it's the same, I always see my 3D scene in it's normal colors...
Thanks for your help.
Note: I haven't tried no$gba because my game uses FAT, I don't know how to use fscr dldi and I don't want to learn only for this, i usually check on ds using wifiloader.
Note 2: I'm spanish, if you don't understand something, just tell me and I'll try to explain myself better.
---------------------
Here is my code:
---------------------
Before this, I init PAlib.
I use this to init 3D mode:
I call this function in the main loop once a frame:
I'm coding a 3D game, but I just can't make the lights work in real DS (in iDeaS they seem to work...). I have read all 3D examples of libnds where light is used, and changed my code a lots of times, but it's the same, I always see my 3D scene in it's normal colors...
Thanks for your help.
Note: I haven't tried no$gba because my game uses FAT, I don't know how to use fscr dldi and I don't want to learn only for this, i usually check on ds using wifiloader.
Note 2: I'm spanish, if you don't understand something, just tell me and I'll try to explain myself better.
---------------------
Here is my code:
---------------------
Before this, I init PAlib.
I use this to init 3D mode:
Code: |
int texture[128]; void My_Init_3D() { lcdMainOnTop(); videoSetMode(MODE_0_3D); vramSetBankA(VRAM_A_TEXTURE); vramSetBankB(VRAM_B_TEXTURE); glInit(); glEnable(GL_TEXTURE_2D | GL_ANTIALIAS | GL_BLEND); glClearColor(0,0,0,31); glClearPolyID(63); glClearDepth(GL_MAX_DEPTH); glViewport(0,0,255,191); glGenTextures(128, &texture[0]); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(70, 256.0 / 192.0, 0.1, 40); glMaterialf(GL_AMBIENT, RGB15(16,16,16)); glMaterialf(GL_DIFFUSE, RGB15(20,20,20)); glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8)); glMaterialf(GL_EMISSION, RGB15(5,5,5)); glMaterialShinyness(); } |
I call this function in the main loop once a frame:
Code: |
void 3D()
{ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt( -12.0, 4.0, 0.0, 8.0, 0.0, 0.0, 0.0, 1.0, 0.0); //This is only for testing... if(Pad.Held.X) glLight(0, RGB15(31, 0,0) , 0, floattov10(-1.0), 0); else glLight(0, RGB15(1, 0,0) , 0, floattov10(-1.0), 0); if(Pad.Held.B) glLight(1, RGB15(0, 31, 0) , 0, floattov10(-1.0), 0); else glLight(1, RGB15(0, 1, 0) , 0, floattov10(-1.0), 0); if(Pad.Held.Y) glLight(2, RGB15(0, 0, 31) , 0, floattov10(-1.0), 0); else glLight(2, RGB15(0, 0, 1) , 0, floattov10(-1.0), 0); glPolyFmt(POLY_ID(1) | POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0| POLY_FORMAT_LIGHT1| POLY_FORMAT_LIGHT2); Draw_Objects(); /*For example: glBegin(GL_QUADS); glNormal3f(0,1,0); glColor3f(1,0,0); glVertex3f(-8,0,-8); glColor3f(0,1,0); glVertex3f(-8,0,8); glColor3f(0,0,1); glVertex3f(8,0,8); glColor3f(1,1,0); glVertex3f(8,0,-8); glEnd(); */ glFlush(0); } |