   2D text drawing in a 3D scene by resizing
  I read the very useful tutorials about fonts and text rendering in an OpenGL scene, however there's something very simple (I guess) that I cannot achieve:Assuming that I have an OpenGL 3D Scene, I want to display the size (for instance at the upper left corner) of the drawing area when I resize it...I took the lesson17 of the tutorials, there's a resize function, I tryed here to print any string in the scene but nothing appears...Any hint would be very appreciated.Thanx   
  well, there can be a number of things causing your problems. One issue i had was translating the text into the screen using glTranslatef(0.0f,0.0f,-1.0f); to make shure it doesn't get clipped out of the final image. You also need to clear the depth buffer bit so the text remains on the top of the screen. (with that in mind, it's also a good idea to draw the text at the end of your drawing routine so it is on the top). also check your raster positions, and you might need to call glLoadIdentity(); . Hope that helps.-Steve   ;  Does the text display before the resize event?As Hellspawn points out, the problem could be any number of places from setting up the font, properly clearing and reseting matrices, translating out slightly to see the text, setting the orthographic mode properly, capturing the window resize event, or making the proper OpenGL calls within your resize window function. You might need to post up some code so we can determine where the issue lies.F451   ;  gen a texture,load an bmp to it in which there is your words....it's a bad method,but seems easy :-)   ;  The way I read that you want to display the text only when you resize the window, and it shouldn't be displayed at any other time?If that's what you meant, is your window updating everything else as it resizes? It could be because nothing is being drawn until you've finished & let go of the window border.Or is it just that your text display routines aren't working at all? Alternatively you could update the window's title bar as a temporary solution.   ;  Thanx to all of you for your replies.Right, to have it in the drawing Scene (permanently) is not a problem indeed. I would like to have it ONLY when I resize my window, and of course the little info area should appear over the scene and not scaled! So, I assume it's more like a synchronisation problem or am I wrong(?)Now there could be a solution if I can detect while I'am redrawing the scene if I'am in a "resize" event or not, but how??As example code, you can take any sample code typically like this one:http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17And try to display the size of the drawing area only when resizing.Thanx again.;  You probably just need to define and set a counter to zero at the start of the program along with a new 9 char text field, and in the WinProc section where the resize event is captured (WM_SIZE) increment that counter, query the new window size, and generate your new text field. In your draw scene routine check to see if the counter is greater than one and if so, perform the display of the extra text and reset the counter to one. You need to detect if greater than one because there is one initial execution of the WM_SIZE routine at startup, which moves the counter from zero to one. From then on, the WM_SIZE code section (and further increments, requeries, text setup etc) will only occur if the window is resized. A little rough around the edges, but that should work.hthF451edit: quickly tested this and it works fine.[Edited by - Fahrenheit451 on December 4, 2005 9:38:16 AM];  that's it Fahrenheit451, it works, thank you! However I wonder if there is no other more elegant way to handle this kind of event out of the main drawing engine? For instance, now I would like to display the size of the drawing area only during 2 seconds when I press on Ctrl<key>, of course without disturbing the rest of my scene...Should I use the same kind of trick?;  hehe. Yes, not too elegant but in your draw routine there should only be one if statement and one print line. The work to query the window size and generate the text to display is done outside of the draw routine and occurs only if a resize event occurs, so I would think this is already quite efficient but there is likely more that can be done to enhance the esthetics.For the two second display I would imagine that you don't have to do much to achieve this. Two things are probably required; A new timer class to keep track of "time" and a few tweaks to the existing code with a small addition to the keypress detection routine.In the key detection routine (and in the WM_SIZE routine) you will probably set a flag to indicate the text should be displayed. The if statement in the draw scene would be as simply as the one there now - something like "if (flag is true)then display text". Simple. This essentially replaces the counter.A timer class is easier to work with given some of the complexity that quickly becomes involved with proper timers (FPS stats, historical stats, averaging, multiple timer support etc), but if you don't want to manage separate classes in your program or deal with the bells-and-whistles, then the core timer initialisation and update code be included in the WinMain section. If you dont have a timer class I will post up a simple one when I get home later tonight, otherwise you can search the forums for info. There are positively hundreds of discussions on this, but simply initialise your timer at the start of WinMain, and then within the main loop of the WinMain section, keep taking the difference between the last time you were in the loop and the current time. This time difference (or delta) is essentially how long it took for your draw routine to execute (in system ticks or milliseconds depending upon the timer you use. system ticks is easily converted to milliseconds and seconds). The delta is continually added to a time accumulator variable and can be used to know when your two seconds has passed. - and thus toggling the display flag off that was set in the key press routine or the WM_SIZE section.Fairly simple. Again, I will post up some code later tonight to do the timing if you want.hthF451   ;  great if you can post a sample for the timer.Thanx again.   