-2

Please attention on my code.......

#include<windows.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>

static GLfloat spin = 0.0;  // Does it use as global variable??


void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();

    glColor3f(1.0, 1.0, 1.0);


    glRectf(-25.0, -4.0, 25.0, 4.0);
    glRectf(-4.0, -25.0, 4.0, 25.0);
    glColor3f(0.0, 0.0, 1.0);
    glutSolidTorus(1.00, 6.4, 10, 100);
    glPopMatrix();

    glFlush();
}


void spinDisplay_right1(void)
{
   spin = -.60;
            glutPostRedisplay();
            glRotatef(spin, 0.0, 0.0, 1.0);
}

Note: I think static variable is used as global variable. If I use static variable under any function then it will be local variable

Am I right or not ? Please response my questions.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Imdadul Haque
  • 1,635
  • 5
  • 23
  • 44
  • https://stackoverflow.com/questions/572547/what-does-static-mean-in-c explains file scoped and function scoped static variables. In this case there's no reason for that variable to be static that I know of. It's just a global. – Retired Ninja Aug 29 '20 at 04:58

1 Answers1

2

In your case static GLfloat spin = 0.0; is a global variable that will be "seen" only in the file it is declared in.

If you declare a static variable inside a function then it will be a local variable but it will keep its value between function invocations.