View Full Version : How to make text show up against black background.
12-23-2010, 10:17 AM
I'm developing a 2D real-time display of radar imagery that includes the display of time, location, etc. at the corners of the image.
What I'm doing is very straightforward: set the GL_PROJECTION matrix, create a gluOrtho2D(), set GL_MODELVIEW, etc. and then map a texture containing the image to a quad. After that, I use glutBitmapCharacter() to display the text.
This all works great as long as the bitmap isn't too dark. If the bitmap is very dark, or black, the text can't be seen. (This doesn't depend much on the color of the text.) I've experimented with every glBlenFunc() combination I can find...
How can I make the text always show up? Any suggestions would be appreciated!
12-23-2010, 11:35 AM
I'm not completely sure I understand the question, especially this:
(This doesn't depend much on the color of the text.)
Surely the color of the text makes a major difference whether it has good contrast with the background it is drawn on?
Anyway, I think you may want to take a look at glLogicOp (http://www.opengl.org/sdk/docs/man/xhtml/glLogicOp.xml).
12-23-2010, 11:52 AM
How can I make the text always show up?
Consider a drop shadow. When drawing on a light background, draw text in black, then draw text using desired colors one pixel up and one pixel left. When drawing on a dark background, draw text in white, then draw text using desired colors one pixel up and one pixel left.
01-03-2011, 02:49 PM
Thanks! glLogicOp(GL_SET) is certainly a big improvement. One remaining item is that the text should be green, but when using glLogicOp(), the text is white. Is there something else I need to do?
01-04-2011, 07:52 AM
Thanks! glLogicOp(GL_SET) is certainly a big improvement.
Huh? That just draws the text in white (as you've noticed), so why not draw the text in white in the first place - or green for that matter?
01-04-2011, 11:32 AM
Whatever color I tried, white, green or anything else, if glLogicOp() isn't called, the text "flickers" and disappears/reappears as the texture, a constantly changing radar image updated in real-time, under the text changes.
As I originally noted, I couldn't find a combination of glBlenFunc() parameters that would make the text remain visible.
Again, thanks for the suggestion to use glLogicOp(). Without that, the text display was unreadable much of the time.
01-04-2011, 12:03 PM
if glLogicOp() isn't called, the text "flickers" and disappears/reappears as the texture, a constantly changing radar image updated in real-time, under the text changes.
Hmm, that sounds a bit as if you are not drawing the text consistently after the radar image (but perhaps only if the text changes?). I don't see why glLogicOp would make a difference though. Do you disable depth testing when rendering the text?
01-05-2011, 10:58 AM
The image is updated on a timer, and each time through the routine the text is updated after the texture. I definitely disable depth testing.
Maybe this is related to some interaction between the tools I'm using, Envitia MapLink and a Qt QGLWidget.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.