void GLUI_ActiveText::draw_active_area( void ) { if (currently_highlighted) { glColor3ub( glui->bkgd_color[0]+25, glui->bkgd_color[1]+25, glui->bkgd_color[2]+25 ); } else { glColor3ub( glui->bkgd_color[0], glui->bkgd_color[1], glui->bkgd_color[2] ); } glBegin( GL_QUADS ); glVertex2f( -0.5 + 2 , -0.5 + 2 ); glVertex2f( -0.5 + w-2, -0.5 + 2 ); glVertex2f( -0.5 + w-2, -0.5 + h-1 ); glVertex2f( -0.5 + 2 , -0.5 + h-1 ); glEnd(); if ( currently_pressed && currently_inside ) { draw_name( 3 + 1, 13 + 1); } else { draw_name( 3 , 13 ); } }
void GLUI_EditText::draw( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM int name_x; name_x = MAX(text_x_offset - string_width(this->name) - 3,0); draw_name( name_x , 13); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( text_x_offset, 0 ); glVertex2i( w, 0 ); glVertex2i( text_x_offset, 0 ); glVertex2i( text_x_offset, h ); glColor3f( 1., 1., 1. ); glVertex2i( text_x_offset, h ); glVertex2i( w, h ); glVertex2i( w, h ); glVertex2i( w, 0 ); if ( enabled ) glColor3f( 0., 0., 0. ); else glColor3f( .25, .25, .25 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( w-1, 1 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( text_x_offset+1, h-1 ); glColor3f( .75, .75, .75 ); glVertex2i( text_x_offset+1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, 1 ); glEnd(); /** Find where to draw the text **/ update_substring_bounds(); draw_text(0,0); draw_insertion_pt(); }
void GLUI_RadioButton::draw( int x, int y ) { int orig; orig = set_to_glut_window(); if ( NOT group OR NOT can_draw() ) return; /*** See if we're the currently-selected button. If so, draw ***/ if ( group->int_val == this->user_id ) { if ( enabled ) glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_ON, 0, 0 ); else glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_ON_DIS, 0, 0 ); } else { if ( enabled ) glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_OFF, 0, 0 ); else glui->std_bitmaps.draw( GLUI_STDBITMAP_RADIOBUTTON_OFF_DIS, 0, 0 ); } draw_active_area(); draw_name( text_x_offset, 10 ); restore_window(orig); }
void GLUI_StaticText::draw_text( void ) { if ( NOT can_draw() ) return; erase_text(); draw_name( 0, 9 ); }
/** * Does complete refresh of game screen */ void refresh_game_screen() { ClearVram(); DrawMap2(0, 0, tiles_screen); draw_field(); draw_molecule(SCREEN_MOLECULE_X, SCREEN_MOLECULE_Y); draw_statistics(); draw_name(); draw_cursor(); }
void GLUI_Mouse_Interaction::draw( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM int text_width = string_width( this->name ); int x_left = this->w/2 - text_width/2; if ( NOT draw_active_area_only ) { draw_name( x_left, h-4 ); draw_active_box( x_left-4, x_left+string_width( name )+4, h, h-14 ); } draw_active_area(); }
void GLUI_Button::draw_text( int sunken ) { int string_width; glColor3ub( glui->bkgd_color.r, glui->bkgd_color.g, glui->bkgd_color.b ); glDisable( GL_CULL_FACE ); glBegin( GL_QUADS ); glVertex2i( 2, 2 ); glVertex2i( w-2, 2 ); glVertex2i( w-2, h-2 ); glVertex2i( 2, h-2 ); glEnd(); glColor3ub( 0,0,0 ); string_width = _glutBitmapWidthString( glui->font, this->name.c_str() ); if ( NOT sunken ) { draw_name( MAX((w-string_width),0)/2, 13); } else { draw_name( MAX((w-string_width),0)/2 + 1, 13 + 1); } if ( active ) { glEnable( GL_LINE_STIPPLE ); glLineStipple( 1, 0x5555 ); glColor3f( 0., 0., 0. ); glBegin( GL_LINE_LOOP ); glVertex2i( 3, 3 ); glVertex2i( w-3, 3 ); glVertex2i( w-3, h-3 ); glVertex2i( 3, h-3 ); glEnd(); glDisable( GL_LINE_STIPPLE ); } }
void celestial_body::draw(const simulation_context *sim_context, const drawing_context *draw_context) { // set up projection vector ep = utils::pos_in_eye_space(this); gsgl::real_t radius = gsgl::max_val(get_polar_radius(), get_equatorial_radius()); gsgl::real_t dist = ep.mag(); gsgl::real_t zdist = -ep.get_z(); gsgl::real_t far_plane = zdist + (radius * 1.1f); gsgl::real_t near_plane = zdist - (radius * 1.1f); if (near_plane <= 0) near_plane = 1; display::scoped_perspective proj(*draw_context->screen, draw_context->cam->get_field_of_view(), draw_context->screen->get_aspect_ratio(), near_plane, far_plane); display::scoped_color white(*draw_context->screen, color::WHITE); // check to see if we're out of range gsgl::real_t screen_width = utils::pixel_size(dist, radius, draw_context->cam->get_field_of_view(), draw_context->screen->get_height()); if (screen_width < MIN_PIXEL_WIDTH) { display::scoped_state state(*draw_context->screen, draw_context->display_flags(this, drawing_context::RENDER_NO_LIGHTING)); set_flags(get_draw_results(), node::NODE_DREW_POINT); draw_context->screen->draw_point(vector::ZERO, MIN_PIXEL_WIDTH); } else { utils::sphere *sph = get_simple_sphere(); if (sph) { display::scoped_state state(*draw_context->screen, draw_context->display_flags(this)); // the simple sphere may be rotated... rotating_body *rb = get_rotating_frame(); display::scoped_modelview mv(*draw_context->screen, rb ? &rb->get_modelview() : 0); display::scoped_material mat(*draw_context->screen, simple_material); draw_context->screen->clear(display::CLEAR_DEPTH); sph->draw(sim_context, draw_context); } } // draw name draw_name(draw_context); } // celestial_body::draw()
void GLUI_Slider::draw( int x, int y ) { int orig; if ( NOT glui ) return; orig = set_to_glut_window(); draw_emboss_box( 0, w, GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_FONT_HEIGHT - 1 - GLUI_SLIDER_FONT_MID_HEIGHT, h ); draw_bkgd_box( GLUI_SLIDER_NAME_INDENT-1, GLUI_SLIDER_NAME_INDENT + string_width(name.string) + 2*GLUI_SLIDER_NAME_SIDE_BORDER - 1, 0, 0 + GLUI_SLIDER_FONT_FULL_HEIGHT + GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_NAME_BOTTOM_BORDER); draw_name( GLUI_SLIDER_NAME_INDENT + GLUI_SLIDER_NAME_SIDE_BORDER, GLUI_SLIDER_FONT_HEIGHT-1 + GLUI_SLIDER_NAME_TOP_BORDER); draw_active_area(); restore_window(orig); draw_active_box( GLUI_SLIDER_NAME_INDENT, GLUI_SLIDER_NAME_INDENT + string_width(name.string) + 2*GLUI_SLIDER_NAME_SIDE_BORDER - 1, 0, GLUI_SLIDER_FONT_FULL_HEIGHT + GLUI_SLIDER_NAME_TOP_BORDER + GLUI_SLIDER_NAME_BOTTOM_BORDER - 1); }
void GLUI_EditText::draw( int x, int y ) { int orig; int name_x; if ( NOT can_draw() ) return; orig = set_to_glut_window(); name_x = MAX(text_x_offset - string_width(this->name) - 3,0); draw_name( name_x , 13); glBegin( GL_LINES ); glColor3f( .5, .5, .5 ); glVertex2i( text_x_offset, 0 ); glVertex2i( w, 0 ); glVertex2i( text_x_offset, 0 ); glVertex2i( text_x_offset, h ); glColor3f( 1., 1., 1. ); glVertex2i( text_x_offset, h ); glVertex2i( w, h ); glVertex2i( w, h ); glVertex2i( w, 0 ); if ( enabled ) glColor3f( 0., 0., 0. ); else glColor3f( .25, .25, .25 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( w-1, 1 ); glVertex2i( text_x_offset+1, 1 ); glVertex2i( text_x_offset+1, h-1 ); glColor3f( .75, .75, .75 ); glVertex2i( text_x_offset+1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, h-1 ); glVertex2i( w-1, 1 ); glEnd(); /** Find where to draw the text **/ update_substring_bounds(); draw_text(0,0); draw_insertion_pt(); restore_window(orig); }
void GLUI_Listbox::draw( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM int name_x; /* draw_active_area(); */ name_x = MAX(text_x_offset - string_width(this->name) - 3,0); draw_name( name_x , 13); draw_box_inwards_outline( text_x_offset, w, 0, h ); if ( NOT active ) { draw_box( text_x_offset+3, w-2, 2, h-2, 1.0, 1.0, 1.0 ); if ( NOT enabled ) glColor3b( 32, 32, 32 ); else glColor3f( 0.0, 0.0, 0.0 ); glRasterPos2i( text_x_offset+5, 13 ); draw_string( curr_text ); } else { draw_box( text_x_offset+3, w-2, 2, h-2, .0, .0, .6 ); glColor3f( 1.0, 1.0, 1.0 ); glRasterPos2i( text_x_offset+5, 13 ); draw_string( curr_text ); } if ( enabled ) { glui->std_bitmaps. draw(GLUI_STDBITMAP_LISTBOX_UP, w-glui->std_bitmaps.width(GLUI_STDBITMAP_LISTBOX_UP)-1, 2 ); } else { glui->std_bitmaps. draw(GLUI_STDBITMAP_LISTBOX_UP_DIS, w-glui->std_bitmaps.width(GLUI_STDBITMAP_LISTBOX_UP)-1, 2 ); } }
void GLUI_Mouse_Interaction::draw( int x, int y ) { int orig; int text_width = string_width( this->name ); int x_left = this->w/2 - text_width/2; if ( NOT glui ) return; if ( NOT draw_active_area_only ) { orig = set_to_glut_window(); draw_name( x_left, h-4 ); restore_window(orig); draw_active_box( x_left-4, x_left+string_width( name.string )+4, h, h-14 ); } draw_active_area(); }
void GLUI_Graph::draw( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM; draw_emboss_box( 0, w, GLUI_GRAPH_NAME_TOP_BORDER + GLUI_GRAPH_FONT_HEIGHT - 1 - GLUI_GRAPH_FONT_MID_HEIGHT, h ); draw_bkgd_box( GLUI_GRAPH_NAME_INDENT-1, GLUI_GRAPH_NAME_INDENT + string_width(name) + 2*GLUI_GRAPH_NAME_SIDE_BORDER - 1, 0, 0 + GLUI_GRAPH_FONT_FULL_HEIGHT + GLUI_GRAPH_NAME_TOP_BORDER + GLUI_GRAPH_NAME_BOTTOM_BORDER); draw_name( GLUI_GRAPH_NAME_INDENT + GLUI_GRAPH_NAME_SIDE_BORDER, GLUI_GRAPH_FONT_HEIGHT-1 + GLUI_GRAPH_NAME_TOP_BORDER); draw_active_area(); draw_active_box( GLUI_GRAPH_NAME_INDENT, GLUI_GRAPH_NAME_INDENT + string_width(name) + 2*GLUI_GRAPH_NAME_SIDE_BORDER - 1, 0, GLUI_GRAPH_FONT_FULL_HEIGHT + GLUI_GRAPH_NAME_TOP_BORDER + GLUI_GRAPH_NAME_BOTTOM_BORDER - 1); }
void GLUI_Panel::draw( int x, int y ) { int top; GLUI_DRAWINGSENTINAL_IDIOM if ( int_val == GLUI_PANEL_RAISED ) { top = 0; glLineWidth( 1.0 ); glColor3f( 1.0, 1.0, 1.0 ); glBegin( GL_LINE_LOOP ); glVertex2i( 0, top ); glVertex2i( w, top ); glVertex2i( 0, top ); glVertex2i( 0, h ); glEnd(); glColor3f( .5, .5, .5 ); glBegin( GL_LINE_LOOP ); glVertex2i( w, top ); glVertex2i( w, h ); glVertex2i( 0, h ); glVertex2i( w, h ); glEnd(); /** ORIGINAL RAISED PANEL METHOD - A LITTLE TOO HIGH ** glLineWidth(1.0); glBegin( GL_LINES ); glColor3f( 1.0, 1.0, 1.0 ); glVertex2i( 1, 1 ); glVertex2i( w-2, 1 ); glVertex2i( 1, 1 ); glVertex2i( 1, h-2 ); glColor3f( .5, .5, .5 ); glVertex2i( w-1, 1 ); glVertex2i( w-1, h-1 ); glVertex2i( 1, h-1 ); glVertex2i( w-1, h-1 ); glColor3f( 0.0, 0.0, 0.0 ); glVertex2i( 0, h ); glVertex2i( w, h ); glVertex2i( w, 0 ); glVertex2i( w, h ); glEnd(); -- Touch up the lines a bit (needed in some opengl implementations glBegin( GL_POINTS ); glColor3f( .5, .5, .5 ); glVertex2i( w-1, h-1 ); glColor3f( 0.0, 0.0, 0.0 ); glVertex2i( w, h ); glEnd(); **/ } else if ( int_val == GLUI_PANEL_EMBOSSED ) { if ( parent_node == NULL || name == "" ) { top = 0; } else { top = GLUI_PANEL_EMBOSS_TOP; } glLineWidth( 1.0 ); glColor3f( 1.0, 1.0, 1.0 ); glBegin( GL_LINE_LOOP ); glVertex2i( 0, top ); glVertex2i( w, top ); glVertex2i( w, h ); glVertex2i( 0, h ); glVertex2i( 1, top+1 ); glVertex2i( w-1, top+1 ); glVertex2i( w-1, h-1 ); glVertex2i( 1, h-1 ); glEnd(); glColor3f( .5, .5, .5 ); glBegin( GL_LINE_LOOP ); glVertex2i( 0, top ); glVertex2i( w-1, top ); glVertex2i( w-1, h-1 ); glVertex2i( 0, h-1 ); glEnd(); /**** Only display text in embossed panel ****/ if ( parent_node != NULL && name != "" ) { /* Only draw non-null strings */ int left = 7, height=GLUI_PANEL_NAME_DROP+1; int str_width; str_width = string_width(name); if ( glui ) glColor3ub(glui->bkgd_color.r,glui->bkgd_color.g,glui->bkgd_color.b); glDisable( GL_CULL_FACE ); glBegin( GL_QUADS ); glVertex2i( left-3, 0 ); glVertex2i( left+str_width+3, 0 ); glVertex2i( left+str_width+3, height ); glVertex2i( left-3, height ); glEnd(); draw_name( left, GLUI_PANEL_NAME_DROP ); } } glLineWidth( 1.0 ); }
void GLUI_Panel::draw( int x, int y ) { int top, orig; if ( NOT can_draw() ) return; orig = set_to_glut_window(); if ( int_val == GLUI_PANEL_RAISED ) { top = 0; glLineWidth( 1.0 ); glColor3f( 1.0, 1.0, 1.0 ); glBegin( GL_LINE_LOOP ); glVertex2i( 0, top ); glVertex2i( w, top ); glVertex2i( 0, top ); glVertex2i( 0, h ); glEnd(); glColor3f( .5, .5, .5 ); glBegin( GL_LINE_LOOP ); glVertex2i( w, top ); glVertex2i( w, h ); glVertex2i( 0, h ); glVertex2i( w, h ); glEnd(); /** ORIGINAL RAISED PANEL METHOD - A LITTLE TOO HIGH ** glLineWidth(1.0); glBegin( GL_LINES ); glColor3f( 1.0, 1.0, 1.0 ); glVertex2i( 1, 1 ); glVertex2i( w-2, 1 ); glVertex2i( 1, 1 ); glVertex2i( 1, h-2 ); glColor3f( .5, .5, .5 ); glVertex2i( w-1, 1 ); glVertex2i( w-1, h-1 ); glVertex2i( 1, h-1 ); glVertex2i( w-1, h-1 ); glColor3f( 0.0, 0.0, 0.0 ); glVertex2i( 0, h ); glVertex2i( w, h ); glVertex2i( w, 0 ); glVertex2i( w, h ); glEnd(); -- Touch up the lines a bit (needed in some opengl implementations glBegin( GL_POINTS ); glColor3f( .5, .5, .5 ); glVertex2i( w-1, h-1 ); glColor3f( 0.0, 0.0, 0.0 ); glVertex2i( w, h ); glEnd(); **/ } else if ( int_val == GLUI_PANEL_EMBOSSED ) { if ( name[0] == '\0' ) { top = 0; } else { top = GLUI_PANEL_EMBOSS_TOP; } glLineWidth( 1.0 ); glColor3f( 1.0, 1.0, 1.0 ); glBegin( GL_LINE_LOOP ); glVertex2i( 0, top ); glVertex2i( w, top ); glVertex2i( w, h ); glVertex2i( 0, h ); glVertex2i( 1, top+1 ); glVertex2i( w-1, top+1 ); glVertex2i( w-1, h-1 ); glVertex2i( 1, h-1 ); glEnd(); glColor3f( .5, .5, .5 ); glBegin( GL_LINE_LOOP ); glVertex2i( 0, top ); glVertex2i( w-1, top ); glVertex2i( w-1, h-1 ); glVertex2i( 0, h-1 ); glEnd(); /**** Only display text in embossed panel ****/ if ( name[0] != '\0' ) { /* Only draw non-null strings */ int left = 7, height=GLUI_PANEL_NAME_DROP+1; int str_width; str_width = string_width(name); if ( glui ) glColor3ub(glui->bkgd_color.r,glui->bkgd_color.g,glui->bkgd_color.b); glDisable( GL_CULL_FACE ); glBegin( GL_QUADS ); glVertex2i( left-3, 0 ); glVertex2i( left+str_width+3, 0 ); glVertex2i( left+str_width+3, height ); glVertex2i( left-3, height ); glEnd(); draw_name( left, GLUI_PANEL_NAME_DROP ); } } glLineWidth( 1.0 ); restore_window(orig); }
void large_rocky_body::draw(const simulation_context *sim_context, const drawing_context *draw_context) { lithosphere *litho = get_lithosphere(); if (litho) { vector pos_in_view = get_modelview() * vector::ZERO; gsgl::real_t radius = gsgl::max_val(get_polar_radius(), get_equatorial_radius()); gsgl::real_t dist = pos_in_view.mag(); gsgl::real_t zdist = -pos_in_view.get_z(); assert(zdist > 0); gsgl::real_t far_plane = zdist + (radius * 1.1f); gsgl::real_t near_plane = zdist - (radius * 1.1f); if (near_plane <= 0) near_plane = 1; display::scoped_perspective proj(*draw_context->screen, draw_context->cam->get_field_of_view(), draw_context->screen->get_aspect_ratio(), near_plane, far_plane); display::scoped_color cc(*draw_context->screen, color::WHITE); gsgl::real_t screen_width = utils::pixel_size(dist, radius, draw_context->cam->get_field_of_view(), draw_context->screen->get_height()); if (screen_width < MIN_PIXEL_WIDTH) { display::scoped_state state(*draw_context->screen, draw_context->display_flags(this, drawing_context::RENDER_NO_LIGHTING)); set_flags(get_draw_results(), node::NODE_DREW_POINT); draw_context->screen->draw_point(vector::ZERO, MIN_PIXEL_WIDTH); } else { display::scoped_state state(*draw_context->screen, draw_context->display_flags(this)); draw_context->screen->clear(display::CLEAR_DEPTH); display::scoped_modelview mv(*draw_context->screen, &litho->get_modelview()); litho->draw(sim_context, draw_context); } // draw name draw_name(draw_context); } else { celestial_body::draw(sim_context, draw_context); } #if 0 lithosphere *litho = get_lithosphere(); if (litho) { glPushAttrib(GL_ALL_ATTRIB_BITS); CHECK_GL_ERRORS(); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); CHECK_GL_ERRORS(); vector ep = utils::pos_in_eye_space(this); gsgl::real_t radius = gsgl::max_val(get_polar_radius(), get_equatorial_radius()); gsgl::real_t dist = ep.mag(); gsgl::real_t zdist = -ep.get_z(); gsgl::real_t far_plane = zdist + (radius * 1.1f); gsgl::real_t near_plane = zdist - (radius * 1.1f); if (near_plane <= 0) near_plane = 1; glMatrixMode(GL_PROJECTION); CHECK_GL_ERRORS(); glLoadIdentity(); CHECK_GL_ERRORS(); gluPerspective(draw_context->cam->get_field_of_view(), draw_context->screen->get_aspect_ratio(), near_plane, far_plane); CHECK_GL_ERRORS(); // check to see if we're out of range gsgl::real_t screen_width = utils::pixel_size(dist, radius, draw_context->cam->get_field_of_view(), draw_context->screen->get_height()); color::WHITE.bind(); if (screen_width < MIN_PIXEL_WIDTH) { get_draw_results() |= node::NODE_DREW_POINT; draw_point(MIN_PIXEL_WIDTH); } else { glClearDepth(1); CHECK_GL_ERRORS(); glClear(GL_DEPTH_BUFFER_BIT); CHECK_GL_ERRORS(); glEnable(GL_DEPTH_TEST); CHECK_GL_ERRORS(); glEnable(GL_CULL_FACE); CHECK_GL_ERRORS(); glPolygonMode(GL_FRONT_AND_BACK, (draw_context->render_flags & drawing_context::RENDER_WIREFRAME) ? GL_LINE : GL_FILL); CHECK_GL_ERRORS(); // set up lighting if (!(draw_context->render_flags & drawing_context::RENDER_NO_LIGHTING) && !(get_draw_flags() & NODE_DRAW_UNLIT)) { glEnable(GL_LIGHTING); CHECK_GL_ERRORS(); glLightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); CHECK_GL_ERRORS(); glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); CHECK_GL_ERRORS(); //glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color::WHITE.get_val()); CHECK_GL_ERRORS(); glMaterialfv(GL_FRONT, GL_SPECULAR, color::BLACK.get_val()); CHECK_GL_ERRORS(); glMaterialfv(GL_FRONT, GL_EMISSION, color::BLACK.get_val()); CHECK_GL_ERRORS(); glMaterialf(GL_FRONT, GL_SHININESS, 8); CHECK_GL_ERRORS(); } // set up texturing if (!(draw_context->render_flags & drawing_context::RENDER_NO_TEXTURES)) { glEnable(GL_TEXTURE_2D); } // draw lithosphere glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadMatrixf(litho->get_modelview().ptr()); litho->draw(sim_context, draw_context); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } glPopClientAttrib(); CHECK_GL_ERRORS(); glPopAttrib(); CHECK_GL_ERRORS(); draw_name(draw_context, 1, far_plane); } else { celestial_body::draw(sim_context, draw_context); } #endif } // large_rocky_body::draw()
int title_screen(const char *commands[100], int *f, double noteinfo[2][1000], char output[1000]){ int xsize=1250; int ysize=1000; int xpos; int ypos; int height=400; int width=(xsize-50)/16; int i,j; char input[20]; char initial[1000]; char c; gfx_open(xsize, ysize, "Digital Piano"); quit_button(); draw_title(100); draw_name(50); draw_name2(50); draw_button(295,600,70,310); draw_button(645,600,70,310); button_label(60); button_label2(60); while (1){ c=gfx_wait(); xpos=gfx_xpos(); ypos=gfx_ypos(); //user clicks the quit button if (xpos>=1110 && xpos<=1210 && ypos>=850 && ypos<=890){ return 0; } //user clicks free play button if (xpos>=295 && xpos<=605 && ypos>=600 && ypos<=670){ gfx_clear(); piano_graphic(commands, f); } //user clicks load file button if (xpos>=645 && xpos<=955 && ypos>=600 && ypos<=670){ terminal_message(); printf("Please enter the name of the file, including the extension.\nThe file content should follow the same format as the examples in lab 8:\n"); scanf("%s", input); //scans file name into input FILE *music=fopen(input, "r"); if ((music=fopen(input, "r")) == NULL){ //returns error if file not found puts("File could not be opened"); return 0; } else{ //scans the file into output for (j=0; j<1000; j++){ fscanf(music, "%c", &output[j]); if (output[j]=='X'){ break; } } } piano2(noteinfo, output); //fork to play sound while lighting up keys if (fork()){ system("play sound.wav"); } else{ gfx_clear(); draw_piano(width, height); draw_arrow(50, f); gfx_color(255,255,255); draw_box(); octave_label(30); quit_button(); gfx_flush(); key_animation(noteinfo, f); return 0; } } } }
void GLUI_Rollout::draw( int x, int y ) { GLUI_DRAWINGSENTINAL_IDIOM int left, right, top, bottom; left = 5; right = w-left; top = 3; bottom = 3+16; if ( is_open ) draw_emboss_box( 0, w, top+3, h ); else draw_emboss_box( 0, w, top+3, h-7 ); glui->draw_raised_box( left, top, w-left*2, 16 ); if ( glui ) glColor3ub(glui->bkgd_color.r,glui->bkgd_color.g,glui->bkgd_color.b); glDisable( GL_CULL_FACE ); glBegin( GL_QUADS ); glVertex2i( left+1, top+1 ); glVertex2i( right-1, top+1 ); glVertex2i( right-1, bottom-1 ); glVertex2i( left+1, bottom-1 ); glEnd(); draw_name( left+8, top+11 ); if ( active ) /*draw_active_box( left+4, left+string_width( name.c_str() )+12, */ draw_active_box( left+4, right-17, top+2, bottom-2 ); /** Draw '+' or '-' **/ glBegin( GL_LINES ); if ( is_open ) { if ( enabled ) glColor3f( 0.0, 0.0, 0.0 ); else glColor3f( 0.5, 0.5, 0.5 ); glVertex2i(right-14,(top+bottom)/2); glVertex2i(right-5,(top+bottom)/2); glColor3f( 1.0, 1.0, 1.0 ); glVertex2i(right-14,1+(top+bottom)/2);glVertex2i(right-5,1+(top+bottom)/2); } else { glColor3f( 1.0, 1.0, 1.0 ); glVertex2i(right-9,top+3); glVertex2i(right-9,bottom-4); glVertex2i(right-14,(top+bottom)/2); glVertex2i(right-5,(top+bottom)/2); if ( enabled ) glColor3f( 0.0, 0.0, 0.0 ); else glColor3f( 0.5, 0.5, 0.5 ); glVertex2i(right-14,-1+(top+bottom)/2); glVertex2i(right-5,-1+(top+bottom)/2); glVertex2i(right-10,top+3); glVertex2i(right-10,bottom-4); } glEnd(); glLineWidth( 1.0 ); if (currently_inside) {draw_pressed(); /* heavy black outline when pressed */ } }