【问题标题】:linux openGL depth_test not workinglinux openGL depth_test不工作
【发布时间】:2015-07-19 11:59:36
【问题描述】:

我在网上试了很多方法,还是不行。 现在我考虑问题是否与我的操作系统(ubuntu)有关。

void init(void){
glClearColor(1.0, 1.0, 1.0, 0.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glClearDepth(1.0);
glDepthFunc(GL_LESS);
glFrontFace(GL_CCW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
init2();
}

void reshape(int w, int h){
int t = min (w,h);
glViewport (0, 0,  t, t);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-100.0, 100.0, -100.0, 100.0, 1.1, 200.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(40.0, 40.0, 100.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}

上面的两个函数来自我的代码..

【问题讨论】:

  • 在创建 gl window 时,你真的要求深度缓冲区吗?

标签: opengl depth-testing


【解决方案1】:

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) 必须在每一帧开始时调用以清除颜色缓冲区和深度缓冲区。

除此之外,您应该发布更多详细信息。你在看什么?您如何请求 OpenGL 上下文?你能发布整个绘制循环吗?

【讨论】:

    猜你喜欢
    • 2017-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多