Jean-Christophe,
Post by Jean-ChristopheI 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.
Post by Jean-ChristopheYou 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
?
Post by Jean-ChristopheWait, 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.
Post by Jean-ChristopheBTW, 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).
Post by Jean-ChristophePost by R.WieserAnd *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.
Post by Jean-ChristopheUh ... 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.
Post by Jean-ChristopheRudy,
Post by R.Wieser(...) 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 :-)
Post by R.Wieseras 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.
Post by R.Wieseran 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 )
Post by R.WieserAnd *how* does it do that ?
With the very same code I already posted here before.
Post by R.WieserI 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