Advertisement

problem with regular text (not outline)

Started by August 31, 2005 06:55 AM
5 comments, last by BlackRyder 19 years, 3 months ago
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
i cant see what the problem is since the images are identical save for the jpeg compression(i checked with photoshop to be on the safe side).
Advertisement
the results i attached are screen shots ... in the second image there is no text and the frame color of each item is diffrent from the second image .
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.
it was my bad i put 2 identical images
i fixed it try it now....

sorry
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.
Advertisement
Thanks the problem was that in the textShow() at the end there is glEnable(GL_TEXTURE_2D);

This topic is closed to new replies.

Advertisement