Jump to content

[OpenGL]Non multitexture faces drawn once.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
Hello,
I don't know if I'm posting in the right section but since I'm making this OpenGL program in C++, here I post :) .

So here is my problem, at the first frame, everything seems to be drawn. At the second(and third and so on...), only the faces using ARB mutlitexture are drawn...
Here is part of my code, if you need more ask for it :D :
(so the pyramid is drawn once and the cube (first function) only "keeps" the top, that uses multitex)
    glBindTexture(GL_TEXTURE_2D, textures[0]);
    glPushMatrix();
    glTranslated(2,2,0);
    //glBindTexture(GL_TEXTURE_2D, textures[0]);
    //Je feinte en dessinant la même face 4 fois avec une rotation
    for (int i = 0; i < 4; i++)
    {
        glBegin(GL_QUADS);
        glColor3ub(255,255,255);
        glTexCoord2d(0,1);
        glVertex3d(1,1,1);
        glTexCoord2d(0,0);
        glVertex3d(1,1,-1);
        glTexCoord2d(1,0);
        glVertex3d(-1,1,-1);
        glColor3ub(255,255,0);
        glTexCoord2d(1,1);
        glVertex3d(-1,1,1);
        glEnd();
        glRotated(90,0,0,1);
    }
    //puis le dessus (pas besoin du dessous grâce au sol)
    glActiveTextureARB(GL_TEXTURE0_ARB);
    glBindTexture(GL_TEXTURE_2D, textures[0]);
    glEnable(GL_TEXTURE_2D);

    glActiveTextureARB(GL_TEXTURE1_ARB);
    glBindTexture(GL_TEXTURE_2D, textures[1]);
    glEnable(GL_TEXTURE_2D);
    glBegin(GL_QUADS);
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0,0.0);
    glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0.0,0.0);
    glVertex3d(1,-1,1);
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB,1.0,0.0);
    glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1.0,0.0);
    glVertex3d(1,1,1);
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB,1.0,1.0);
    glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1.0,1.0);
    glVertex3d(-1,1,1);
    glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0,1.0);
    glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0.0,1.0);
    glVertex3d(-1,-1,1);

    glEnd();
    glPopMatrix();

}

void dessinerPyramide(GLuint* textures)
{

    glBindTexture(GL_TEXTURE_2D, textures[0]);
    glPushMatrix();
    glTranslated(-1,-1,0);
    glRotated(60,0,0,1);
    //Je feinte en dessinant la même face 4 fois avec une rotation
    for (int i = 0; i < 4; i++)
    {
        glBegin(GL_TRIANGLES);
        glTexCoord2d(0,0);
        glVertex3d(1,1,-1);
        glTexCoord2d(1,0);
        glVertex3d(-1,1,-1);
        glTexCoord2d(0.5,1);
        glVertex3d(0,0,1);
        glEnd();
        glRotated(90,0,0,1);
    }
    glPopMatrix();
}


#2
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
Thats because the previous frame wasnt cleared,
try putting this line before drawing

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

try it and tell me if it works, im not 100% sure
Posted via CodeCall Mobile

#3
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
actually it is in my mainloop, any other guesses?

#4
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
I dont see anything wrong in this code
what happens when you draw only one shape of the 2 above?

#5
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
well... after some tests, if I draw the triangle then the cube I see both then only the top of the cube, if i draw only the triangle it stays forever, if I draw only the cube it is drawn the only the top(multitextured) is...
If i draw the cube then the triangle, only the cube is drawn...

Means there is something wrong with multitexture... I guess

#6
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
ok... if before drawing everything I call glDisable(GL_TEXTURE_2D);
then the first frame has its textures disabled and all the other frames work!.....

that's strange...