• GDI32 drawing over OpenGL - How to get rid of the flickering.

    From Jean-Christophe@21:1/5 to All on Sun Sep 6 14:49:35 2015
    "R.Wieser"
    In the paint event, directly after the wglSwapBuffers

    I guess that you shouldn't call any
    OpenGL functions after wglSwapBuffers.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sun Sep 6 13:37:55 2015
    Hello All,

    In the paint event, directly after the wglSwapBuffers and before the event
    ends I'm overlaying some information using DrawText, which sometimes
    flickers (showing the OpenGL drawing behind it). How can I stop that flickering ?

    I've tried a GdiFlush, but that didn't help.

    Regards,
    Rudy Wieser

    P.s.
    I know that I can also create a 2D overlay in OpenGL itself. I would still like to know how to combine OpenGL and GDI.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Christophe@21:1/5 to All on Sun Sep 6 17:50:31 2015
    "Jean-Christophe"
    I guess that you shouldn't call any
    OpenGL functions after wglSwapBuffers.

    "R.Wieser"
    Shucks. Although I hinted at it in the subjectline ...

    Sure, I read too fast - sorry about that !

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to Jean-Christophe on Sun Sep 6 17:00:10 2015
    Jean-Christophe,

    I guess that you shouldn't call any
    OpenGL functions after wglSwapBuffers.

    Shucks. Although I hinted at it in the subjectline, I forgot to
    explicitily name the DrawText function that I call after the wglSwapBuffers
    as being from GDI32. Sorry.

    Regards
    Rudy Wieser


    -- Origional message:
    Jean-Christophe <myadr@is.invalid> schreef in berichtnieuws mshcfd$2fs$1@speranza.aioe.org...
    "R.Wieser"
    In the paint event, directly after the wglSwapBuffers

    I guess that you shouldn't call any
    OpenGL functions after wglSwapBuffers.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Christophe@21:1/5 to All on Sun Sep 6 18:21:42 2015
    "R.Wieser" :
    In the paint event, directly after the wglSwapBuffers and before the event ends I'm overlaying some information using DrawText, which sometimes
    flickers (showing the OpenGL drawing behind it). How can I stop that flickering ? I've tried a GdiFlush, but that didn't help.

    Overlayed: is this text GDI-drawn inside the OpenGL viewport area itself ?


    I know that I can also create a 2D overlay in OpenGL itself.

    That's what I do to write 'flat' ( XY fixed ) text into an OpenGL view,
    when I don't want 3D translations and/or rotations to affect the text. http://www.cjoint.com/data/EIgqfmYuONh_0.jpg


    I would still like to know how to combine OpenGL and GDI.

    Is there any reason why you absolutely need to
    somehow mix GDI and OpenGL instead of just writing
    all the text at the OpenGL level before swapping buffers ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Christophe@21:1/5 to All on Sun Sep 6 18:44:24 2015
    "R.Wieser" :
    In the paint event, directly after the wglSwapBuffers and before the
    event ends I'm overlaying some information using DrawText

    MSDN excerpt (applies to 'DrawText' since it's a graphic function) says :
    " OpenGL and GDI graphics cannot be mixed in a double-buffered window. "

    Full text : https://msdn.microsoft.com/en-us/library/windows/desktop/dd374250%28v=vs.85%29.aspx

    ---





    "R.Wieser" :
    In the paint event, directly after the wglSwapBuffers and before the
    event
    ends I'm overlaying some information using DrawText, which sometimes
    flickers (showing the OpenGL drawing behind it). How can I stop that
    flickering ? I've tried a GdiFlush, but that didn't help.

    "Jean-Christophe"
    Overlayed: is this text GDI-drawn inside the OpenGL viewport area itself ?


    I know that I can also create a 2D overlay in OpenGL itself.

    That's what I do to write 'flat' ( XY fixed ) text into an OpenGL view,
    when I don't want 3D translations and/or rotations to affect the text. http://www.cjoint.com/data/EIgqfmYuONh_0.jpg


    I would still like to know how to combine OpenGL and GDI.

    Is there any reason why you absolutely need to
    somehow mix GDI and OpenGL instead of just writing
    all the text at the OpenGL level before swapping buffers ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to Jean-Christophe on Sun Sep 6 21:58:10 2015
    Jean-Christophe,

    Overlayed: is this text GDI-drawn inside the OpenGL viewport
    area itself ?

    Yes. Currently its just the camera's position and horizintal and vertical angles, but could be used for other info too.

    I know that I can also create a 2D overlay in OpenGL itself.

    That's what I do to write 'flat' ( XY fixed ) text into an OpenGL
    view, when I don't want 3D translations and/or rotations to affect
    the text.

    I wrote some test code for it, and there is quite a bit to manage. From continuously setting up and switching between 3D and 2D mode, you also need
    to take care that stuff like fog and lighting do not interfere. A GDI32
    kind of overlay is than a lot simpler.

    MSDN excerpt (applies to 'DrawText' since it's a graphic
    function) says : "OpenGL and GDI graphics cannot be mixed
    in a double-buffered window."

    Whoops ...

    Oh well. That I've got to live with OpenGLs overlay method I guess (and use the GDI32 overlay method for "debugging" purposes only).

    Is there any reason why you absolutely need to
    somehow mix GDI and OpenGL instead of just writing
    all the text at the OpenGL level before swapping buffers ?

    Nope, there is no absolute need to do it with GDI. Its just that I was
    curious if it could be done that way, as it seemed simpler to use. And,
    apart from the flickering, it definitily works. :-)

    Thanks for the help,
    Rudy Wieser.


    -- Origional message:
    Jean-Christophe <myadr@is.invalid> schreef in berichtnieuws mshot2$1gd$1@speranza.aioe.org...
    "R.Wieser" :
    In the paint event, directly after the wglSwapBuffers and before the
    event
    ends I'm overlaying some information using DrawText, which sometimes flickers (showing the OpenGL drawing behind it). How can I stop that flickering ? I've tried a GdiFlush, but that didn't help.

    Overlayed: is this text GDI-drawn inside the OpenGL viewport area itself ?


    I know that I can also create a 2D overlay in OpenGL itself.

    That's what I do to write 'flat' ( XY fixed ) text into an OpenGL view,
    when I don't want 3D translations and/or rotations to affect the text. http://www.cjoint.com/data/EIgqfmYuONh_0.jpg


    I would still like to know how to combine OpenGL and GDI.

    Is there any reason why you absolutely need to
    somehow mix GDI and OpenGL instead of just writing
    all the text at the OpenGL level before swapping buffers ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Christophe@21:1/5 to All on Sun Sep 6 23:44:13 2015
    Jean-Christophe :
    ... write 'flat' (XY fixed) text into an OpenGL view, when I don't
    want 3D translations and/or rotations to affect the text.

    "R.Wieser" :
    I wrote some test code for it, and there is quite a bit to manage.
    From continuously setting up and switching between 3D and 2D mode,
    you also need to take care that stuff like fog and lighting do not
    interfere.

    Well, you don't need to switch all those things off and on if you
    implement the 2D text display after the complete drawing of the 3D
    scene and just before swapping buffers - when you don't need any
    OpenGL calls anymore - just first disable all 'featurettes' and that's it. Plus, the text background can be transparent if you want it to. http://www.cjoint.com/data/EIgun1ZTXch_0.jpg

    The tiny drawback is that all the information you need to display
    shall be available at the time you finally call the text display function,
    you know that already since you implemented DrawText after swapping
    buffers, so you just need to "OpenGL-ise" it before swapping buffers ...


    Nope, there is no absolute need to do it with GDI. Its just that I was curious if it could be done that way, as it seemed simpler to use.

    Well, if you _really_ want it to use it that bad, then you've
    got to say good-bye to the marvels of double-buffering !


    And, apart from the flickering, it definitily works. :-)

    ... apart from the flickering :-)

    Rudy, here's an excerpt of the code I wrote for this,
    to be used after the drawing of the whole OpenGL scene
    and just before swapping thy OpenGL buffers ... HTH.


    // disable all stuff I don't need anymore (add you own)
    glDisable(GL_DEPTH_TEST);
    glShadeModel(GL_FLAT);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(winRect.left, winRect.right, winRect.bottom, winRect.top, -1, 1);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    glDisable(GL_BLEND);
    glColor3ubv( (GLbyte*)&cColor[COL_WHITE] ); // text color

    // display 2D 'flat' text
    glListBase(INDEX_LIST_TEXT); // use display lists for the glyphs
    /// insert here the display of all strings
    glRasterPos2i(x,y); // screen coordinates text location
    glCallLists( strlen(s), GL_UNSIGNED_BYTE, s ); // string 's'
    ... // display other text at other location
    /// ending of the display of all strings

    // restore (don't really need to - except for PopMatrixes)
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective( stP.fovy, stP.aspect, stP.zNear, stP.zFar );
    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_DEPTH_TEST);

    // ends

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Christophe@21:1/5 to All on Mon Sep 7 18:38:23 2015
    "Jean-Christophe"
    Plus, the text background can be transparent if you want it to.

    "R.Wieser"
    Lol. I removed my own remark in that direction from a previous
    post, as I did not want to muddy my question with it.
    Yes, thats something plain GDI (as opposed to GDI+ ) does not
    seem to be able to do (I asked in another newsgroup about it).

    I used to GDI-draw transparent background text this way :

    SetBkMode(hdc,TRANSPARENT);
    SetTextColor( hdc, value );
    DrawText( hdc, str, -1, &rect, DT_CENTER );


    I took it that when the glSwapBuffers is executed
    the backbuffer gets swapped with the front one

    That's how I understand it too : complete flush, then swapped.
    ( each time I had a funny display, it was because of a bug in my
    own code, or a misunderstanding on how to use OpenGL :-)


    (probably just copied to the DC), so where is the flickering coming from ?
    Is there some kind of delay involved causing the actual "swapping" to take place some time later ?

    Dunno, just a guess :
    I suppose that using both GDI and OpenGL on the same area rises
    some conflict (?) and not the same one wins every time, so the flickering.

    I know that, when catching WM_PAINT msg, one can't mess too much
    between BeginPaint() and EndPaint(). I tried several different approches,
    like calling the whole OpenGL scene drawing from inside a thread loop,
    or like this :

    //// main window message loop
    for( ok=1; ok; )
    { if( PeekMessage(&msg,NULL,0,0,PM_REMOVE) ) // got some
    { TranslateMessage(&msg); // process
    DispatchMessage(&msg);
    if( msg.message == WM_QUIT ) ok=0; // leave loop
    }
    else // no win msg to process
    { fDrawOpenGLscene(); // OpenGL scene
    }
    }
    // ...

    //// inside WndProc()
    case WM_PAINT:
    fDrawOpenGLscene(); // OpenGL scene
    return 0;


    And by the way, I saw the same kind of flickering when I had a control
    placed ontop of the OpenGL canvas, so its not just my GDI drawing thats bothered by it.

    What kind of "control" ?
    A windows dialog box or something ?


    A remark though: In the "restore" phase you switch to and than pop the projection matrix, only to directly overwrite it by using glPerspective.
    Does that combination do something I'm not (yet) aware of ?

    No :-)
    I don't call anymore OpenGL functions after "restore".

    This 'restore' phase is a remaining of the time when this function was
    still called from inside the middle of the drawing scene ... later I moved
    it after total scene completion, and never took time to clean-up the code !
    So don't bother too much about how bad it looks :-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to Jean-Christophe on Mon Sep 7 12:05:33 2015
    Jean-Christophe,

    Plus, the text background can be transparent if you want it to.

    Lol. I removed my own remark in that direction from a previous post, as I
    did not want to muddy my question with it.

    Yes, thats something plain GDI (as opposed to GDI+ ) does not seem to be
    able to do (I asked in another newsgroup about it).

    when you don't need any OpenGL calls anymore - just
    first disable all 'featurettes' and that's it.

    Next to setting ortho mode, yes. But there seem to be quite a few of those 'featurettes' that need to be switched on and off again. Z-Buffer,
    lighting and fog to name a few to start with.

    Well, if you _really_ want it to use it that bad, then you've
    got to say good-bye to the marvels of double-buffering !

    You know, thats something I do not quite understand. I took it that when
    the glSwapBuffers is executed the backbuffer gets swapped with the front one (probably just copied to the DC), so where is the flickering coming from ?
    Is there some kind of delay involved causing the actual "swapping" to take place some time later ?

    And by the way, I saw the same kind of flickering when I had a control
    placed ontop of the OpenGL canvas, so its not just my GDI drawing thats bothered by it.

    And, apart from the flickering, it definitily works. :-)

    ... apart from the flickering :-)

    Well, that just a minor issue, isn't it ? :-p

    Rudy, here's an excerpt of the code I wrote for this,
    to be used after the drawing of the whole OpenGL
    scene and just before swapping thy OpenGL buffers
    ... HTH.

    Thats pretty-much the same as what I have (in the test code I spoke of
    before), save for not pushing anything* and having the projection part as
    the first thing.

    ## start frame
    -- Set perspective mode
    -- Set features
    -- Set camera
    draw 3D environment
    -- Set ortho mode
    -- Reset features
    draw 2D environment
    ## end frame

    *By setting the the perspective mode as the first thing when drawing a frame there is no need to push anything. And to me thats important, as I do not
    have full control over whats done in the "draw 3D environment" and "draw 2D environment" phases.

    A remark though: In the "restore" phase you switch to and than pop the projection matrix, only to directly overwrite it by using glPerspective.
    Does that combination do something I'm not (yet) aware of ?

    Regards,
    Rudy Wieser


    -- Origional message:
    Jean-Christophe <myadr@is.invalid> schreef in berichtnieuws msibpp$gaj$1@speranza.aioe.org...
    Jean-Christophe :
    ... write 'flat' (XY fixed) text into an OpenGL view, when I don't
    want 3D translations and/or rotations to affect the text.

    "R.Wieser" :
    I wrote some test code for it, and there is quite a bit to manage.
    From continuously setting up and switching between 3D and 2D mode,
    you also need to take care that stuff like fog and lighting do not interfere.

    Well, you don't need to switch all those things off and on if you
    implement the 2D text display after the complete drawing of the 3D
    scene and just before swapping buffers - when you don't need any
    OpenGL calls anymore - just first disable all 'featurettes' and that's it. Plus, the text background can be transparent if you want it to. http://www.cjoint.com/data/EIgun1ZTXch_0.jpg

    The tiny drawback is that all the information you need to display
    shall be available at the time you finally call the text display function, you know that already since you implemented DrawText after swapping
    buffers, so you just need to "OpenGL-ise" it before swapping buffers ...


    Nope, there is no absolute need to do it with GDI. Its just that I was curious if it could be done that way, as it seemed simpler to use.

    Well, if you _really_ want it to use it that bad, then you've
    got to say good-bye to the marvels of double-buffering !


    And, apart from the flickering, it definitily works. :-)

    ... apart from the flickering :-)

    Rudy, here's an excerpt of the code I wrote for this,
    to be used after the drawing of the whole OpenGL scene
    and just before swapping thy OpenGL buffers ... HTH.


    // disable all stuff I don't need anymore (add you own)
    glDisable(GL_DEPTH_TEST);
    glShadeModel(GL_FLAT);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(winRect.left, winRect.right, winRect.bottom, winRect.top, -1,
    1);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    glDisable(GL_BLEND);
    glColor3ubv( (GLbyte*)&cColor[COL_WHITE] ); // text color

    // display 2D 'flat' text
    glListBase(INDEX_LIST_TEXT); // use display lists for the glyphs
    /// insert here the display of all strings
    glRasterPos2i(x,y); // screen coordinates text location
    glCallLists( strlen(s), GL_UNSIGNED_BYTE, s ); // string 's'
    ... // display other text at other location
    /// ending of the display of all strings

    // restore (don't really need to - except for PopMatrixes)
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective( stP.fovy, stP.aspect, stP.zNear, stP.zFar );
    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_DEPTH_TEST);

    // ends



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Christophe@21:1/5 to All on Tue Sep 8 19:56:04 2015
    Rudy,

    I used to GDI-draw transparent background text this way :
    [Snip]

    Whoops. I was referring to the transparency of the big black-ish
    box the text is drawn ontop of ( in your example image: http://www.cjoint.com/data/EIgun1ZTXch_0.jpg ).

    The bgnd looks black because there's no image under the text ... when
    there's an image under then you see it thru the text's transparent bgnd. (actually I set the bgnd _partially_ transparent to materialize the 2D box) http://www.cjoint.com/data/EIip02dxhoh_0.jpg

    Anyway it's OpenGL, not GDI, but I _used_ transparent bgnd
    GDI DrawText and it works well, like for instance the screen
    of this scope with the transparent-bgnd text (yellow, top right) http://www.cjoint.com/data/EIirk07676h_0.jpg


    I used CreateDIBSection to create a 32-bit DIB to draw on using GDI
    commands, which I than converted into a texture using glTextImage2D.
    Color me surprised when the OpenGL cube I used the texture on
    disappeared from the scene .... The cause was/is that any GDI drawing
    will zero the high byte (alpha channel) of all pixels touched by the command(s), causing full transparency. :-\

    The delicate complexity of the OpenGL machine :-8 http://www.cjoint.com/data/EIirHtyFVKh_-openglm.pdf

    Personnally I won't mix GDI & OpenGL together as it sounds
    to me like "looking for trouble" -- honestly, once one started
    to write a program already using OpenGL, who needs GDI ?
    ( except for the launch of sharp technical threads on usenet :-)


    I suppose that using both GDI and OpenGL on the same area rises
    some conflict (?) and not the same one wins every time, so the
    flickering.

    Hmmm... I assumed that after the swapping the OpenGL scene
    effectivily becomes a 2D GDI image (otherwise Windows can't
    handle it). And as the GDI command comes later in the code
    that the OpenGL swapping one it *should* be placed ontop of it.

    Yeah, but you know how it is with software programing, look at it
    the other way : a user is thinking « oh I see, it should work this way, therefore if I do *this* then it should do *that* ... » next thing you
    know, your phone is ringin' and he complains that it didn't work ;-)


    There is one thing I realized a bit later though: Its possible that the actual OpenGL "swapping" is done, unsynchronized, from within
    another thread. That might cause a race condition
    (with the curent thread) resulting in the flickering.

    I seriously doubt that Windows and OpenGL will really conflict
    ... as long as we're not messing (too much) with the rules.
    (but it's always interresting to check and try unusual things)


    ... don't bother too much about how bad it looks :-)

    It regulary happens to me that I have to rewrite a program from
    scratch again, because the current one has been "tested to death"
    (with all kinds of orphan testcode still embedded everywhere).

    Usually I use several couples of { #ifdef | #endif } with an identifier
    like 'ISDEBUG' to avoid the need to comment out the code everywhere,
    then I just comment out { #define ISDEBUG }, recompile, and that's it.
    ( unless I feel lazy, or bored, or out of time, or all of the above,
    which appends more and more frequently as I get older )


    One quick question (yeah, even I do not believe that anymore :-) ) :
    I just tried to create a textbox (alike the one in that example image
    of yours) for which I used a glSetViewport (so the text coordinates
    would be relative to the current "box", not to the 3D scene's window).
    I than did draw text into the box using wglUseFontBitmaps
    (initilisation) and glCallLists. What I did not expect is that that
    text "spilled over" the sides (top and right) of the Viewport
    (not clipped against it). Should it ?

    It think it shouldn't since you explicitely set the wiewport,
    but, as you already guessed, I'm not an OpenGL expert.
    (there ARE some experts roaming around in this newsgroup)

    However :-) my 2DFlatTextBox bypasses this problem : http://www.cjoint.com/data/EIiqQXEYaTh_0.jpg

    Best Regards.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to Jean-Christophe on Tue Sep 8 10:34:17 2015
    Jean-Christophe,

    I used to GDI-draw transparent background text this way :
    [Snip]

    Whoops. I was referring to the transparency of the big black-ish box the
    text is drawn ontop of ( in your example image: http://www.cjoint.com/data/EIgun1ZTXch_0.jpg ).

    I used CreateDIBSection to create a 32-bit DIB to draw on using GDI
    commands, which I than converted into a texture using glTextImage2D. Color
    me surprised when the OpenGL cube I used the texture on disappeared from the scene ....

    The cause was/is that any GDI drawing will zero the high byte (alpha
    channel) of all pixels touched by the command(s), causing full transparency. :-\

    Dunno, just a guess :
    I suppose that using both GDI and OpenGL on the same area rises
    some conflict (?) and not the same one wins every time, so the flickering.

    Hmmm... I assumed that after the swapping the OpenGL scene effectivily becomes a 2D GDI image (otherwise Windows can't handle it). And as the GDI command comes later in the code that the OpenGL swapping one it *should* be placed ontop of it.

    There is one thing I realized a bit later though: Its possible that the
    actual OpenGL "swapping" is done, unsynchronized, from within another
    thread. That might cause a race condition (with the curent thread)
    resulting in the flickering.

    What kind of "control" ?
    A windows dialog box or something ?

    Nope. It was/is a listbox, used as a debugging/status output window. My
    first atempt (based on a tutorial) used the whole dialog as an OpenGL
    canvas. This meant that any control placed on the dialog was always overlapping the OpenGL output.

    later I moved it after total scene completion, and never
    took time to clean-up the code !
    So don't bother too much about how bad it looks :-)

    :-) Don't worry about it, I know the problem. It regulary happens to me
    that I have to rewrite a program from scratch again, because the current one has been "tested to death" (with all kinds of orphan testcode still embedded everywhere).


    One quick question (yeah, even I do not believe that anymore :-) ) : I just tried to create a textbox (alike the one in that example image of yours) for which I used a glSetViewport (so the text coordinates would be relative to
    the current "box", not to the 3D scene's window). I than did draw text into the box using wglUseFontBitmaps (initilisation) and glCallLists. What I did not expect is that that text "spilled over" the sides (top and right) of the Viewport (not clipped against it). Should it ? A 2D quad I also did draw was, unlike the text, indeed clipped ...

    Regards,
    Rudy Wieser


    -- Origional message:
    Jean-Christophe <myadr@is.invalid> schreef in berichtnieuws mske8a$2pf$1@speranza.aioe.org...
    "Jean-Christophe"
    Plus, the text background can be transparent if you want it to.

    "R.Wieser"
    Lol. I removed my own remark in that direction from a previous
    post, as I did not want to muddy my question with it.
    Yes, thats something plain GDI (as opposed to GDI+ ) does not
    seem to be able to do (I asked in another newsgroup about it).

    I used to GDI-draw transparent background text this way :

    SetBkMode(hdc,TRANSPARENT);
    SetTextColor( hdc, value );
    DrawText( hdc, str, -1, &rect, DT_CENTER );


    I took it that when the glSwapBuffers is executed
    the backbuffer gets swapped with the front one

    That's how I understand it too : complete flush, then swapped.
    ( each time I had a funny display, it was because of a bug in my
    own code, or a misunderstanding on how to use OpenGL :-)


    (probably just copied to the DC), so where is the flickering coming from
    ?
    Is there some kind of delay involved causing the actual "swapping" to
    take
    place some time later ?

    Dunno, just a guess :
    I suppose that using both GDI and OpenGL on the same area rises
    some conflict (?) and not the same one wins every time, so the flickering.

    I know that, when catching WM_PAINT msg, one can't mess too much
    between BeginPaint() and EndPaint(). I tried several different approches, like calling the whole OpenGL scene drawing from inside a thread loop,
    or like this :

    //// main window message loop
    for( ok=1; ok; )
    { if( PeekMessage(&msg,NULL,0,0,PM_REMOVE) ) // got some
    { TranslateMessage(&msg); // process
    DispatchMessage(&msg);
    if( msg.message == WM_QUIT ) ok=0; // leave loop
    }
    else // no win msg to process
    { fDrawOpenGLscene(); // OpenGL scene
    }
    }
    // ...

    //// inside WndProc()
    case WM_PAINT:
    fDrawOpenGLscene(); // OpenGL scene
    return 0;


    And by the way, I saw the same kind of flickering when I had a control placed ontop of the OpenGL canvas, so its not just my GDI drawing thats bothered by it.

    What kind of "control" ?
    A windows dialog box or something ?


    A remark though: In the "restore" phase you switch to and than pop the projection matrix, only to directly overwrite it by using glPerspective. Does that combination do something I'm not (yet) aware of ?

    No :-)
    I don't call anymore OpenGL functions after "restore".

    This 'restore' phase is a remaining of the time when this function was
    still called from inside the middle of the drawing scene ... later I moved
    it after total scene completion, and never took time to clean-up the code
    !
    So don't bother too much about how bad it looks :-)



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Christophe@21:1/5 to All on Wed Sep 9 19:45:27 2015
    Rudy,

    (...) drawing an overlay using GDI is quite a bit simpler
    than the equivalent in OpenGL. Both in terms of lines of code,

    I don't agree ... you just need to write your own fct2DFlatText()
    To me, if 'it works' and _never_ shows any funny behavior, it's done.
    I re-used the same code on several OpenGL softs w/ just a copy/paste
    of the code, the only tuning was to sprintf the strings to display.
    ( plus ... now I know what problems I escaped by not using GDI :-)


    as well as not having to manage, in OpenGL, switching between 3D
    and 2D modes as well as enabeling and disabeling other stuff

    You won't need this heavy load anymore if you disable all 'features'
    at the very start of your fct2DFlatText() function, and call it after
    your OpenGL scene is completed and before the final buffer swap.


    an enabled depth-test caused the lower part of some drawn text
    to disappear, depending on the height my camera was on

    Wait, I never experienced that, wherever near or far the camera is.
    (no surprise, since all features have already been disabled before)

    Or, it may be because glOrtho( r.left, r.right, r.bottom, r.top, -1.0, 1.0 ) with 'r' being the whole window rectangle ...

    BTW, I used something quite close to insert 2D-flat-text into the 3D
    scene itself with the possibility to locate text in 3D(x,y,z) while always
    keep oriented straight in front of the viewer, whatever the rotations.
    ( like 'XYZ' text to identify the three axis of a 3D system coordinates )


    However :-) my 2DFlatTextBox bypasses this problem :

    And *how* does it do that ?

    With the very same code I already posted here before.


    I myself have added a clipping box to the viewport (both placed around
    the textbox), which gives an acceptable result. Still, text drawin before
    the viewport as well as with a baseline (just) below the viewport
    disappears entirely. :-\

    Uh ... never had that, but I don't clip the box at all.

    Regards

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to Jean-Christophe on Tue Sep 8 23:20:03 2015
    Jean-Christophe,

    Anyway it's OpenGL, not GDI, but I _used_ transparent
    bgnd GDI DrawText and it works well,

    Yeah, it certainly does (have used it myself, with that DrawText this thread started with).

    But I didn't mean the text itself, but the box its drawn on. When using
    OpenGL you can make the box itself transparent. Straight GDI on the other
    hand isn't able to do transparency when drawing such a rectangle.

    The delicate complexity of the OpenGL machine :-8

    It didn't have anything to do with OpenGL. I could alter the raw RGBA
    pixel data directly in memory (before converting it to an OpenGL texture),
    and get the expected results (with transparency as I set it). Its just that any GDI drawing sets the alpha of the affected pixels to Zero, making them invisible.

    Personnally I won't mix GDI & OpenGL together as it
    sounds to me like "looking for trouble" -- honestly, once
    one started to write a program already using OpenGL,
    who needs GDI ?

    I could definitily use it. Because drawing an overlay using GDI is quite a bit simpler than the equivalent in OpenGL. Both in terms of lines of code,
    as well as not having to manage, in OpenGL, switching between 3D and 2D
    modes as well as enabeling and disabeling other stuff (an enabled depth-test caused the lower part of some drawn text to disappear, depending on the
    height my camera was on).

    I seriously doubt that Windows and OpenGL will really
    conflict ...

    But it *does* "conflict". Hence the flickering.

    as long as we're not messing (too much) with the rules.

    :-) That sounds like making up "don't do that" rules as a result of "hey,
    this doesn't work" experiences. I myself are currently wondering why
    glFlush and/or glFinish (or something similar) cannot be used to wait for
    that wglSwapBuffers to complete ...

    Usually I use several couples of { #ifdef | #endif } with an
    identifier like 'ISDEBUG' to avoid the need to comment out
    the code everywhere,

    Same here. But I've just been tinkering around with some code to create a textbox much like yours, and now have multiple bits of code all doing it
    their own way. If I would continue with this program It would probably
    contain quite a few bits of orphaned code.

    It think it shouldn't since you explicitely set the wiewport,

    Thats what I thought too.

    but, as you already guessed, I'm not an OpenGL expert.

    :-) Well, it looks like you know more about it than I do, so I thought it
    smart to ask.

    However :-) my 2DFlatTextBox bypasses this problem :

    And *how* does it do that ?

    I myself have added a clipping box to the viewport (both placed around the textbox), which gives an acceptable result. Still, text drawin before the viewport as well as with a baseline (just) below the viewport disappears entirely. :-\

    Regards,
    Rudy Wieser


    -- Origional message:
    Jean-Christophe <myadr@is.invalid> schreef in berichtnieuws msn75u$a06$1@speranza.aioe.org...
    Rudy,

    I used to GDI-draw transparent background text this way :
    [Snip]

    Whoops. I was referring to the transparency of the big black-ish
    box the text is drawn ontop of ( in your example image: http://www.cjoint.com/data/EIgun1ZTXch_0.jpg ).

    The bgnd looks black because there's no image under the text ... when
    there's an image under then you see it thru the text's transparent bgnd. (actually I set the bgnd _partially_ transparent to materialize the 2D
    box)
    http://www.cjoint.com/data/EIip02dxhoh_0.jpg

    Anyway it's OpenGL, not GDI, but I _used_ transparent bgnd
    GDI DrawText and it works well, like for instance the screen
    of this scope with the transparent-bgnd text (yellow, top right) http://www.cjoint.com/data/EIirk07676h_0.jpg


    I used CreateDIBSection to create a 32-bit DIB to draw on using GDI commands, which I than converted into a texture using glTextImage2D.
    Color me surprised when the OpenGL cube I used the texture on
    disappeared from the scene .... The cause was/is that any GDI drawing
    will zero the high byte (alpha channel) of all pixels touched by the command(s), causing full transparency. :-\

    The delicate complexity of the OpenGL machine :-8 http://www.cjoint.com/data/EIirHtyFVKh_-openglm.pdf

    Personnally I won't mix GDI & OpenGL together as it sounds
    to me like "looking for trouble" -- honestly, once one started
    to write a program already using OpenGL, who needs GDI ?
    ( except for the launch of sharp technical threads on usenet :-)

    I suppose that using both GDI and OpenGL on the same area rises
    some conflict (?) and not the same one wins every time, so the
    flickering.

    Hmmm... I assumed that after the swapping the OpenGL scene
    effectivily becomes a 2D GDI image (otherwise Windows can't
    handle it). And as the GDI command comes later in the code
    that the OpenGL swapping one it *should* be placed ontop of it.

    Yeah, but you know how it is with software programing, look at it
    the other way : a user is thinking « oh I see, it should work this way, therefore if I do *this* then it should do *that* ... » next thing you
    know, your phone is ringin' and he complains that it didn't work ;-)

    There is one thing I realized a bit later though: Its possible that the actual OpenGL "swapping" is done, unsynchronized, from within
    another thread. That might cause a race condition
    (with the curent thread) resulting in the flickering.

    I seriously doubt that Windows and OpenGL will really conflict
    ... as long as we're not messing (too much) with the rules.
    (but it's always interresting to check and try unusual things)

    ... don't bother too much about how bad it looks :-)

    It regulary happens to me that I have to rewrite a program from
    scratch again, because the current one has been "tested to death"
    (with all kinds of orphan testcode still embedded everywhere).

    Usually I use several couples of { #ifdef | #endif } with an identifier
    like 'ISDEBUG' to avoid the need to comment out the code everywhere,
    then I just comment out { #define ISDEBUG }, recompile, and that's it.
    ( unless I feel lazy, or bored, or out of time, or all of the above,
    which appends more and more frequently as I get older )


    One quick question (yeah, even I do not believe that anymore :-) ) :
    I just tried to create a textbox (alike the one in that example image
    of yours) for which I used a glSetViewport (so the text coordinates
    would be relative to the current "box", not to the 3D scene's window).
    I than did draw text into the box using wglUseFontBitmaps
    (initilisation) and glCallLists. What I did not expect is that that
    text "spilled over" the sides (top and right) of the Viewport
    (not clipped against it). Should it ?

    It think it shouldn't since you explicitely set the wiewport,
    but, as you already guessed, I'm not an OpenGL expert.
    (there ARE some experts roaming around in this newsgroup)

    However :-) my 2DFlatTextBox bypasses this problem : http://www.cjoint.com/data/EIiqQXEYaTh_0.jpg

    Best Regards.



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to Jean-Christophe on Wed Sep 9 21:37:49 2015
    Jean-Christophe,

    I don't agree ... you just need to write your own fct2DFlatText()

    Lol. And how many lines would that procedure contain ?

    With GDI32 I can just use the DLL function like TextOut directly. Nothing
    to switch, nothing that needs to be set and cleared the whole time.
    Ofcourse, disabeling the texts own background does make it look a bit
    better. So, two calls all-in all.

    With OpenGL on the other hand I have had quite a few troubles. It also
    needs me to set up 3D and 2D modes in every frame, as well as switching
    quite a few things related to those off and on the whole time.

    And pardon me, but the OpenGL way isn't really what you call simple *or* too well documented. I've just posted a problem where switching to Ortho causes
    me to loose pixel row and column Zero, causing an offset. ...Which I only noticed when I tried to match-up ortho coordinates with the ones that I supplied to glScissor.

    Nope, I've now spend a few days *just* to get Ortho to work, and to keep working when I desire a bit more ffrom it than just overlay the whole canvas and draw a line or two text on it somewhere.

    You won't need this heavy load anymore if you disable all
    'features' at the very start of your fct2DFlatText() function

    Yeah, thats exactly the "switching on and off" I referred too. Because when
    I disable them at the start of some orthographic drawing I need to re-enable them again when a new frame is started and the 3D mode is initialized. Right
    ?

    Wait, I never experienced that, wherever near or far the camera is.

    Well, I think it *might* have something to do with the fact that I did not clear the z-buffer after switching to ortho mode (which you normally give
    a -1.0f to +1.0f range), and my 3D ViewNear was set to a rather high 1.0f value. After I disabled the depth-test that problem disappeared.

    BTW, I used something quite close to insert 2D-flat-text into
    the 3D scene itself with the possibility to locate text in 3D(x,y,z)
    while always keep oriented straight in front of the viewer, whatever
    the rotations.

    I will probably try to do the same/similar, as I would like to place some
    "name tags" onto certain 3D locations (like when displaying a game world).

    And *how* does it do that ?

    With the very same code I already posted here before.

    Ah. Sorry, I thought it would do a bit more than that. Your image and function name hinted at a true textbox*, something which I also aimed to
    make (already wrote it using GDI, but now needed to recreate it in OpenGL).

    *One where the textbox top-left would be the origin to the drawn text, and which would not allow any drawn text to spill outof/over the box. Possibly even including CR,LF awareness.

    Uh ... never had that, but I don't clip the box at all.

    :-) Thats what I referred to a few messages back: You know how long your
    text will be(come) at its maximum, and just draw a big enough rectangle that the text will always stay "inside" of it.

    My approach is a bit different: I have no idea how long the text might
    become, so I somehow need to clip it against the box. Hence my experiments with placing the box inside a small viewport -- and subsequently bumping
    into the problem that glDrawLists does not play nice with it (still spilling over it as well as not drawing text which does not origionate inside the viewport).

    I think I've found another way though, using glScissor (but, as already mentioned in the above, that approach came with its own problems ...).

    Thanks for the help though, I appreciate it.

    Regards,
    Rudy Wieser


    -- Origional message.
    Jean-Christophe <myadr@is.invalid> schreef in berichtnieuws mspqu0$672$1@speranza.aioe.org...
    Rudy,

    (...) drawing an overlay using GDI is quite a bit simpler
    than the equivalent in OpenGL. Both in terms of lines of code,

    I don't agree ... you just need to write your own fct2DFlatText()
    To me, if 'it works' and _never_ shows any funny behavior, it's done.
    I re-used the same code on several OpenGL softs w/ just a copy/paste
    of the code, the only tuning was to sprintf the strings to display.
    ( plus ... now I know what problems I escaped by not using GDI :-)

    as well as not having to manage, in OpenGL, switching between 3D
    and 2D modes as well as enabeling and disabeling other stuff

    You won't need this heavy load anymore if you disable all 'features'
    at the very start of your fct2DFlatText() function, and call it after
    your OpenGL scene is completed and before the final buffer swap.

    an enabled depth-test caused the lower part of some drawn text
    to disappear, depending on the height my camera was on

    Wait, I never experienced that, wherever near or far the camera is.
    (no surprise, since all features have already been disabled before)

    Or, it may be because glOrtho( r.left, r.right, r.bottom, r.top, -1.0,
    1.0 )
    with 'r' being the whole window rectangle ...

    BTW, I used something quite close to insert 2D-flat-text into the 3D
    scene itself with the possibility to locate text in 3D(x,y,z) while always keep oriented straight in front of the viewer, whatever the rotations.
    ( like 'XYZ' text to identify the three axis of a 3D system coordinates )

    However :-) my 2DFlatTextBox bypasses this problem :

    And *how* does it do that ?

    With the very same code I already posted here before.

    I myself have added a clipping box to the viewport (both placed around
    the textbox), which gives an acceptable result. Still, text drawin
    before
    the viewport as well as with a baseline (just) below the viewport disappears entirely. :-\

    Uh ... never had that, but I don't clip the box at all.

    Regards

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Christophe@21:1/5 to All on Thu Sep 10 20:20:26 2015
    Rudy,

    Jean-Christophe,
    I don't agree ... you just need to write your own fct2DFlatText()

    Lol. And how many lines would that procedure contain ?

    And how many lines will this thread contain ?

    Sorry, I can't see where the fun is ... maybe because the
    number of lines isn't exactly my metric for code quality,
    mine is : 'it does exactly what I want' ... I'm a simple man !


    With GDI32 I can just use the DLL function like TextOut directly.
    Nothing to switch, nothing that needs to be set and cleared the whole
    time.
    Ofcourse, disabeling the texts own background does make it look a bit
    better. So, two calls all-in all.

    Fine - except it doesn't work like you wanted it - hence this thread,
    and me trying to help while getting back unexpected comments :-|


    With OpenGL on the other hand I have had quite a few troubles. It also
    needs me to set up 3D and 2D modes in every frame, as well as switching
    quite a few things related to those off and on the whole time.
    And pardon me, but the OpenGL way isn't really what you call simple *or*
    too
    well documented. I've just posted a problem where switching to Ortho
    causes
    me to loose pixel row and column Zero, causing an offset. ...Which I only noticed when I tried to match-up ortho coordinates with the ones that I supplied to glScissor.
    Nope, I've now spend a few days *just* to get Ortho to work

    Well, I guess that, all in all, total you wrote more lines than I did,
    with the result that yours gives you trouble while mine works.
    ( now I start to see where the fun is ... no seriously, come on :-)


    You won't need this heavy load anymore if you disable all
    'features' at the very start of your fct2DFlatText() function

    Yeah, thats exactly the "switching on and off" I referred too. Because
    when
    I disable them at the start of some orthographic drawing I need to
    re-enable
    them again when a new frame is started and the 3D mode is initialized.
    Right ?

    Sure, being the programmer, you're the master,
    you can't expect OpenGL to guess and do it four you.

    You want flat 2D text, fine; then after your 3D scene is done you disable
    3D 'features' and enable 2D text drawing, draw text, then swap buffers,
    and that's it; next frame will process your already written 3D scene.
    Sounds quite logical to me and I still can't see where the problem is.
    Mix GDI rised problems leading to complain about OpenGL ?


    BTW, I used something quite close to insert 2D-flat-text into
    the 3D scene itself with the possibility to locate text in 3D(x,y,z)
    while always keep oriented straight in front of the viewer, whatever
    the rotations.

    I will probably try to do the same/similar, as I would like to place some "name tags" onto certain 3D locations (like when displaying a game world).

    Yes, that's it exactly.

    Works fine unless you want better-looking, 'sexy', 3D fonts.
    I used to use a BMP with nice alphabet and numbers and map
    string characters into it to display textured 3D floating messages.
    Looks better ... unless you demand to count number of code lines :op


    And *how* does it do that ?

    With the very same code I already posted here before.

    Ah. Sorry, I thought it would do a bit more than that.

    Sorry I didn't post what you expected.


    Your image and function name hinted at a true textbox*, something
    which I also aimed to make (already wrote it using GDI, but now
    needed to recreate it in OpenGL).
    *One where the textbox top-left would be the origin to the drawn text, and which would not allow any drawn text to spill outof/over the box.
    Possibly
    even including CR,LF awareness.

    I did this in the past, by parsing the string to detect CRLFs,
    split the string, skip one character_height down (+Y)
    and restart at the left of the box (X)
    I don't use it anymore since I just display numeric values,
    where strings are sprintf'ed at the time the box is drawn.


    Uh ... never had that, but I don't clip the box at all.

    :-) Thats what I referred to a few messages back: You know how long your text will be(come) at its maximum, and just draw a big enough rectangle
    that
    the text will always stay "inside" of it.

    Yes, that is true.

    Another way is to dynamically resize the rectangle of the box
    to make it fit by itself to the longest string ( strlen * charwidth )
    Implied : use of non-proportional font like ANSI 'Courier' or else.
    Works fine too.
    I don't use it there since I fixed the longest string length.


    Thanks for the help though, I appreciate it.

    You're welcome, Rudy.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to Jean-Christophe on Thu Sep 10 23:31:54 2015
    Jean-Christophe,

    And how many lines will this thread contain ?

    Sorry, I can't see where the fun is ...

    My apologies. At the moment I wrote that you where referring to a function I knew nothing about. It could have possibly held several thousands of lines. Which you did, quite offhandidly, offer it as a/the solution to me. That combination was funny to me.

    Fine - except it doesn't work like you wanted it - hence this thread,

    True.

    But please do not tell me that the OpenGL method is easy. Which is all I tried to say there.

    Well, I guess that, all in all, total you wrote more lines than
    I did,

    You can say that again. If only to try to get different approaches to work.

    with the result that yours gives you trouble while mine works.

    :-) If all I wanted to make would have been a copy of what you've got I
    would probably have had it in less than an hour after it became clear that
    GDI wouldn't do. No, as I've been mentioning thruout our conversation, my textbox was intended to do a bit more than yours.

    Next to that, your approach to it is quite different than mine. Where you
    are content with having it "look good" I have the deep-rooted urge to figure out the reason why some things do not want to work as expected -- like that rectangle and its border coordinates mismatch -- and often learn a thing or
    two in the process (just as I did here).

    ( now I start to see where the fun is ... no seriously, come on :-)

    :-) I think I see what you think is funny.

    you can't expect OpenGL to guess and do it four you.

    No. But I did try a fully different approach which would not have needed
    all of that, and thus would make overlaying text quite a bit easier (and
    also most likely speed the whole thing up a bit).

    Sorry I didn't post what you expected.

    Nothing to be sorry about. You posted code you thought would be helpfull
    (and it was), it was just me thinking it was in reference to what I had
    been talking about at that moment (viewports, text-on-textbox, clipping).

    I don't use it anymore since I just display numeric values,
    where strings are sprintf'ed at the time the box is drawn.

    Other than you, my textbox isn't geared to a specific goal. I think that
    being able to display a multi-line string on its own (much like GDI's ExtTextOut does) could come in handy.

    Another way is to dynamically resize the rectangle of the box
    to make it fit by itself to the longest string ( strlen * charwidth )

    A kind of "messagebox" approach. Yep, that would be another solution.

    Regards,
    Rudy Wieser


    -- Origional message:
    Jean-Christophe <myadr@is.invalid> schreef in berichtnieuws msshbh$4qd$1@speranza.aioe.org...
    Rudy,

    Jean-Christophe,
    I don't agree ... you just need to write your own fct2DFlatText()

    Lol. And how many lines would that procedure contain ?

    And how many lines will this thread contain ?

    Sorry, I can't see where the fun is ... maybe because the
    number of lines isn't exactly my metric for code quality,
    mine is : 'it does exactly what I want' ... I'm a simple man !

    With GDI32 I can just use the DLL function like TextOut directly.
    Nothing to switch, nothing that needs to be set and cleared the whole
    time.
    Ofcourse, disabeling the texts own background does make it look a bit better. So, two calls all-in all.

    Fine - except it doesn't work like you wanted it - hence this thread,
    and me trying to help while getting back unexpected comments :-|

    With OpenGL on the other hand I have had quite a few troubles. It also needs me to set up 3D and 2D modes in every frame, as well as switching quite a few things related to those off and on the whole time.
    And pardon me, but the OpenGL way isn't really what you call simple *or* too
    well documented. I've just posted a problem where switching to Ortho
    causes
    me to loose pixel row and column Zero, causing an offset. ...Which I
    only
    noticed when I tried to match-up ortho coordinates with the ones that I supplied to glScissor.
    Nope, I've now spend a few days *just* to get Ortho to work

    Well, I guess that, all in all, total you wrote more lines than I did,
    with the result that yours gives you trouble while mine works.
    ( now I start to see where the fun is ... no seriously, come on :-)


    You won't need this heavy load anymore if you disable all
    'features' at the very start of your fct2DFlatText() function

    Yeah, thats exactly the "switching on and off" I referred too. Because
    when
    I disable them at the start of some orthographic drawing I need to re-enable
    them again when a new frame is started and the 3D mode is initialized. Right ?

    Sure, being the programmer, you're the master,
    you can't expect OpenGL to guess and do it four you.

    You want flat 2D text, fine; then after your 3D scene is done you disable
    3D 'features' and enable 2D text drawing, draw text, then swap buffers,
    and that's it; next frame will process your already written 3D scene.
    Sounds quite logical to me and I still can't see where the problem is.
    Mix GDI rised problems leading to complain about OpenGL ?

    BTW, I used something quite close to insert 2D-flat-text into
    the 3D scene itself with the possibility to locate text in 3D(x,y,z)
    while always keep oriented straight in front of the viewer, whatever
    the rotations.

    I will probably try to do the same/similar, as I would like to place
    some
    "name tags" onto certain 3D locations (like when displaying a game
    world).

    Yes, that's it exactly.

    Works fine unless you want better-looking, 'sexy', 3D fonts.
    I used to use a BMP with nice alphabet and numbers and map
    string characters into it to display textured 3D floating messages.
    Looks better ... unless you demand to count number of code lines :op

    And *how* does it do that ?

    With the very same code I already posted here before.

    Ah. Sorry, I thought it would do a bit more than that.

    Sorry I didn't post what you expected.

    Your image and function name hinted at a true textbox*, something
    which I also aimed to make (already wrote it using GDI, but now
    needed to recreate it in OpenGL).
    *One where the textbox top-left would be the origin to the drawn text,
    and
    which would not allow any drawn text to spill outof/over the box.
    Possibly
    even including CR,LF awareness.

    I did this in the past, by parsing the string to detect CRLFs,
    split the string, skip one character_height down (+Y)
    and restart at the left of the box (X)
    I don't use it anymore since I just display numeric values,
    where strings are sprintf'ed at the time the box is drawn.

    Uh ... never had that, but I don't clip the box at all.

    :-) Thats what I referred to a few messages back: You know how long
    your
    text will be(come) at its maximum, and just draw a big enough rectangle that
    the text will always stay "inside" of it.

    Yes, that is true.

    Another way is to dynamically resize the rectangle of the box
    to make it fit by itself to the longest string ( strlen * charwidth )
    Implied : use of non-proportional font like ANSI 'Courier' or else.
    Works fine too.
    I don't use it there since I fixed the longest string length.

    Thanks for the help though, I appreciate it.

    You're welcome, Rudy.
    \

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)