Jump to content
  • Advertisement
Sign in to follow this  
clrscr

How can I have two things render independently

This topic is 5056 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
Advertisement
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);
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!