示例#1
0
void display(void)
{
  
   if(draw_grid) {
      glColor3f(0,0,0);
      glLineWidth(1);
      draw_grid2d(Vec2f(0,0), sim.dx, sim.ni, sim.nj);  
   }

   if(draw_boundaries) {
      glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
      draw_circle2d(c0, rad0, 50); 
      draw_circle2d(c1, rad1, 50); 
      draw_circle2d(c2, rad2, 50); 
      draw_circle2d(c3, rad3, 50); 
      
      //There's a bug, so draw one more(?)
      draw_circle2d(c3, 0, 10);
   }

   if(draw_particles) {
      glColor3f(0,0,0);
      glPointSize(3);
      draw_points2d(sim.particles);
   }

   if(draw_velocities) {
      for(int j = 0;j < sim.nj; ++j) for(int i = 0; i < sim.ni; ++i) {
         Vec2f pos((i+0.5f)*sim.dx,(j+0.5f)*sim.dx);
         draw_arrow2d(pos, pos + 0.01f*sim.get_velocity(pos), 0.1f*sim.dx);
      }
   }

}
示例#2
0
void display(void)
{
  
   if(draw_grid) {
      glColor3f(0,0,0);
      glLineWidth(1);
      draw_grid2d(Vec2f(0,0), sim.dx, sim.ni, sim.nj);  
   }

   if(draw_boundaries) {
      glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
      draw_circle2d(c0, rad0, 50); 
      
      //There's a bug, so draw one more(?)
      draw_circle2d(c3, 0, 10);
   }

   if(draw_particles) {
      glColor3f(0,0,1);
      glPointSize(3);
      glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
      draw_points2d(sim.particles);
      for(unsigned int p = 0; p < sim.particles.size(); ++p) {
         draw_circle2d(sim.particles[p], sim.particle_radius, 20);
      }
   }

   if(draw_velocities) {
      glColor3f(1,0,0);
      for(int j = 0;j < sim.nj; ++j) for(int i = 0; i < sim.ni; ++i) {
         Vec2f pos((i+0.5)*sim.dx,(j+0.5)*sim.dx);
         draw_arrow2d(pos, pos + 0.01f*sim.get_velocity(pos), 0.01*sim.dx);
      }
   }


}