Techniques for drawing coplanar polygons in OpenGL

梦想的初衷 提交于 2020-01-06 07:13:44

问题


I'm going to have meshes with several coplanar polygons, all lying in a certain plane, that I'm not going to be able to eliminate.

These polygons have a specific draw order. Some polygons are behind other polygons. If I turn off depth testing I'll have the effect I want, but I want to be able to position this mesh in a 3D scene.

I do not trust glPolygonOffset because I'll potentially have several of these overlapping polygons and am am worried about the cumulative effects of the offset.


回答1:


If I turn off depth testing I'll have the effect I want, but I want to be able to position this mesh in a 3D scene.

Simply disable writing to z-buffer, without disabling depth test.

glDepthMask(GL_FALSE);

Make sure to render all polygons that doesn't require glDepthMask(GL_FALSE) before rendering any polygons with glDepthMask(GL_FALSE); Otherwise object will be incorrectly positioned.

If you can't do that, then you should change your geometry or use texture instead.

glDepthMask documentation



来源:https://stackoverflow.com/questions/3432934/techniques-for-drawing-coplanar-polygons-in-opengl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!