我试着在我的线框图中把所有的隐藏线(或线的一部分)画成虚线(也就是点线)。经过一些研究,这是有意义的,这应该是可以通过几个渲染过程来实现的。
这是我到目前为止所掌握的。
// -- preamble stuff --
gl.glClearColor(1.f, 1.f, 1.f, 1.f);
gl.glShadeModel(GL.GL_SMOOTH);
gl.glDepthFunc(GL.GL_LEQUAL);
gl.glLineWidth(2);
gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// -- render hidden lines with stipple set, color mask enabled, depth buffer disabled --
gl.glDisable(GL_DEPTH_TEST);
gl.glColorMask(true, true, true, true);
gl.glLineStipple(1, (short) 0x00FF);
gl.glEnable(GL_LINE_STIPPLE);
gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
renderGLDisplayLists(); // -- does the rendering
// -- render in fill mode with color mask disabled, depth buffer enabled --
gl.glEnable(GL_DEPTH_TEST);
gl.glColorMask(false, false, false, false);
gl.glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
renderGLDisplayLists();
// -- final pass to render visible lines --
gl.glColorMask(true, true, true, true);
gl.glEnable(GL_LINE);
gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
renderGLDisplayLists();我已经附加了在我正在处理的特定案例上运行此代码时会发生的情况。
发布于 2014-09-09 21:45:36
应在启用深度缓冲区但反转且为只读的情况下最后绘制点划线
//just drew the fills
gl.glDepthMask(false);
lg.glDepthFunc(gl.GL_GREATER);//reverses the depth buffer
//render
gl.glColorMask(true, true, true, true);
gl.glLineStipple(1, (short) 0x00FF);
gl.glEnable(GL_LINE_STIPPLE);
gl.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
renderGLDisplayLists(); // -- does the rendering
gl.glDepthMask(true);
lg.glDepthFunc(gl.GL_LESS);//restores the depth bufferhttps://stackoverflow.com/questions/25746110
复制相似问题