OpenGL setting up a dialog box (or, did you play an RPG and...)

This topic is 5106 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Ever play an rpg like Dragon Warrior or Final Fantasy? When the characters talk, they have dialog boxes above them with the text appearing so you can see it. Well, I know how to create the boxes where the text will be displayed, but I don't know how to render the text onscreen. I know this much: 1. I create the dialog box first with GL_QUAD (or GL_LINES, etc.) 2. I pick a point on the screen where I want to start passing the text 3. I insert my own code for handling things like text wrapping (so the text doesn't go outside the box) 4. Once the text is displayed on the screen, I wait for the user to press a key to keep displaying more text. Once the user presses the key, how do I clear the text box? Is it just automatically done (like Glflush clearing the entire screen, and new text can just be put in the box because the old text is erased)? Or do you have to "clear it yourself"? I apologize for the lack of more detail in the explanation. Put it to you this way: my dilemma is like writing on a blackboard. In terms of Opengl, does the blackboard clear itself everytime it gets flushed or Glclear'ed, or do you have to pick up the eraser and clear the text from the blackboard yourself? Thanks for any assistance. -slippers2k

Share on other sites
You need to clear the buffer at the begining of each render.

To clear the entire scren, use:
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

If not, you'd continue to render ontop of whatever's there.

You can use glScissor() to limit clearing of the screen to your own dialog box, which might be faster than trying to render the entire scene over again.

Share on other sites
Okay... so I'm displaying text onscreen like I wanted to.

I know how to load text into a string array from a text file. Has anyone actually ever printed an array of text onscreen in OpenGL?

I'm using NeHe's bitmap text output tutorial as a base for my code (yes, bitmap, ugh, but I'm learning right now, and I can switch over to outline fonts later).

-slippers2k

Share on other sites
I did my FYP(RPG) in OpenGL last year(link below), basically this is how i do it.
I have a Menu system, it is either toggled on/off.

{
//On/Off
bool state;
//Text to be printed
string dialog;
}

//Every frame
RenderObjects();
{
SwitchToOrtho();
drawText(dialog);
}

//Input
//Toggles menu after user has pressed a button
{
}

Obviously this is a very rough example, it's been a year since i looked at the code. There are many other things like wordWrap, when and how to activate the dialogue, action to take after user has read dialogue. It takes quite a bit of planning and patience to make everything work seamlessly. Making a RPG is tedious but fun when you do it right.

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
18
5. 5

• 9
• 12
• 9
• 33
• 13
• Forum Statistics

• Total Topics
632588
• Total Posts
3007240

×