Lighting and Multitexturing problem

Scribendi
Unregistered
 
Post: #1
Hi , I've been trying to implement this in C++:

http://www.delphi3d.net/articles/viewart...aintex.htm

However I'm trying to get lighting to work and just don't seem to be able to , I just seem to get T2 (see code below) Can some one give me some advice. Kind Regards

Code:



glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_FLOAT, 0,Colours);

glClientActiveTextureARB(GL_TEXTURE3_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, TexCoords2);

glClientActiveTextureARB(GL_TEXTURE2_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, TexCoords);

glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, TexCoords);

glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, TexCoords);

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, Vertices);

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, Vertices);


//Normals
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT,0, Normals);

// Texture 3: previous * L lightmap
glActiveTextureARB(GL_TEXTURE3_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Lightmap);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);



// Texture 2: lerp(C0.alpha, previous, T3)
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, T3);

glMatrixMode(GL_TEXTURE);
glScalef(0.2, 0.2, 0);
glMatrixMode(GL_MODELVIEW);

//glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA);

// Texture 1: lerp(C0.rgb, T1, T2)
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, T1);

glMatrixMode(GL_TEXTURE);
glScalef(0.2, 0.2, 0);
glMatrixMode(GL_MODELVIEW);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR);

// Texture 0: T1
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, T2);

glMatrixMode(GL_TEXTURE);
glScalef(0.2, 0.2, 0);
glMatrixMode(GL_MODELVIEW);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Can't get multitexturing to work Coyote 4 3,875 Nov 16, 2009 11:48 PM
Last Post: arekkusu
  Using glTexCoordPointer with multitexturing TomorrowPlusX 6 13,532 Dec 5, 2006 09:42 AM
Last Post: NYGhost
  Lighting Problem, need help nahid 10 4,005 Apr 13, 2005 10:16 PM
Last Post: nahid
  Strange lighting problem Duncanla 14 5,822 Mar 1, 2005 02:43 PM
Last Post: Duncanla
  OpenGL Multitexturing Details w/Alpha WakingJohn 22 10,664 Dec 4, 2004 10:52 AM
Last Post: WakingJohn