PDA

View Full Version : multitexturing



Mickey_dup1
03-27-2006, 03:09 PM
Hi, I have a problem with this code below: I'd like to use multitexturing and when I inserted the code to do this, my entire scene takes colors of texture (eg appear more brown) or the light seems fall down; Multitexturing seems works...but I have this change of 'color' Why this? Is my code right? Thanks


void initGL()
glGenTextures(1, &tex);
glGenTextures(1, &lastTex);
glBindTexture(GL_TEXTURE_2D, lastTex );
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, tt.width(),
tt.height(), GL_RGBA, GL_UNSIGNED_BYTE, tt.
bits() );
glBindTexture(GL_TEXTURE_2D, tex);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, tx.width(),
tx.height(), GL_RGBA, GL_UNSIGNED_BYTE, tx.
bits() );

void drawGL()
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, lastTex);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, tex);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0);
...............

ZbuffeR
03-27-2006, 03:26 PM
You mean you want to disable texture for the rest of the scene ? Or you don't have proper texcoords ?

Komat
03-27-2006, 03:31 PM
What is that code supposed to do? Can you post more code from the drawGL() function?

Mickey_dup1
03-27-2006, 06:05 PM
sorry,I'm drawing a quad; this code put texture
tex on texture lastTex; this works, but I have a change of color of all scene (eg I draw also some white lines, that they take the color of texture I loaded (eg brown);the rest of scene haven't texture; it has only white lines and a write "hello" that change color also; (before implement multit. they were white; thanks;

void drawGL()
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, lastTex);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, tex);
glBegin(GL_QUADS);
glNormal3f(0,1,1);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0);
glVertex(V[0]);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, .5, 0.0);
glVertex(V[1]);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 1.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, .5, .5);
glVertex(V[2]);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 1.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, .5);
glVertex(V[3]);
glEnd();

Tin Whisker
03-28-2006, 09:06 AM
Mickey, the code you posted isn't sufficient to produce textured results, unless of course there's a glEnable(GL_TEXTURE_?) elsewhere. Supposing that there is, be sure to disable texturing afterwards, else all geometry to follow is doomed to the same textured fate.

Mickey_dup1
03-28-2006, 09:46 AM
thanks for reply; but where I must enable and where disable exactly?

Thanks

jide
03-28-2006, 09:49 AM
Well, reading some books or documents should really help you. Enabling/disabling should be done for each texture unit.

Mickey_dup1
03-28-2006, 03:47 PM
Originally posted by jide:
Well, reading some books or documents should really help you. Enabling/disabling should be done for each texture unit. Yes, I red the problem; I have use enable/disable texuring; now the white light don't take texture color but white line became gray (seems light fall down). Any hints? Thanks

Mickey_dup1
03-29-2006, 04:51 AM
hi,
I see that if I comment this code below (from my initGL), my color of white lines don't change (and so it's OK); was it problem lights?

GLfloat light_position[] = {0.0, 0.0, 2.0, 0.0};
glLightfv(GL_LIGHT0, GL_POSITION, light_position);What isn't work? Thanks

03-29-2006, 04:55 AM
what hap if u tink you light to green?

03-29-2006, 05:01 AM
oh i hope u light did not hurt itself when it fell! :D

i'm noo too but mayb i help? :) i red redbooook and it help me much.