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
}

I need user text input without opening a window etc.

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?

I tried the code but it isn't work .

Yes , i tried the code but isn't work

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****

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.