void display(float k, float m, float v, float b, float t){ int i; const float distance = 3.0; atom a; GLint circle_points = 100; float angle; float x, y, z, x1, y1, z1, x0, y0, z0; x0 = 0.0; y0 = 0.0; z0 = 0.0; a.move(x0, y0, z0); a.set_k(k); a.set_m(m); a.set_t(t); a.set_b(b); angle = 90.0; x1 = (x0 + t*v*(1-b*t/(2*m))-k*pow(t,2)*x0/(2*m))*cos(angle*PI/180); y1 = (y0 + t*v*(1-b*t/(2*m))-k*pow(t,2)*y0/(2*m))*sin(angle*PI/180); z1 = 0.0; a.move(x1, y1, z1); do{ x = a.position.get_x(); y = a.position.get_y(); z = a.position.get_z(); draw_axis(WIDTH, HEIGHT); /*glPointSize(6.0); glBegin(GL_POINTS); glVertex3f(x, y, z); glEnd(); glFlush();*/ glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0, 0.7, 1.0); glPushMatrix(); draw_axis(WIDTH, HEIGHT); glTranslatef(x, y, z); glutWireSphere(20, 16, 16); // draw the earth glPopMatrix(); glutSwapBuffers(); usleep(t*40000); }while(a.motion()); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glFlush(); }
void Radar::draw() { update(); // ofNoFill(); // ofSetColor(255); // ofRect(x,y,w,h); // ofFill(); cam.begin(ofRectangle(x, y, w, h)); // ofRect(0,0,w,h); ofNoFill(); ofSetColor(0,255,0); radialSplineShader.begin(); radialSplineShader.setUniform1f("thickness", 3.5); radialSplineShader.setUniform1f("minTheta", minTheta); radialSplineShader.setUniform1f("maxTheta", maxTheta); radialSplineShader.setUniform2f("center", absolute_center.x, ofGetHeight()-absolute_center.y); radialSplineShader.setUniform1f("alphaSub", alphaSub); float descale = 0.1; for (int i = 0; i < 9; i++) { ofPushMatrix(); { ofScale(1-descale*i, 1-descale*i, 1-descale*i); bezierLineMesh.draw(); } ofPopMatrix(); } radialSplineShader.end(); // Rotating period // axisShader.begin(); // axisShader.setUniform1f("thickness", 1.0); ofSetColor(COLOR_95); draw_axis(maxTheta); draw_axis(minTheta); // axisShader.end(); if (debug) { ofSetColor(255,150); debug_draw_bezier_segments(); debug_draw_aframe(); // Axes ofSetColor(255,0,0); ofLine(0, 0, 0, 20, 0, 0); ofSetColor(0,255,0); ofLine(0, 0, 0, 0, 20, 0); ofSetColor(0,0,255); ofLine(0, 0, 0, 0, 0, 20); } cam.end(); }
//========================================================================== // appDrawScene() will redraw the scene accodring to the current state of // the application. For more complex scenes, display lists should be used. //========================================================================== void appDrawScene () { // Clear the rendering buffer: glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Set the viewing frustum for a coordinate range in [-10,10]^3 int w = glutGet ( GLUT_WINDOW_WIDTH ); int h = glutGet ( GLUT_WINDOW_HEIGHT ); double aspect = double(w)/double(h); glMatrixMode ( GL_PROJECTION ); glLoadIdentity (); gluPerspective ( App->fovy, aspect, 2/*znear*/, 50/*zfar*/ ); gluLookAt ( 0, 0, -20, // eye 0, 0, 0, // center 0, 1, 0 ); // up vector // Clear the model transformation stack: glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // Rotate the scene for some simple visualization: glRotated ( App->rotx, 1, 0, 0 ); glRotated ( App->roty, 0, 1, 0 ); // Draw: if ( App->viewaxis ) draw_axis ( 10.0 ); draw_wire_tube(App->len, App->rt, App->rb, App->nfaces); // Show back buffer: glFlush(); // flush the pipeline (usually not necessary) glutSwapBuffers(); // we were drawing to the back buffer, now bring it to the front }
void GLWidget::paintGL(){ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0f,(GLfloat)width/(GLfloat)height,0.01f,650.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt( 0.0, cam_radius, cam_radius, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glViewport(0, 0, width, height); glRotatef( rotate_x, 1.0, 0.0, 0.0 ); glRotatef( rotate_y, 0.0, 0.0, 1.0 ); draw_layers(); if (show_grid) draw_grid(-0.5,-0.5,0.1,0.1,11,11,&guide_z,&guide_col); if (show_axis) draw_axis(); glFlush(); }
//rewrite draw method virtual void draw(){ reshape(); if(!valid()){ static GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0}; static GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0}; glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } valid(1); glClearColor (0.25,0.5,0.5, 1.0); glDepthFunc (GL_LESS); glEnable (GL_DEPTH_TEST); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); arcball_transform();//apply transformation if(show_axis)draw_axis(); drawCube(); if(show_3d_ort)draw_3d_orbit(); if(show_scale)draw_zoom_scale(); glPopMatrix(); glFinish(); }
void draw_scene(void){ clear_window(); change_observer(); draw_axis(); draw_objects(); glutSwapBuffers(); }
void callBackDisplay(void) { glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (GLdouble)winwidth/winheight, 0.01, 100); camera.move( phyEngine->getPositionBody(Body::Trunk) - camera.lookAt ); camera.transform(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_LIGHTING); draw_axis(); glEnable(GL_LIGHTING); glPushMatrix(); glSetMaterial(1,1,1); simBird->drawBird(); // bird model glPopMatrix(); glutSwapBuffers(); }
int main(int argc, char* argv[]){ parse_args(argc, argv); init_ui(); init_structs(); init_plotter(); start_debug(); int x; while (!options.quit) { clear(); set_terminal_size(); draw_axis(); replot_functions(); x = input(); if(x == -1) break; refresh(); } clean_plotter(); clean_ui(); return 0; }
void init(int w, int h){ // выбираем цвет очистки фона glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D((float)-w/2, (float)w/2, (float)-h/2, (float)h/2); draw_axis(WIDTH, HEIGHT); }
void draw_gps_orientation (double gps_orientation, int gps_heading_valid, carmen_orientation_3D_t xsens_orientation, carmen_pose_3D_t xsens_pose, carmen_pose_3D_t sensor_board_pose, carmen_pose_3D_t car_pose) { carmen_vector_3D_t xsens_global_position = get_xsens_position_global_reference (xsens_pose, sensor_board_pose, car_pose); glPushMatrix (); glTranslatef (xsens_global_position.x, xsens_global_position.y, xsens_global_position.z); glRotatef (carmen_radians_to_degrees (gps_orientation), 0.0f, 0.0f, 1.0f); glRotatef (carmen_radians_to_degrees (xsens_orientation.pitch), 0.0f, 1.0f, 0.0f); glRotatef (carmen_radians_to_degrees (xsens_orientation.roll), 1.0f, 0.0f, 0.0f); if (gps_heading_valid) draw_axis (1.0); else draw_axis (0.5); glPopMatrix (); }
void GLWidget::paintGL() { if (_modelLighting) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING); glClearColor(_BackgroundColorR, _BackgroundColorG, _BackgroundColorB, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(eyex, eyey, eyez, // camera position targetx, targety, targetz, // target position up_vector.x, up_vector.y, up_vector.z); float scale_size(1 / 1.5); glPushMatrix(); if (_showFilteredMesh && !filtered_mesh.empty()) { glTranslatef(0.6, 0, 0); glScalef(scale_size, scale_size, scale_size); } if (!primary_meshes.empty()) { draw_mesh(primary_meshes[0]); //draw_mesh_test(primary_meshes[0]); //* if (vertex_chosen) { drawSphereOnVertex(chosen, 0.05); drawSphereOnVertex(chosen, 0.14); drawSphereOnVertex(chosen, 0.22); } //*/ } if (_showGrid) draw_grid(primary_meshes[0]); glPopMatrix(); if (_showFilteredMesh && !filtered_mesh.empty()) { glPushMatrix(); glTranslatef(-0.5, 0, 0); glScalef(scale_size, scale_size, scale_size); draw_mesh(filtered_mesh); glPopMatrix(); } if (_showAxis) { glPushMatrix(); glScalef(scale_size, scale_size, scale_size); draw_axis(); glPopMatrix(); } }
void draw_xsens_orientation (carmen_orientation_3D_t xsens_orientation, double xsens_yaw_bias, carmen_pose_3D_t xsens_pose, carmen_pose_3D_t sensor_board_pose, carmen_pose_3D_t car_pose) { carmen_vector_3D_t xsens_global_position = get_xsens_position_global_reference (xsens_pose, sensor_board_pose, car_pose); glPushMatrix (); glTranslatef (xsens_global_position.x, xsens_global_position.y, xsens_global_position.z); glRotatef (carmen_radians_to_degrees (xsens_orientation.yaw - xsens_yaw_bias), 0.0f, 0.0f, 1.0f); glRotatef (carmen_radians_to_degrees (xsens_orientation.pitch), 0.0f, 1.0f, 0.0f); glRotatef (carmen_radians_to_degrees (xsens_orientation.roll), 1.0f, 0.0f, 0.0f); draw_axis (1.0); glPopMatrix (); }
void Cartesian::draw_to(Drawable* drawable) { if(drawable) { draw_axis(drawable); if(function) { float from = function->from(), to = function->to(), step = function->step(); drawable->begin_path(); drawable->move_to(transfer_x(from), transfer_y(function->calculate(from))); for(float i = from; i <= to; i += step) { drawable->line_to(transfer_x(i), transfer_y(function->calculate(i))); } drawable->end_path(); } } };
/* * EduRaster drawing routines. */ static void draw(){ clear_buffer(); er_load_identity(); mat3 rotx, roty; rotatex_mat3(rotx, deg_to_rad(camera_phi)); rotatey_mat3(roty, deg_to_rad(camera_theta)); vec3 cam_pos = {0.0f, 0.0f, camera_offset}; mult_mat3_vec3(rotx, cam_pos, cam_pos); mult_mat3_vec3(roty, cam_pos, cam_pos); vec3 up_vec = {0.0f, 1.0f, 0.0f}; mult_mat3_vec3(rotx, up_vec, up_vec); mult_mat3_vec3(roty, up_vec, up_vec); er_look_at(cam_pos[0], cam_pos[1], cam_pos[2], 0.0f, 0.0f, 0.0f, up_vec[0], up_vec[1], up_vec[2]); er_use_program(program_axis); draw_axis(); er_use_program(current_surface_program); er_draw_elements(ER_TRIANGLES, index_size, index_data); }
void draw_line(int x, int y, int cantidad, int vectores [][2]) { // Clear the screen before drawing: glClear( GL_COLOR_BUFFER_BIT ); // draw the line glBegin(GL_LINES); draw_axis(); draw_vectors(cantidad, vectores); //dibuja lineas glVertex3f( SCREEN_WIDTH/2, SCREEN_HEIGHT/2, 0 ); glVertex3f( x, y, 0 ); dibuja_flecha(x,y); glEnd(); }
void d3d_control::render_frame(void) { // clear the window to a deep blue d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); //change wireframe mode if( fillmode_changed ){ if( !is_solid ){ d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID); } else{ d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME); } is_solid = !is_solid; fillmode_changed=false; } d3ddev->BeginScene(); // begins the 3D scene // select which vertex format we are using d3ddev->SetFVF(CUSTOMFVF); //set transform view_transform(); projection_transform(); // set the world transform D3DXMATRIX matLocal; D3DXMatrixIdentity(&matLocal); draw_axis( matLocal ); draw_text(); rs.draw(); d3ddev->EndScene(); // ends the 3D scene d3ddev->Present(NULL, NULL, NULL, NULL); // displays the created frame on the screen }
void Graph::draw(){ // glClear(GL_COLOR_BUFFER_BIT); glColor3d(10,10,10); //背景を白で描画 glRectd(-1,-1, 1,1); draw_axis(); glLineWidth(1.0); vector<DataSet<double>>::iterator it; it = Solid.begin(); while(it != Solid.end() ){ draw_data((*it), true); it++; } it = Dash.begin(); while(it != Dash.end() ){ draw_data((*it), false); it++; } }
/** render the scene */ void draw_scene() { static int cn = 0; static int part = 0; glClear(GL_COLOR_BUFFER_BIT); SDL_Delay(40); glMatrixMode(GL_PROJECTION); glLoadIdentity(); /* here take the bounding box of the whole circuit */ vcg::Point3f bmin = race.circuit->bbox.min; vcg::Point3f bmax = race.circuit->bbox.max; float sidex, sidez; sidex = bmax[0] - bmin[0]; sidez = bmax[2] - bmin[2]; cli.UpdatePlayers(); if (!cli.players.empty()) glOrtho(-6, 6, -6, 6, 0.0, 10.0); else glOrtho(-sidex*vieww, sidex*vieww, -sidez*vieww, sidez*vieww, 0.0, 400); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if (!cli.players.empty()) { vcg::Point4f pos = (*cli.players.begin()).car.frame.O(); gluLookAt(pos[0], 6.0, pos[2], pos[0], pos[1], pos[2], 0, 0, -1); } else { gluLookAt(obs[0], obs[1], obs[2], obs[0], obs[1] - 400, obs[2], 0, 0, -1); } // draw bounding box of the terrain glColor3f(0.1, 0.2, 0.4); glBegin(GL_QUADS); glVertex3f(bmin[0], bmin[1], bmin[2]); glVertex3f(bmax[0], bmin[1], bmin[2]); glVertex3f(bmax[0], bmin[1], bmax[2]); glVertex3f(bmin[0], bmin[1], bmax[2]); glEnd(); glPushMatrix(); glScalef(bmax[0] - bmin[0], bmax[1] - bmin[1], bmax[2] - bmin[2]); draw_axis(); glPopMatrix(); // draw circuit Street::TilesIterator ti; int i; glColor3f(1.0, 0.0, 0.0); glPolygonMode(GL_FRONT, GL_LINE); glBegin(GL_QUAD_STRIP); for (i = 0, ti = race.circuit->street.path.begin(); ti != race.circuit->street.path.end(); ++ti, ++i) { vcg::Point3f p0, p1; p0 = (*ti)[0].P(); p1 = (*ti)[1].P(); glVertex3f(p0[0], p0[1] + 0.1, p0[2]); glVertex3f(p1[0], p1[1] + 0.1, p1[2]); } glEnd(); // draw tunnels Street::TunnelsIterator tni; glColor3f(1.0, 1.0, 0.0); glPolygonMode(GL_FRONT, GL_FILL); for (i = 0, tni = race.circuit->street.tunnels.begin(); tni != race.circuit->street.tunnels.end(); ++tni, ++i) { glBegin(GL_QUAD_STRIP); for (i = 0, ti = (*tni).path.begin(); ti != (*tni).path.end(); ++ti, ++i) { vcg::Point3f p0, p1; p0 = (*ti)[0].P(); p1 = (*ti)[1].P(); glVertex3f(p0[0], p0[1] + 0.2, p0[2]); glVertex3f(p1[0], p1[1] + 0.2, p1[2]); } glEnd(); } // draw buildings Circuit::BuildingsIterator bi; glColor3f(1.0, 1.0, 1.0); glPolygonMode(GL_FRONT, GL_FILL); for (bi = race.circuit->buildings.begin(); bi != race.circuit->buildings.end(); ++bi) { glBegin(GL_POLYGON); for (i = 0; i < (*bi).footprint.size(); ++i) glVertex3f((*bi).footprint[i].P()[0], (*bi).footprint[i].P()[1], (*bi).footprint[i].P()[2]); glEnd(); } // draw trees Circuit::TreesIterator tsi; glColor3f(10.0, 1.0, 0.0); glBegin(GL_POINTS); for (tsi = race.circuit->trees.begin(); tsi != race.circuit->trees.end(); ++tsi) glVertex3f((*tsi).pos[0], (*tsi).pos[1], (*tsi).pos[2]); glEnd(); // draw players Race::PlayersIterator pi; int st = clock(); /* updte the state of the players as received by the server */ for (pi = cli.players.begin(); pi != cli.players.end(); ++pi) { glPushMatrix(); /* apply transformation coded in the frame */ Frame f = ((*pi).car.frame); glMultMatrixf(&f[0][0]); glPushMatrix(); glColor3f(1.0, 1.0, 1.0); glRotatef(90, 0, 1, 0); glutSolidTeapot(3.0); // draw the teapot (300 meters in size! ) glColor3f(0, 1, 0); glBegin(GL_LINES); glVertex3f(0.0, 1.0, 1.0); glVertex3f(0.0, 1.0, -1.0); glEnd(); glColor3f(0, 0, 1); glTranslatef(0.0, 0.0, (*pi).car.front_wheel_pos); glRotatef((*pi).car.steering_angle * 180.0 / M_PI, 0, 1, 0); glBegin(GL_LINES); glVertex3f(0.0, 1.0, 0.4); glVertex3f(0.0, 1.0, -0.4); glEnd(); glPopMatrix(); glColor3f(1.0, 0.0, 0.0); gl_print(100.0, 100.0, ((*pi).ip_address.toString()).toAscii().data()); // write the IP address of the client glPopMatrix(); } glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); /* print the commands */ glColor3f(1.0, 1.0, 0.0); gl_print(-1, 0.8, "accel: w"); gl_print(-1, 0.7, "slow: s"); gl_print(-1, 0.6, "left: a"); gl_print(-1, 0.5, "right: d"); gl_print(-1, 0.4, "brake: x"); gl_print(-1, 0.3, "reset: p"); if (sendSS) { cli.SendScreenshot(); sendSS = false; } cli.DrawScreenshots(std::string()); SDL_GL_SwapBuffers(); cn++; if (clock() - part > 1000) { printf("VIEW fps %d\n", cn); part = clock(); cn = 0; } }
int main(){ int i,count=0; cairo_surface_t *cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, W,H); int s=(W+SPACING-1)/SPACING+1; float *data = calloc((W+SPACING-1)/SPACING,sizeof(*data)); for(i=0;i<s;i++) data[i] = -sin((i-.35)/s*2*M_PI)*.9; clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_samples(cs,data,0); write_frame(cs,"quant",count++); /* fade in lines */ for(i=0;i<FRAMES;i++){ clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_targets(cs,data,(float)i/FRAMES); draw_samples(cs,data,0); write_frame(cs,"quant",count++); } /* fade in arrows */ for(i=0;i<FRAMES;i++){ clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_targets(cs,data,1); draw_samples(cs,data,0); draw_arrows(cs,data,0,(float)i/FRAMES); write_frame(cs,"quant",count++); } /* move */ for(i=0;i<FRAMES;i++){ clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_targets(cs,data,1); draw_samples(cs,data,(float)i/FRAMES); draw_arrows(cs,data,(float)i/FRAMES,1); write_frame(cs,"quant",count++); } /* fade out all */ for(i=0;i<FRAMES;i++){ clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_targets(cs,data,1.-(float)i/FRAMES); draw_samples(cs,data,1); draw_arrows(cs,data,1,1-(float)i/FRAMES); write_frame(cs,"quant",count++); } clear_surface(cs); draw_quant(cs); draw_axis(cs,0); draw_samples(cs,data,1); write_frame(cs,"quant",count++); cairo_surface_destroy(cs); return 0; }
ENTRYPOINT void draw_planet (ModeInfo * mi) { planetstruct *gp = &planets[MI_SCREEN(mi)]; int wire = MI_IS_WIREFRAME(mi); Display *dpy = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); double x, y, z; if (!gp->glx_context) return; glDrawBuffer(GL_BACK); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glXMakeCurrent (dpy, window, *(gp->glx_context)); mi->polygon_count = 0; if (! gp->button_down_p) switch (gp->state) { case STARTUP: gp->ratio += speed * 0.01; break; case FLAT: gp->ratio += speed * 0.005; break; case FOLD: gp->ratio += speed * 0.01; break; case ICO: gp->ratio += speed * 0.01; break; case STEL_IN: gp->ratio += speed * 0.05; break; case STEL: gp->ratio += speed * 0.01; break; case STEL_OUT: gp->ratio += speed * 0.07; break; case ICO2: gp->ratio += speed * 0.07; break; case AXIS: gp->ratio += speed * 0.02; break; case SPIN: gp->ratio += speed * 0.005; break; case UNFOLD: gp->ratio += speed * 0.01; break; default: abort(); } if (gp->ratio > 1.0) { gp->ratio = 0; switch (gp->state) { case STARTUP: gp->state = FLAT; break; case FLAT: gp->state = FOLD; break; case FOLD: gp->state = ICO; break; case ICO: gp->state = STEL_IN; break; case STEL_IN: gp->state = STEL; break; case STEL: { int i = (random() << 9) % 7; gp->state = (i < 3 ? STEL_OUT : i < 6 ? SPIN : AXIS); } break; case AXIS: gp->state = STEL_OUT; break; case SPIN: gp->state = STEL_OUT; break; case STEL_OUT: gp->state = ICO2; break; case ICO2: gp->state = UNFOLD; break; case UNFOLD: gp->state = FLAT; break; default: abort(); } } glEnable(GL_LINE_SMOOTH); glEnable(GL_POINT_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glPushMatrix(); gltrackball_rotate (gp->trackball); glRotatef (current_device_rotation(), 0, 0, 1); if (gp->state != STARTUP) { get_position (gp->rot, &x, &y, &z, !gp->button_down_p); x = (x - 0.5) * 3; y = (y - 0.5) * 3; z = 0; glTranslatef(x, y, z); } if (do_roll && gp->state != STARTUP) { get_rotation (gp->rot, &x, &y, 0, !gp->button_down_p); glRotatef (x * 360, 1.0, 0.0, 0.0); glRotatef (y * 360, 0.0, 1.0, 0.0); } if (do_stars) { glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glPushMatrix(); glScalef (60, 60, 60); glRotatef (90, 1, 0, 0); glRotatef (35, 1, 0, 0); glCallList (gp->starlist); mi->polygon_count += gp->starcount; glPopMatrix(); glClear(GL_DEPTH_BUFFER_BIT); } if (! wire) glEnable (GL_LIGHTING); if (do_texture) glEnable(GL_TEXTURE_2D); glScalef (2.6, 2.6, 2.6); { GLfloat fold_ratio = 0; GLfloat stel_ratio = 0; switch (gp->state) { case FOLD: fold_ratio = gp->ratio; break; case UNFOLD: fold_ratio = 1 - gp->ratio; break; case ICO: case ICO2: fold_ratio = 1; break; case STEL: case AXIS: case SPIN: fold_ratio = 1; stel_ratio = 1; break; case STEL_IN: fold_ratio = 1; stel_ratio = gp->ratio; break; case STEL_OUT: fold_ratio = 1; stel_ratio = 1 - gp->ratio; break; case STARTUP: /* Tilt in from flat */ glRotatef (-90 * ease_ratio (1 - gp->ratio), 1, 0, 0); break; default: break; } # ifdef HAVE_MOBILE /* Enlarge the icosahedron a bit to make it more visible */ { GLfloat s = 1 + 1.3 * ease_ratio (fold_ratio); glScalef (s, s, s); } # endif if (gp->state == SPIN) { align_axis (mi, 0); glRotatef (ease_ratio (gp->ratio) * 360 * 3, 0, 0, 1); align_axis (mi, 1); } draw_triangles (mi, ease_ratio (fold_ratio), ease_ratio (stel_ratio)); if (gp->state == AXIS) draw_axis(mi); } glPopMatrix(); if (mi->fps_p) do_fps (mi); glFinish(); glXSwapBuffers(dpy, window); }
int main(int argc, char *argv[]) { int quit = 0; //Initialize if( init() == 0 ) { return 1; } SDL_Surface *screen; SDL_Event event; //The event structure int cantidad = 0; // cantidad de vectores int vectores[1000][2]; //arreglo de vectores glBegin(GL_LINES); draw_axis(); glEnd(); //escucha de eventos //While the user hasn't quit while( quit == 0 ) { //If there's events to handle if( SDL_PollEvent( &event ) ) { //reset the viewport // glViewport(0, 0, 600, 800); //The mouse offsets int x = 0, y = 0; //If the mouse moved if( event.type == SDL_MOUSEMOTION ) { //Get the mouse offsets x = event.motion.x; y = event.motion.y; draw_line(x, y, cantidad, vectores); } if (event.type == SDL_MOUSEBUTTONDOWN) { if( event.button.button == SDL_BUTTON_LEFT ) { vectores[cantidad][0] = event.button.x; vectores[cantidad][1] = event.button.y; cantidad++; } } SDL_GL_SwapBuffers(); //If the user has Xed out the window if( event.type == SDL_QUIT ) { //Quit the program quit = 1; } } } SDL_Quit(); return 0; }