Jump to content
  • Advertisement
Sign in to follow this  
slippers2k

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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).

Thanks for your time.
-slippers2k

Share this post


Link to post
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.

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


//Every frame
RenderObjects();
If(menu.state)
{
SwitchToOrtho();
drawText(dialog);
}

//Input
//Toggles menu after user has pressed a button
if(menu.state)
{
menu.state = false;
}

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!