Ya using glLines i can display the line…but i want cursor position for my text what i enter…Help me out, a sample codeia given below of my program of how i am using keyboard function to get input & display it…Not full program a part of code i hav put…check out & tell if i can modify anyting to get cursor position also visible
static void clear_text(char msg[])
{
msg[0]='\0';
}
static void get_text(char msg[], void (*call_with_text)())
{
getting_text = 1;
the_text = msg;
text_entered = call_with_text;
}
static void stop_text(char msg[])
{
getting_text = 0;
}
static void convert_int(char ww1[])
{
int i1;
i1 = atoi(ww1);
printf("user text converted to integer w1=%d
", i1);
}
void textbox(int x1, int y1, int x2 ,int y2,int r,int g,int b)
{
glColor3f(r,g,b);
glBegin(GL_POLYGON);
glVertex2i(x1,y1);
glVertex2i(x2,y1);
glVertex2i(x2,y2);
glVertex2i(x1,y2);
glVertex2i(x1,y1);
glEnd();
glColor3f(0,0,0);
}
void output1(int x, int y, char *string)
{
int len, i;
glRasterPos2f(x, y);
len = (int) strlen(string);
for (i = 0; i < len; i++)
{
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, string[i]);
}
}
void display(void)
{
GLfloat xsize, ysize; /* Size of image */
GLfloat xscale, yscale; /* Scaling of image */
glutSetWindow(win);
glutShowWindow();
a1=0;
no_of_pts1=0;
cheak=0;
glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
// glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
if (BitmapInfo)
{
xsize = Width;
ysize = BitmapInfo->bmiHeader.biHeight * xsize /
BitmapInfo->bmiHeader.biWidth;
if (ysize > Height)
{
ysize = Height;
xsize = BitmapInfo->bmiHeader.biWidth * ysize /
BitmapInfo->bmiHeader.biHeight;
}
xscale = xsize / BitmapInfo->bmiHeader.biWidth;
yscale = ysize / BitmapInfo->bmiHeader.biHeight;
glRasterPos2f(0,0);
glPixelZoom(xscale, yscale);
glDrawPixels(BitmapInfo->bmiHeader.biWidth, BitmapInfo->bmiHeader.biHeight,
GL_RGB, GL_UNSIGNED_BYTE, BitmapBits);
textbox(905,660,1037,740,1,1,0);//magn
output1(930,715,"Magnitude") ;
glBegin(GL_POLYGON);
glColor3f(0.8, 0.8, 0.8);
glVertex2f(915,670);
glVertex2f(915,700);
glVertex2f(965,700);
glVertex2f(965,670);
glEnd();
glColor3f(0.0, 0.0, 0.0);
output1(935,678,ww1);
glLoadIdentity();
glFinish();
}
}
void cmouse(int but,int state,int x , int y)
{
char st2[4];
int y1;
y1=875-y;
//char ww1[3], ww2[3];
if(cheak==2)
cheak=0;
if(cheak==0)
{
//y1=850-y;
if(but==GLUT_LEFT_BUTTON)
{
if(x>893 && x<[b]1049[/b] )
{
if(y>441 && y<[b]448[/b])
{
a1=0;
no_of_pts1=0;
glutSetWindow(win);
glutShowWindow();
}
else
if(y>61 && y<[b]85[/b] && x>945 && x<[b]1004[/b])
exit(0);
else
if(x>915 && x<[b]965[/b] && y>175 && y<205)
{
clear_text(ww1);
get_text(ww1,convert_int);
}
int w1;
w1 = atoi(ww1);
printf("w1=%d
",w1);
}
}
static int add_text(unsigned char key)
{
char msg[] = "x";
int len;
if(!getting_text) return 0;
if(key==8) /* backspace */
{
len = strlen(the_text);
the_text[len-1] = '\0';
}
else if(key==13 || key==9)
{
getting_text = 0;
text_entered(the_text);
}
else
{
msg[0] = key;
strcat(the_text, msg);
}
glutPostRedisplay();
return 1;
}
void keyboard(unsigned char key, int x, int y)
{
if(add_text(key)) return;
switch (key)
{
case 'a':
break;
default :
break;
}
glutPostRedisplay();
}
Help me out by modifying this functions