问题描述
我想在不使用GLUT的情况下以与平台无关的方式使用深度缓冲区初始化OpenGL.
I would like to initialize OpenGL with a depth-buffer in a platform independent manner without using GLUT.
如何使用c#包装器在OpenGL场景中移除隐藏表面.我没有使用GLUT,所以不能使用glutInitDisplayMode.有什么主意吗?
How to remove hidden-surface in OpenGL scene using c# wrapper.I'm not using GLUT so I can't use glutInitDisplayMode.any idea?
有关更多详细信息:
我发现了以下有关隐藏表面去除的步骤:
I found these steps about Hidden-Surface removal:
-
通过glutInitDisplayMode请求z缓冲区:
Request for z-buffer via glutInitDisplayMode:
// GLUT_DEPTH to request for depth-buffer
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
启用z缓冲区进行深度测试:
Enable z-buffer for depth testing:
glEnable(GL_DEPTH_TEST);
清除颜色缓冲区时清除z缓冲区:
Clear the z-buffer when we clear the color buffer:
// Clear color and depth buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
据我所知,glutInitDisplayMode是GLUT函数之一.我可以消除此呼叫而不会产生不良影响.如果没有,那么可以实现此目的的替代纯opengl调用是什么.
as I know, glutInitDisplayMode is one of GLUT functions.can i eliminate this call without bad effect.if not, what is the alternative pure opengl calls that do the trick.
我正在使用(科林·P·法赫伊)写的ac#包装器
I'm using a c# wrapper written by (Colin P. Fahey)
推荐答案
GLUT不是OpenGL!
无论GLUT做什么,您的C#包装器也可能会提供它,并且可能会更好.您需要一个深度缓冲区,并启用深度测试.
Whatever GLUT does, your C# wrapper probably offers it as well, and probably better. What you need are a depth buffer and enabling depth testing.
要获得深度缓冲区的确切步骤完全取决于您使用的包装器.因此,必须告诉我们它是哪个包装器.
The exact steps to be taken to get a depth buffer depend entirely on the wrapper you use. So it's essential to tell us, which wrapper it is.
这篇关于使用深度缓冲区和深度测试初始化OpenGL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!