Note that there are some explanatory texts on larger screens.

plurals
  1. POthis glut sphere won't spin, why? using Visual c++ 2010
    text
    copied!<p>This is the complete code I am using. The sphere does not spin like I would expect it to. Normally I program in Java so maybe it is my c++ programming and not GLUT. </p> <pre><code>#include "stdafx.h" #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;GL/glut.h&gt; #include &lt;GL/glu.h&gt; #include &lt;GL/gl.h&gt; #include &lt;iostream&gt; using namespace std; static float angle = 0; void init(void) { GLfloat mat_specular[] = { 1.0, .5f, .5f, .5f }; GLfloat mat_shininess[] = { 15.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); } void display(void) { cout &lt;&lt; angle; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(90, 1, 0, 0); glRotatef(angle, 0, 0, 1); glutSolidSphere (.5, 24, 24); glPopMatrix(); glFlush (); angle += 1; glutSwapBuffers(); } void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity(); glOrtho (-1.5*(GLfloat)w/(GLfloat)h, 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } int main(int argc, char** argv) { glutInit(&amp;argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; } </code></pre> <p>It seems from my debug line 'cout &lt;&lt; angle;' that glut is only calling the display function once. I am using Microsoft Visual C++ 2010 with GLUT</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload