PDA

View Full Version : Determine whether system support GLUT_INDEX?



Jichao
05-20-2010, 10:13 PM
I created a program using GLUT APIs under Windows XP.
#include <GL\glut.h>
#include <stdio.h>

void init(void)
{
glClearIndex(100);

glMatrixMode(GL_PROJECTION);
gluOrtho2D(0, 300, 0, 300);
}

void indexColor(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glIndexi(100);
glRecti(50, 50, 150, 150);
glFlush();
}

void main(int argc, char** argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_INDEX);
glutInitWindowPosition(100, 100);
glutInitWindowSize(300, 300);
glutCreateWindow("Index Color");

init();
glutDisplayFunc(indexColor);
glutMainLoop();
}

But it turns out an error message "pixel format with necessary capabilities not found".It seems that my system does not support GLUT_INDEX color mode.

My question is: how to determine whether a system support the GLUT_INDEX color mode? do linux system support GLUT_INDEX color mode?

thanks.
jichao.

mhagain
05-21-2010, 03:14 AM
Color index mode is very heavily deprecated these days. Any specific reason why you can't use RGBA?

Jichao
05-21-2010, 05:47 AM
The textbook from which I learn OpenGL mention it and the benefits of this mode.

Jan
05-21-2010, 08:26 AM
Erm, ditch that book immediately.

Index mode is not used by anyone anymore for about 15 years now. If that book suggests to use it, it is either extremely old, or the author is an idiot.

"Today" everything is rendered in RGBA mode.

Using a color-table does allow you to do some nice effects (color-table animations), but today no one does that anymore. And even if you wanted to have such behavior, there are much better ways these days (through shaders).

Jan.

Jichao
05-21-2010, 10:16 AM
Oh,thanks for the hint.

But the textbook I am using Computer Graphics with OpenGL,3rd (http://www.amazon.com/Computer-Graphics-OpenGL-Donald-Hearn/dp/0130153907) was first published at 2004.

Maybe I should consider the index mode section as history rather practice.

mhagain
05-21-2010, 12:53 PM
Color index mode is something that's required to be supported in order to pass conformance, but nobody uses it these days and you can bet that hardware acceleration in color indexed mode is going to be patchily supported at best. Unless you have something very very specific that you know for a fact that color index mode is the only solution for, and unless you don't care about performance, you really should use RGBA and forget what that book told you.

Jichao
05-21-2010, 07:47 PM
I have decided to forget it since I have made a test in my ubuntu and it does not support the index color mode either.

Paraddi
07-01-2010, 10:47 PM
You can determine whether GLUT_INDEX is supported or not based on the following piece of code, basically glutGet(GLUT_DISPLAY_MODE_POSSIBLE) indicates whether current display mode is supported or not.

glutInitDisplayMode (GLUT_SINGLE | GLUT_INDEX);
if (! glutGet(GLUT_DISPLAY_MODE_POSSIBLE))
glutInitDisplayMode(GLUT_RGB);