关于一个在VC++6.0环境下无法使用OPENGL着色索引模式的问题?
#include <windows.h>#include <GL/glew.h>
#include <GL/glut.h>
#define NUMCOLORS 32
#define RAMPSTART 16
static void init(void)
{
int i;
glEnable(GL_DEPTH_TEST);
for(i=0;i<NUMCOLORS;i++)
{
GLfloat shade;
shade=(GLfloat)(NUMCOLORS-i)/(GLfloat)NUMCOLORS;
glutSetColor(RAMPSTART+i,shade,shade,shade);
}
glEnable(GL_FOG);
glFogi(GL_FOG_MODE,GL_LINEAR);
glFogi(GL_FOG_INDEX,NUMCOLORS);
glFogf(GL_FOG_END,6.0);
glHint(GL_FOG_HINT,GL_NICEST);
glClearIndex((GLfloat)(NUMCOLORS+RAMPSTART-1));
}
static void renderSphere(GLfloat x,GLfloat y,GLfloat z)
{
glPushMatrix();
glTranslatef(x,y,z);
glutSolidSphere(0.4,16,16);
glPopMatrix();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glIndexi((GLfloat)RAMPSTART);
renderSphere(-2.0,-0.5,-1.0);
renderSphere(-1.0,-0.5,-2.0);
renderSphere(0.0,-0.5,-3.0);
renderSphere(1.0,-0.5,-4.0);
renderSphere(2.0,-0.5,-5.0);
glFlush();
}
void reshape(int w,int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-2.5,2.5,-2.5*(GLfloat)h/(GLfloat)w,
2.5*(GLfloat)h/(GLfloat)w,-10.0,10.0);
else
glOrtho(-2.5*(GLfloat)w/(GLfloat)h,2.5*(GLfloat)w/(GLfloat)h,
-2.5,2.5,-10.0,10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void keyboard(unsigned char key,int x,int y)
{
switch(key)
{
case 27:
exit(0);
}
}
int main(int argc ,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_INDEX|GLUT_DEPTH);
glutInitWindowSize(500,500);
glutCreateWindow(argv[0]);
init();
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
请群里会OPENGL的帮个忙不知道怎么搞的我这个简单的程序无法运行只要把
glutInitDisplayMode中的GLUT_INDEX索引改成RGBA模式就能运行了,帮个忙
出的错误是在运行我的环境是环境是VC++6.0 系统XP
运行后出现GLUT\\pixel format with necessary capabilities not found.
问题注意该程序是可编译的但不出OPENGL窗口