Scale speed problem

Hi:

I have a matrix of gluSphere and it draws ok. When I select some sphere of one color I want it to dessapair and that works ok too.

Now I’m trying to scale it down from 1.0 to 0.0 to make an effect of dissapear of every sphere selected so I put an glScalef(factor,factor,factor) and every time that glutDisplayFunc is called I reduce in a 0.01 the factor.

The problem: If I select a lot spheres the scale mades a lot of faster than if I select a few spheres. Anyone knows Why? or how to solve it?

thanks

Each sphere should have it’s own factor.

i can’t image why it’s faster when you select more.
you can try these,
glScalef(f,f,f) where you drawing selected sphere,
glScalef(1,1,1) where you drawing un-selected sphere ,
can this be fastest? i do’t think so.

Mmmm no, I still have the same problem… When I select 2 or 3 spheres it goes smoothly but if I select 10 or 12 it goes too fast…

Maybe I should do something to do all the frames drawed at the same speed? something like measure the time to draw and then add an sleep to keep the sync?

The draw function is the next… Its a little bit complex because it needs a lot of things of the rest of the code… but mainly it draws a grid of 10x10 spheres

    
void dibujatablero(void)
{
  double j=0,i=0;
  int q=0,q2=0;
  int minimo,maximo;
  
  glColor3f(0.09,0.71,0.90);
  minimo=pantalla.Minimo();
  maximo=pantalla.Maximo();

  if (pantalla.Ancho()==maximo)
    glViewport(0,100,minimo-100,minimo-100);
  else
    glViewport(0,100+(maximo-minimo),minimo-100,minimo-100);
  
  pantalla.Bordes(-1,-1,1,1);

  j=+0.9;
  q2=0;
  while(q2<matriz.Tam())
    {
      q2+=1;
      q=0;
      i=-0.9;
      while (q<matriz.Tam())
	{
	  q+=1;
	  glPushMatrix();
	 
	  if (matriz[q2-1][q-1]!=0)
	    {
	      glTranslatef(i,j,0.0);
	      pantalla.Usatex(matriz[q2-1][q-1]-1);
	      gluQuadricDrawStyle( sphereObj, GLU_FILL );
	      gluQuadricTexture( sphereObj, GL_TRUE );
	      
	      if ((!vec.NoMiembro(q2-1,q-1))&&(bolas==1))
		{
		  glScalef(escalab,escalab,escalab);
		  escalab-=0.1;

		  if (escalab<=0)
		    {
		      procesatablero(q2-1,q-1,vec);
		      int lon=vec.size();
		      puntos+=(lon/2)*((lon/2)-1);
		      vec.clear();
		      vec2.clear();
		      escalab=1;
		      bolas=0;
		    }
		}
	      else
		{
		  glScalef(1,1,1);
		}

	      gluSphere(sphereObj,0.09,36,36);
	      
	    }
	  glPopMatrix();
	  i+=0.20;
	}
      j-=0.20;
    }


  dibujaseleccion();
   usleep(20000);
  glutPostRedisplay();
 
}

I’ll just repeat what I wrote in my previous post:

Each sphere should have it’s own factor.
Or at least move this line outside the loop:

escalab-=0.1;

Was That!!! Sorry for the loosing time… How Can I forget that? :smiley:

Thaks a lot for both :slight_smile: