Results 1 to 6 of 6

Thread: Scale speed problem

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2006
    Location
    Canary Island (Spain)
    Posts
    8

    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

  2. #2
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: Scale speed problem

    Each sphere should have it's own factor.

  3. #3
    Junior Member Newbie
    Join Date
    May 2004
    Location
    china
    Posts
    9

    Re: Scale speed problem

    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.

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2006
    Location
    Canary Island (Spain)
    Posts
    8

    Re: Scale speed problem

    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

    Code :
    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))&amp;&amp;(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();
     
    }

  5. #5
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: Scale speed problem

    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:
    Code :
    escalab-=0.1;

  6. #6
    Junior Member Newbie
    Join Date
    Sep 2006
    Location
    Canary Island (Spain)
    Posts
    8

    Re: Scale speed problem

    Was That!!! Sorry for the loosing time... How Can I forget that?

    Thaks a lot for both

Similar Threads

  1. Image pattern hatch - scale problem ?
    By AllForum in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-24-2014, 03:12 AM
  2. Scale a VBO with glMapBuffer glUnmapBuffer problem
    By initsoga in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-15-2013, 05:26 PM
  3. scale problem
    By wizzo in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-10-2003, 08:56 AM
  4. Problem about rotate and scale objects
    By peng in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 06-20-2002, 04:37 AM
  5. Having some problem with negative scale values and normals
    By Super-K in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-09-2002, 02:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean