Sign in to follow this  

problem with regular text (not outline)

This topic is 4488 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

hey all i think it will be better to put the code and the results, just to notice i am using regular fonts and not outline font [sourc lang="c++"] float textHeight=0; //Holds the text height; float textLength=0; //Holds the text length; glPushMatrix(); glDisable(GL_TEXTURE_2D); glTranslatef(pos.getX(),pos.getY(),0.0f); if(additionalText!=string()) { textHeight = text.getTextHeightForRegularFont(additionalText); textLength = text.getTextLengthForRegularFont(additionalText); text.showText(Point2D(size/2-textLength/2+2,size),frameColor,additionalText); } glColor4f(0.1f,0.1f,0.1f,0.1f); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_BLEND); glLineWidth(2); glColor3fv(frameColor.getColor()); //displaying the frame around the box, with the image. glBegin(GL_QUADS); glVertex2f(0.0,0.0); glVertex2f(size-(textHeight/2+2),0.0); glVertex2f(size-(textHeight/2+2),size-(textHeight/2+2)); glVertex2f(0.0,size-(textHeight/2+2)); glEnd(); glDisable(GL_BLEND); //creating the texture if needed. if(textureID==INVALID_TEXTURE_ID) { if(!gameObject.getImage().hasLoaded()) { gameObject.getImage().load(); } textureID = createTexture(); } //setting the texture glEnable(GL_TEXTURE_2D); glLineWidth(1.0); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glBindTexture(GL_TEXTURE_2D,textureID); glColor3f(1.0,1.0,1.0); //displaying the game object's image size = size - frameSize; glBegin(GL_QUADS); glTexCoord2f(0.0,1.0); glVertex2f(frameSize,frameSize); glTexCoord2f(1.0,1.0); glVertex2f(size-(textHeight/2+2),frameSize); glTexCoord2f(1.0,0.0); glVertex2f(size-(textHeight/2+2),size-(textHeight/2+2)-frameSize); glTexCoord2f(0.0,0.0); glVertex2f(frameSize,size-(textHeight/2+2)-frameSize); glEnd(); if(additionalText!=string()) { } glPopMatrix(); } now a few remarks text.showText is from the tutorial about BITMAP fonts and additional text is data member. result and when i am moving the line text.showText(...) to the last if statement i get the desiered result but not text resutl 2

Share this post


Link to post
Share on other sites
if you say so, but i still can't see any diference between the images.
Either way, these types of problems are often.
1. you didn't reset the color somewhere, allways reset the color before drawing.
2. incorrect blending or that you didn't deactivate the blending after the previous round.
3. incorrect translation and reseting of the viewport.

Unfortunatly i can't pinpoint anything specific due to the small amount of code and incorrect screenshots.

Share this post


Link to post
Share on other sites
better, so here is an suggestion, but i don't know if it works though since i don't know what's inside the showText function.

glDisable(GL_TEXTURE_2D);

after text.showText(Point2D(size/2-textLength/2+2,size),frameColor,additionalText);
(or put it last in that function)

this is because if texturing isn't disabled after text.showtext then it would mean that your frame is textured with the font texture.
and since your not suplying that quad with UV coords, all vertics default to the last uv coord enterd, witch makes the whole quad point to a textel witch is entierly transparent.

Share this post


Link to post
Share on other sites

This topic is 4488 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