/* w5gl.c inputting data from graphics window */ #include #include #include #include "text_in.h" /* menu item numbers */ #define NUMBER 1 #define VIEW 2 #define NAME 3 #define APPLY 4 #define QUIT 5 /* data declarations for popup window */ static char entered_text[100]; static char popup_msg[100]; static int popup_win; static int main_win; static int in_popup = 0; static int popup_created = 0; static int debug = 0; /* set to 1 for debug */ /* standard application data declarations go here */ static int winWidth, winHeight; /* function prototypes */ /* standard application */ static void display(void); static void mouseButton(int button, int state, int x, int y); static void myReshape(int w, int h); static void keyboard(unsigned char key, int x, int y); static void menu_item(int item); /* functions for popup window to get user text */ static void popup(char title[], void (*callback)(char user_text[])); static void display_popup(void); static void keyboard_popup(unsigned char key, int x, int y); static void end_popup(char user_text[]); static void (*popup_return)(char user_text[]); /* callback functions, responding to user actions */ static void DoNumber(char user_text[]); static void DoView(char user_text[]); static void DoName(char user_text[]); static void DoApply(); static void DoQuit(); static void display(void) { int len, i; char msg[] = "right click for menu"; glutSetWindow(main_win); glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* view transform */ glLoadIdentity(); /* for your application */ glPushMatrix(); glLoadIdentity(); glColor3f(1.0, 0.0, 0.0); glRasterPos2f(0.0, 0.0); len = strlen(msg); for (i = 0; i