GL_CULL_FACE使得所有对象消失 [英] GL_CULL_FACE makes all objects disappear

查看:201
本文介绍了GL_CULL_FACE使得所有对象消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建openGL3.3一些简单的多边形。我有2种类型的对象的,具有以下特性:

I am trying to create some simple polygons in openGL3.3. I have 2 types of objects with the following properties :

对象1 - 存储在 GL_ARRAY_BUFFER 10的顶点(以下,按顺序)和使用 GL_TRIANGLE_FAN

Object 1 - 10 vertices (listed below, in order) stored in GL_ARRAY_BUFFER and use GL_TRIANGLE_FAN

v x y z w  
v 0.0 0.0 1.0 1.0  
v 0.0 1.0 0.1 1.0  
v 0.71 0.71 0.1 1.0  
v 1.0 0.0 0.1 1.0  
v 0.71 -0.71 0.1 1.0  
v 0.0 -1.0 0.1 1.0  
v -0.71 -0.71 0.1 1.0  
v -1.0 0.0 0.1 1.0  
v -0.71 0.71 0.1 1.0  
v 0.0 1.0 0.1 1.0  

对象2 - 4个顶点(以下,按顺序)存储在 GL_ARRAY_BUFFER 和使用 GL_TRIANGLE_STRIP

v x y z w  
v 0.0 0.0 0.0 1.0  
v 0.0 1.0 0.0 1.0  
v 1.0 0.0 0.0 1.0  
v 1.0 1.0 0.0 1.0  

我加载64 Object1的4 Object2的公司。该Object2的的使用 GLM ::规模的比例(20,20,0)

当我尝试用 GL_CULL_FACE 使这些禁止,但 GL_DEPTH_TEST 启用glDepthFunc( GL_LESS)一切工作正常。当我尝试启用 GL_CULL_FACE 我得到的是一个空白窗口。

When I try to render these with GL_CULL_FACE disabled but GL_DEPTH_TEST enabled with glDepthFunc(GL_LESS) everything works fine. As soon as I try to enable GL_CULL_FACE all I get is a blank window.

一些其他有用的信息:
- 渲染顺序= 4 Object2的的后跟64 Object1的
- 相机 - GLM ::注视(GLM :: VEC3(0.0,0.0,50.0f),GLM :: VEC3(0.0,0.0,0.0),GLM :: VEC3(0.0楼1.0F,0.0));
- 视角 - GLM ::视角(45.0f,16.0f / 9.0f,0.01F,1000.0f);

Some other useful information :
- Rendering order = 4 Object2's followed by 64 Object1's
- Camera - glm::lookAt(glm::vec3(0.0f, 0.0f, 50.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
- Perspective - glm::perspective(45.0f, 16.0f / 9.0f, 0.01f, 1000.0f);

我一直在试图找出为什么 GL_CULL_FACE 在过去几天不工作,但也没办法。任何帮助是非常AP preciated。

I have been trying to figure out why GL_CULL_FACE doesn't work for the past couple of days but have no idea. Any help is much appreciated.

推荐答案

这是几乎总是由于多边形法线方向(每个三角形的三个顶点的右手规则)

This is almost always due to polygon normal direction (right-hand rule of the three vertices of each triangle)

尝试使用切换方向:

glCullFace(GL_BACK或GL_FRONT)

glCullFace(GL_BACK or GL_FRONT)

有些多读<一href="http://content.gpwiki.org/index.php/OpenGL%3aTutorials%3aTutorial_Framework%3aAdding_Depth_and_Color"相对=nofollow>这里

这篇关于GL_CULL_FACE使得所有对象消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆