# \[SOLVED\] Rendering problem when two faces are close to each other

**URL:** <https://discourse.libcinder.org/t/solved-rendering-problem-when-two-faces-are-close-to-each-other/879>\
**Category:** Using Cinder\
**Created:** [September 28, 2017, 9:30am UTC](https://discourse.libcinder.org/t/solved-rendering-problem-when-two-faces-are-close-to-each-other/879 "2017-09-28T09:30:40Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [July 25, 2018, 11:10pm UTC](https://discourse.libcinder.org/t/solved-rendering-problem-when-two-faces-are-close-to-each-other/879/10 "2018-07-25T23:10:19Z")

</div>

Hi Matt,

my last post contained a lot of possible solutions that I never tried myself. So it inspired me to look at them in more detail. As it turned out, this required quite a substantial update to Cinder to make it support the latest OpenGL version (4.6), required for the `glClipControl` command.

I had to replace the current OpenGL loader (a.k.a. _glLoad_) with a new loader called [GLAD](https://github.com/Dav1dde/glad). You can find this change in [my fork](https://github.com/paulhoux/Cinder/tree/glad) of Cinder. There is currently a discussion among the Cinder devs about whether GLAD is the best choice, so keep in mind that my work on this does not mean it will be adopted in the official Cinder release.

On top of all this, I wrote additional functions to easily enable Reversed Z rendering. You can find this in my `reverse-z` branch. Check out the [FightingPixelFighting](https://github.com/paulhoux/Cinder/tree/reverse-z/samples/FightingPixelFighting) sample.

I added a `gl::enableDepthReversed( bool enable = true )` method that you call once at the beginning of your application. It will setup Cinder to clear the depth buffer with _zero_ instead of _one_, set the depth comparison to `GL_GREATER` instead of `GL_LESS`, set the clip range to `GL_ZERO_TO_ONE` instead of `GL_NEGATIVE_ONE_TO_ONE` and adjust the _projection matrix_ accordingly. Of course, there is also a `gl::isDepthReversedEnabled()` method.

The `CameraPersp` class now also [supports](https://github.com/paulhoux/Cinder/blob/b39c019ad5f5defe5bab74caa2811caa733afdba/include/cinder/Camera.h#L99-L113) _infinite far clip distance_, as well as zero-to-one clip mode and reverse depth.

Caveat: _due to the fact that OS X hasn’t kept up with the times, this code will only work on Microsoft Windows and (in the near future) on Linux platforms. OpenGL ES is out of the question, too, so bad luck for iOS, ANGLE and Android._

-Paul

---

_[View the full topic](https://discourse.libcinder.org/t/solved-rendering-problem-when-two-faces-are-close-to-each-other/879)._
