void idle(){ static int calls=1000; float x, y; float inside=0.f, outside=0.f; char calculatedPi[50]; for(int i=0; i<calls; i++){ x=(float)(rand()%75000)/100000*(rand()%2 ? 1 : -1); y=(float)(rand()%75000)/100000*(rand()%2 ? 1 : -1); if(sqrt(x*x+y*y)<=.75){ glColor3f(0, 1, 0); inside+=1.f; }else{ glColor3f(1, 0, 0); outside+=1.f; } drawPoint(x, y); } sprintf(calculatedPi, "This simulation suggests pi is %.9f", (2.25f*(inside/(inside+outside)))/(.5625f)); glColor3f(1, 1, 1); glScissor(0, 0, 400, 50); glEnable(GL_SCISSOR_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_SCISSOR_TEST); drawBitmapText(-0.9f, -0.9f, calculatedPi); glutSwapBuffers(); calls+=calls/100; }
void BitMap::privateRender() { //glClear(GL_COLOR_BUFFER_BIT); glColor3f(1, 0.5, 0.7); drawBitmapText("Shooting", 10, 660); //glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); //glDepthFunc(GL_ALWAYS); }
void draw(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //draw working window and panel with set of tools draw_grid(); draw_panel(border); glColor3f(0, 0, 0); drawBitmapText("Tools", 2, 770); draw_buttons(); }
/* function that draws window with all stuff */ void draw(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); /* draw working window and panel with set of tools */ drawGrid(); drawPanel(mapState.border); glColor3f(0, 0, 0); drawBitmapText("Tools", BITMAPTEXT_X, BITMAPTEXT_Y); drawButtons(); passiveLineMotion(mapState.points_storage, mapState.previous_point, mapState.passive_motion_point); drawEdgeVertices(mapState.points_storage, RADIUS_OF_POINT); drawEdges(mapState.edges_storage); checkSelectedPoint(mapState.points_storage, mapState.passive_motion_point); markSelectedPoint(mapState.previous_point, mapState.selected_point, SIZE_OF_SHINING_CIRCLE); glutSwapBuffers(); glFlush(); }