How can I have two things render independently
I am trying to render some outline font text and a rotating textured cube. However, the texture cube picks up the color of the text. I tried setting glTextEnvi to DECAL however that just makes the text a dull color though it does fix the cube. So I'm at a lost, any help would be appreciated.
stick in
glColor3f(1.0f,1.0f,1.0f);
after the call to rendering the text and before you render the cube.
glColor3f(1.0f,1.0f,1.0f);
after the call to rendering the text and before you render the cube.
heres the setup and rendering code
gobase = CreateOut("Comic Sans",12,0.5f); if(gobase==0) return false; glClearColor(0.0f,0.f,0.0f,0.0f); glClearDepth(1.0); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glGenTextures(1,&text); glBindTexture(GL_TEXTURE_2D,text); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //glTexImage2D(GL_TEXTURE_2D, 0, 3, pic->sizeX, pic->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, pic->data); gluBuild2DMipmaps(GL_TEXTURE_2D,3,pic->sizeX,pic->sizeY,GL_RGB,GL_UNSIGNED_BYTE,pic->data); glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL); if(pic) { if(pic->data) { free(pic->data); } free(pic); } return true;}void Draw(){ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(-4.5f,-0.5f,-10.0f); if(change_text) { note=rnd(6); change_text=!change_text; } if(change_color) { color=rnd(5); switch(color) { case red: r=1.0; g=0.0; b=0.0; break; case green: r=0.0; g=1.0; b=0.0; break; case blue: r=0.0; g=0.0; b=1.0; break; case purple: r=0.5; g=0.0; b=0.5; break; case white: r=1.0; g=1.0; b=1.0; break; } change_color=!change_color; } glRasterPos2f(-0.35f,0.0f); glColor3f(r,g,b); PrintBit(gbbase,amber_notes); glColor3f(1.0f,1.0f,1.0f); glTranslatef(-1.0,-3.0,-5.0); glRotatef(angle,1.0f,0.0f,0.0f); glRotatef(angle,0.0f,1.0f,0.0f); glRotatef(angle,0.0f,0.0f,1.0f); glBindTexture(GL_TEXTURE_2D,text); DrawCube(0.0f,-5.0f,-10.0f); if(angle>=360.0f) angle=0.0f; angle+=0.2f; glFlush(); SwapBuffers(ghDC);}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement