Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: for loop in display function not working properly

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    23

    for loop in display function not working properly

    The following function is called from the display function and the ReadCp function is updating the finalgrass vector.
    Actually the for loop is not running till the limit i.e. m<5 but it runs for three increments only regardless of the increment. Don't know why this is happening.

    If you have even 1 percent idea please please help.

    Code :
    void OuterSurface()
    {
    ReadCp(1);
    glColor3f(0.8,0.5,0.1);
    glBegin(GL_LINE_STRIP);
    for(double m=0;m<5;m=m+0.2)
    {
    double r=20;
    for(double j=0;j<360; j=j+40)
    {
    for(int ii=0;ii<finalgrass.size();ii++)
    {
    MyPoint temp2=finalgrass[ii];
    if(m==temp2.x && (j>(temp2.t-0.01) && j<(temp2.t+0.01)))
    {
    r=temp2.r;
    }
    }
    glVertex3f(m,r*cos(j*PI/180),r*sin(j*PI/180));
    }
    }
    glEnd();
    }
    Code :
     
    Last edited by qawded; 07-08-2013 at 08:49 PM. Reason: formatting problem

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    23
    i am using vc++ 2010 with glut. Please help.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    7
    Whats with the ReadCp()?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    Why do you think the for loop is not working?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •