Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:37:43+00:00 2026-06-14T06:37:43+00:00

This is the complete code I am using. The sphere does not spin like

  • 0

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.

#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <iostream>
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 << 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(&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;
}

It seems from my debug line ‘cout << angle;’ that glut is only calling the display function once.
I am using Microsoft Visual C++ 2010 with GLUT

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:37:44+00:00Added an answer on June 14, 2026 at 6:37 am

    There are a few options:

    You can manually call glutPostRedisplay to ask the main loop to call your display function again, as documented here.

    Or, you can set it to automatically call your display as often as possible by setting it as the idle func with glutIdleFunc, as documented here.

    If you’re going with the Idle Func, I would definitely suggest you to create a function such as gameUpdate or simulationUpdate where you manipulate your angle and THEN call glutPostRedisplay so that the changes can be rendered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using this code to replace exact match. However this does not
Can someone please tell me whats wrong with this code. I'm not getting complete
I'm new to Biopython. Using this code: handle = Entrez.esearch(db=nuccore, term=complete, field=title, FILT=refseq, porgn=viruses,
This is the complete source code: http://www.sendspace.com/file/lwxpyf I have a problem with a JSF
I am trying to do this: List<Parent> test = new List<Child>(); The complete code
With regards this example from Code Complete: Comparison Compare(int value1, int value2) { if
I'm not sure if this is possible (complete non-flash developer speaking), but we have
I am complete newbie for programming and this is my first real program I
I am trying to build an openssl simple program. Here is the complete code:
For some reason this piece of Java code is giving me overlapping matches: Pattern

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.