Results 1 to 8 of 8

Thread: How to make text show up against black background.

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2009
    Location
    New Jersey, USA
    Posts
    8

    How to make text show up against black background.

    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!

    Thanks,
    Martin

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: How to make text show up against black background.

    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.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,651

    Re: How to make text show up against black background.

    Quote Originally Posted by martinb0820
    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.

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2009
    Location
    New Jersey, USA
    Posts
    8

    Re: How to make text show up against black background.

    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?

    Thanks,
    Martin

  5. #5
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: How to make text show up against black background.

    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?

  6. #6
    Junior Member Newbie
    Join Date
    Sep 2009
    Location
    New Jersey, USA
    Posts
    8

    Re: How to make text show up against black background.

    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.

  7. #7
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: How to make text show up against black background.

    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?

  8. #8
    Junior Member Newbie
    Join Date
    Sep 2009
    Location
    New Jersey, USA
    Posts
    8

    Re: How to make text show up against black background.

    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.

Similar Threads

  1. Black Background while resizing
    By Aidoru in forum OpenGL: Windows
    Replies: 0
    Last Post: 09-15-2014, 11:26 AM
  2. Textures show up black
    By AlexClarke in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-04-2013, 01:04 PM
  3. printf and show text
    By Zath in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-27-2006, 04:22 AM
  4. how to show text on screen?
    By coda in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-04-2003, 02:37 AM
  5. Replies: 2
    Last Post: 06-01-2001, 08:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean