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 2 of 2

Thread: Glut Problem: "Color Index Mode not supported"

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2011
    Posts
    1

    Glut Problem: "Color Index Mode not supported"

    I'm a beginner at using OpenGL even though I've had some experience in C++.

    I'm trying to draw shapes and manipulating them, and the code I was working with was running fine yesterday. However, today I boot up VS and every time I try to run my code the command prompt window says:

    "Color Index Mode not supported
    Press any key to continue..."

    And the window just closes. I have absolutely no idea why this started happening, because I didn't change a single line of code. I'm not sure what the problem is either. Is it something that I have set up wrong? Because code that I know for a fact was working yesterday has this problem today. Google searches don't turn up anything, as if nobody else has had this problem and I have no idea what to do. Can anyone help, and possibly explain why this error is coming up?

    Thanks in advance!

    EDIT: Please let me know if I'm posting in the wrong location, and I apologize if I'm not in the right place.

    Code :
    #include <stdlib.h>
    #include "glut.h"
    #include <math.h>
     
     
    const double TWO_PI = 6.2831853;
     
    GLsizei winWidth = 500, winHeight = 500; // Initial display window size
    GLuint regHex;
    static GLfloat rotTheta = 0.0;
     
    // stores a location
    class scrPt {
    public:
    	GLint x, y;
    };
     
    static void init (void)
    {
    	scrPt hexVertex;
    	GLdouble hexTheta;
    	GLint k;
     
    	glClearColor (1.0, 1.0, 1.0, 0.0);
     
    	/* Set up a display list for a red regular hexagon
    	 * Vertices for the hexagon are six equally spaced 
    	 * points around the circumference of a circle.
    	 */
     
    	regHex = glGenLists(1);
    	glNewList(regHex, GL_COMPILE);
    		glColor3f(1.0,0.0,0.0);
    		glBegin(GL_POLYGON);
    			for(k = 0; k < 6; k++){
    				hexTheta = TWO_PI * k / 6;
    				hexVertex.x = 150 + 100 * cos (hexTheta);
    				hexVertex.y = 150 + 100 * sin (hexTheta);
    				glVertex2i (hexVertex.x, hexVertex.y);
    			}
    		glEnd();
    	glEndList();
    }
     
    void displayHex (void)
    {
    	glClear (GL_COLOR_BUFFER_BIT);
     
    	glPushMatrix();
    	glRotatef(rotTheta, 0.0, 0.0, 1.0);
    	glCallList(regHex);
    	glPopMatrix();
     
    	glutSwapBuffers();
     
    	glFlush();
    }
     
    void rotateHex (void)
    {
    	rotTheta += 3.0;
    	if( rotTheta > 360.0)
    		rotTheta -= 360.0;
     
    	glutPostRedisplay();
    }
     
    void winReshapeFcn (GLint newWidth, GLint newHeight)
    {
    	glViewport (0,0, (GLsizei) newWidth, (GLsizei) newHeight);
     
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	gluOrtho2D(-320.0, 320.0, -320.0, 320.0);
     
    	glMatrixMode (GL_MODELVIEW);
    	glLoadIdentity();
     
    	glClear (GL_COLOR_BUFFER_BIT);
    }
     
    void mouseFcn(GLint button, GLint action, GLint x, GLint y)
    {
    	switch(button){
    	case GLUT_MIDDLE_BUTTON:	// start the rotation
    		if(action == GLUT_DOWN)
    			glutIdleFunc(rotateHex);
    		break;
    	case GLUT_RIGHT_BUTTON:		// stop the rotation
    		if(action == GLUT_DOWN)
    				glutIdleFunc(NULL);
    		break;
    	default:
    		break;
    	}
    }
     
    void main (int argc, char** argv)
    {
    	glutInit(&amp;argc, argv);
    	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    	glutInitWindowPosition(150,150);
    	glutInitWindowSize(winWidth, winHeight);
    	glutCreateWindow ("Animation Example");
     
    	init();
    	glutDisplayFunc (displayHex);
    	glutReshapeFunc (winReshapeFcn);
    	glutMouseFunc (mouseFcn);
     
    	glutMainLoop();
     
    }

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Glut Problem: "Color Index Mode not supported"

    what does glGetIntegerv() with GL_RED_BITS, GL_GREEN_BITS, GL_BLUE_BITS, GL_ALPHA_BITS, and GL_INDEX_BITS return?

    Your glutInitDisplayMode does not include GLUT_INDEX
    ...so if no code was changed how did it ever wotk in the first place ;-)

    My advise to you is to start including some logging to report back opengl state rather than assuming your context is exactly that which you asked for.

Posting Permissions

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