| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 964 人关注过本帖
标题:关于一个在VC++6.0环境下无法使用OPENGL着色索引模式的问题?
只看楼主 加入收藏
renhao126
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2008-4-13
收藏
 问题点数:0 回复次数:1 
关于一个在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窗口
搜索更多相关主题的帖子: OPENGL 索引 环境 模式 
2008-10-22 21:12
renhao126
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2008-4-13
收藏
得分:0 
高手们帮个忙我现在没办法用索引模式头痛了
2008-10-23 23:11
快速回复:关于一个在VC++6.0环境下无法使用OPENGL着色索引模式的问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.070585 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved