yeah sure
//width =500, height =500
void initScene()
{
///All initialization stuff goes here
glClearColor(1.0, 1.0, 1.0,1.0); //white background
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,WIN_WIDTH,0,WIN_HEIGHT,-1,1);
glMatrixMode(GL_MODELVIEW);
}
int main(int argc, char **argv)
{
// setup glut
glutInit(&argc, argv);
initScene();
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE); //We’ll discuss these later
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( WIN_WIDTH , WIN_HEIGHT );
// init();
//You’ll need a handle for your main window for GLUI
main_window = glutCreateWindow( “Graph Maker” );
glutDisplayFunc(Display );
glutReshapeFunc( myGlutReshape );
glutMotionFunc( myGlutMotion );
glutMouseFunc( myGlutMouse );
// Initialize my Scene
//Build the GUI
glui = GLUI_Master.create_glui( “Graph Maker GUI”, 0, 600, 50 );
GLUI_Panel *componentPanel = glui->add_panel(“Graph Components”);
glui->add_button_to_panel(componentPanel, “Square”, SQUARE_BUTTON_ID, buttonCB);
glui->add_button_to_panel(componentPanel, “Triangle”, TRIANGLE_BUTTON_ID, buttonCB);
glui->add_separator();
GLUI_Panel *colorPanel = glui->add_panel(“Color”);
// These could be done with floats but I ran into some issues
GLUI_Spinner *redValue = glui->add_spinner_to_panel(colorPanel, “Red”, 2, &red, RED, colorCB);
redValue->set_int_limits(0, 255);
GLUI_Spinner *greenValue = glui->add_spinner_to_panel(colorPanel, “Green”, 2, &green,GREEN, colorCB);
greenValue->set_int_limits(0,255);
GLUI_Spinner *blueValue = glui->add_spinner_to_panel(colorPanel, “Blue”, 2, &blue, BLUE, colorCB);
blueValue->set_int_limits(0.0, 255);
glui->set_main_gfx_window( main_window );
// We register the idle callback with GLUI, not with GLUT
//GLUI_Master.set_glutIdleFunc( myGlutIdle );
GLUI_Master.set_glutIdleFunc( NULL );
glutMainLoop();
return EXIT_SUCCESS;
}
drawing
void drawSquare()
{
// Code to draw a square
//if( flag==1)
glColor3f(++red,green,blue);
glBegin(GL_QUADS);
glVertex2f(220,220);
glVertex2f(220,250);
glVertex2f(280,280);
glVertex2f(220,280);
glEnd();