Scrolling bitmapped text with glTranslate

I’ve got bitmapped text displayed on a 2D page and
I’m trying to scroll it up or down. If I do:

glTranslate( 0.0, 10.0 (or -10.0), 0.0 );
glutPostRedisplay;

nothing happens immediately. But if I then do a glClear, then display another page of bitmapped text, the translation appears to have worked. What’s the glClear doing to make the translation work?

  • Still a newbie

hello,

what do you like to scroll ?
the text ?
what about the current matrix ? have you set the
proper matrix to scrol the text ?
your problem sounds like a matrix mistake…

I’ve got bitmapped text covering the entire display. It’s like somebody used printf’s but it’s done drawing bitmapped text to the window instead. I was able to do this with a simple program using Linux, but now that I’ve moved over to Windows 2K, it doesn’t work the same (it doesn’t work at all).

I’ve seen other posts on this forum that suggest setting the Matrix mode to GL_MODELVIEW or GL_PROJECTION. I’ve tried both of those with the same bad results. Do I have to Push and Pop the matrix stack too? Like:

glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glTranslate( 0.0, value, 0.0 );
glPopMatrix();

I better go read the red book.

Thanks for replying!

A quick thought: maybe it’s because it depends on the current raster position. But I don’t remeber how you translate the raster pos. I rememeber only glRasterPos* which sets it.

Hmmmmm… glRasterPos.

This leads me to believe I’m trying to do something that’s impossible. I’m trying to translate the c-u-r-r-e-n-t contents of the whole window up or down along the y axis. I’m trying to do this:

  1. draw some bitmapped text.
  2. glTranslate along the y-axis.
  3. watch it scroll up or down.

Is it possible that glTranslate affects only the NEXT things that are drawn? Maybe I’m 'spozed to do this?:

  1. draw some bitmapped text.
  2. glTranslate along the y-axis.
  3. do some more drawing.
  4. watch it scroll up or down.

You have to apply the transformations before drawing what it is that’s supposed to be translated.

like so:
glTranslatef();
draw();

that explains why you saw the translate after you cleared:
you cleared and redrew your scene with the translate in place from the previous frame. (you weren’t pushing/popping the matrix at that point).

glTranslatef() modifies the current modelview matrix which in turn affects how your vertices are transformed before they are drawn.

applying a translate after you have drawn your vertices obviously has no effect.

Ok, thanks.

So what do I do to make the current contents of the window appear to scroll? How 'bout:

  1. draw the bitmapped text.
  2. glTranslate
  3. draw something else to the window? Something I don’t really need, such as whitespace?

if you want the entire contents of the window to scroll up you need to:

  1. clear color buffer (delete previous scene)
  2. translate up (modifies the modelview for drawing)
  3. draw entire scene (now everything will be drawn translated up a bit)

Right - I was just now trying to do what you said. What’s an easy way to do that? I want to
read what’s already there, glTranslate, then draw it back again.

Can I simply:

  1. glTranslate
  2. glCopyPixels
    ?

Oops - forgot to clear the color buffer.

why are you copying pixels?
that’s an expensive operation.

if you want to move the contents of the entire window, erase the window, and draw everything in the window again with the transformation you want.
(in this case a glTranslatef(0,whatever,0)

Problem: I have to draw everything again, but I don’t know the exact sequence of commands to draw everything again.

could you elaborate a little?
how did that stuff end up in the frame buffer?
where is it being drawn from?

I’ve got a couple of functions called WriteLine() and WriteXY(). WriteLine(char* text) draws bitmapped text in a printf-style format, 1 line after another. WriteXY(char* text, int x, int y) draws bitmapped text at specific spots on the display as defined by the caller. The problem is that the caller uses these two functions to draw whatever text he/she wants, and I am not able to recreate them (? can the last display list be re-played?). That’s why I was trying to use the current contents of the framebuffer to re-draw after doing glClear, glTranslate.

Yes, you can recall the last list via glCallLists().

if you’re generating a new list each frame then you’re defeating the purpose of using display lists anyway…

so, you capture a string from the user and then render it, correct?
why not store the string? That way you know what you’re rendering at least.

if the scroll is to happen in response to a scroll bar, clear the screen and redraw the string and other content as mentioned before…

if you’re finding yourself having to use glReadPixels for reasons other than absolutely needing the contents of the frame buffer in system memory, you’re most likely doing something fishy…

EDIT: could you post some relevant code?

Right - I capture a string from the user and then render it. The scroll happens in response to thumb pressure on a button.

I’m such a novice at this, I suspect I do fishy OpenGL things every day! But it’s nice to have your guidance. If I ever become as expert as yourself, I will try to convey accurate information to newbies.

But back to my problem. Which method do you favor for redrawing after having glCleared/glTranslated?

Storing the string sounds like a great idea, one that I hadn’t considered yet.

Thanks!
-mYellow

I would post some code, but I would have to remove too much information, stuff I don’t want visible on the internet.