I need the way for allow users input text by writing , while users input text they see what's they input when user press enter jump for next line and when user end press on button to finish ?

Hi,

It has been long time since I used OpenGL, but I'll try to help.

First, if you know how to intilialize OpenGL properly try the following approach.. otherwise wait for someone else to help:p
Second, I didn't test the code and I'm not sure whether it works or not.

Add the following global variables (you can change the values as you like) :

int lineHight = 25; // the hight of each line
int lineMargin = 10; // the left margin for your text
int currentHight = 25; // the y position of the cursor.

Now in the main function and after OpenGL initialization enter the following lines:

glutKeyboardFunc(myKey); // register the key handler.
glRasterPos2f(lineMargin, currentHight); // set the cursor to the initial position.

And here is some definition of the key handler:

void myKey(unsigned char key, int x, int y)
{
    if (key == 13) // enter key
    {
        currentHight += lineHight; // change cursor y position
        glRasterPos2f(lineMargin, currentHight); // jumb to next line

        return;
    }

    glColor3f(0.0, 0.0, 1.0); // text color
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, key); // print the color
}

Edited 2 Years Ago by The Diamonds

Sorry buddy, you lost me here. @.@

You want to display a text and a button and yet you don't want to open a window? How is that possible?

You need at least one window to accomplish that, don't you think so?

Sorry buddy, i mean one window has a button , and has a text area for get user text input (typing text). I need user text input without opening a new window etc.

Yes, that's what I've assumed and I've wrote previous codes to use the same window not to open a new one.

Have you tried the code?

Make sure you are using a GUI auxi lib like ( GLUT ) . Do you have that ?? if so initialise every necessary stuffs and try again !!!

****HAVE PHUN C0DiNG****

This article has been dead for over six months. Start a new discussion instead.