hi, its me again
i used glOrtho for billboarding but my text isn't billboarded when i move in 2D directions (up,down,west,east).
it is billboarded only when i rotate the camera or move foreward/backward.
this is my billboard function:
/* math.h */
#define BILLBOARD_BEGIN 0
#define BILLBOARD_MASK 1
#define BILLBOARD_IMAGE 2
#define BILLBOARD_END 3
void billboard(int level=-1);
static int bblevel;
/* math.cpp */
void billboard(int level)
{
if (level!=-1)
bblevel=level;
if (bblevel==1)
goto BBMASK;
else if (bblevel==2)
goto BBIMAGE;
else if (bblevel==3)
goto BBPERSPECTIVE;
else
bblevel=0;
// Set ortho mode
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,0,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT),0,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
goto BBEND;
BBMASK:
// Draw mask
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glEnable(GL_BLEND);
goto BBEND;
BBIMAGE:
// Draw image
glBlendFunc(GL_ONE,GL_ONE);
goto BBEND;
BBPERSPECTIVE:
// Set perspective mode
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
BBEND:
bblevel++;
}
and in main():
billboard(BILLBOARD_BEGIN);
billboard(BILLBOARD_MASK);
text.color(1.0,0.0,0.0);
text.pos(cam.getPosition().x,cam.getPosition().y);
text.print("pex");
billboard(BILLBOARD_IMAGE);
text.color(1.0,0.0,0.0);
text.pos(cam.getPosition().x,cam.getPosition().y);
text.print("pex");
billboard(BILLBOARD_END);
the text class uses bitmap fonts (glutBitmapCharacter)
well, maybe billboard() doesn't need to be in math.h/cpp, but i dont know where to put it.
anyway, thats not matter.
what is the solution to my problem?
thnx,
pex.
[Edited by - pex22 on October 21, 2004 1:58:08 PM]