# Depth Testing

**URL:** <https://discourse.glfw.org/t/depth-testing/199>\
**Category:** support\
**Created:** [June 1, 2015, 4:37am UTC](https://discourse.glfw.org/t/depth-testing/199 "2015-06-01T04:37:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 1, 2015, 4:37am UTC](https://discourse.glfw.org/t/depth-testing/199/1 "2015-06-01T04:37:58Z")

</div>

**[coded4coding](https://sourceforge.net/u/coded4coding/)** wrote on [Monday, June 01, 2015](https://sourceforge.net/p/glfw/discussion/247562/thread/cc106f52/#9dbd):

Hi Everyone…  
Do you guys know how to enable depth testing in glfw? 🙂  
Thank you

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 1, 2015, 5:21am UTC](https://discourse.glfw.org/t/depth-testing/199/2 "2015-06-01T05:21:00Z")

</div>

**[bastiaanolij](https://sourceforge.net/u/bastiaanolij/)** wrote on [Monday, June 01, 2015](https://sourceforge.net/p/glfw/discussion/247562/thread/cc106f52/#1f7f):

Hi Ankit,

If I’m not mistaken the depth buffer itself is created by default unless you specify otherwise. After that it just a matter of enabling it in the standard way:

glEnable(GL\_DEPTH\_TEST);

Make sure to clear the depth buffer at the start of your render loop:  
glClear(GL\_COLOR\_BUFFER\_BIT|GL\_DEPTH\_BUFFER\_BIT);

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [June 1, 2015, 5:24am UTC](https://discourse.glfw.org/t/depth-testing/199/3 "2015-06-01T05:24:46Z")

</div>

**[coded4coding](https://sourceforge.net/u/coded4coding/)** wrote on [Monday, June 01, 2015](https://sourceforge.net/p/glfw/discussion/247562/thread/cc106f52/#1f7f/f812):

Thank you Bastiaan! 🙂

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [November 16, 2026, 4:13pm UTC](https://discourse.glfw.org/t/depth-testing/199/4 "2026-11-16T16:13:49Z")

</div>

Closed on November 16, 2026, 4:13pm UTC


