小编acr*_*997的帖子

如何在OpenGL上使立方体面不透明?

我正在编写一个程序在OpenGL上绘制一个立方体,并在单击鼠标时不断旋转它。在特定角度下,我可以透视立方体(透明)。我启用了深度测试,所以我不知道为什么会这样。我不确定是否已正确启用它。

在此图像中,隐藏的面孔仍然可见

#include <math.h>
#include <vector>
#include <Windows.h>
#include <gl\glut.h>

using namespace std;


void myInit() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(0, 0, 0, 1);
    glOrtho(-2, 2, -2, 2, 2, -2);
    glMatrixMode(GL_MODELVIEW);
}

float Cube[][3] = { {-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}, {-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1} };
float Colors[][3] = { {0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 1, 0}, {0, 1, …
Run Code Online (Sandbox Code Playgroud)

c++ opengl glut depth-testing

4
推荐指数
1
解决办法
61
查看次数

标签 统计

c++ ×1

depth-testing ×1

glut ×1

opengl ×1