Sign in to follow this  

How can I have two things render independently

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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[note]);


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);
}

Share this post


Link to post
Share on other sites
That was my first thought as well but its like the call isn't even there its rather odd for OpenGL to just ignore a call I have lighting off at the moment should I turn it on? Before the cube the text was working fine without any lighting

[Edited by - clrscr on September 15, 2004 10:45:11 PM]

Share this post


Link to post
Share on other sites
So lighting is off now? (It wasn't in the code you posted). I'd leave lighting off, at least until you get the problem sorted. Another thing to check would be that PrintBit() isn't calling glColor, for example in earlier attempts to try and get the text working.

Share this post


Link to post
Share on other sites
I fixed it, apprently there was a later call to glColor that was setting it to white,it wasn't in PrintBit, but your idea made me go through and fine all the glColors and I deleted that one and it worked fine. Thank your for all your help.

Share this post


Link to post
Share on other sites

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this