# Depth texture attachment

**URL:** <https://forums.imgtec.com/t/depth-texture-attachment/764>\
**Category:** PowerVR Insider\
**Created:** [July 18, 2010, 9:05am UTC](https://forums.imgtec.com/t/depth-texture-attachment/764 "2010-07-18T09:05:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![slion](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@slion](https://forums.imgtec.com/u/slion)\
**Post date:** [July 18, 2010, 9:05am UTC](https://forums.imgtec.com/t/depth-texture-attachment/764/1 "2010-07-18T09:05:16Z")

</div>

I’m trying to use a texture as frame buffer depth attachment.   
glTexImage2D gives me an invalid parameter error when using GL\_DEPTH\_COMPONENT as pixel format. Using GL\_UNSIGNED\_BYTE as pixel type. Then the frame buffer check fails. My frame buffer works fine when I’m not trying to use that depth texture as depth attachment.  
  
I’m on WinXP with NVidia GeForce GTS 250. OpenGL ES 2.0 ( SDK build: 2.06.26.0641 )  
Extensions string contains **GL\_OES\_depth\_texture**   
  
What’s the trick to use texture as depth attachment?

---

<div class="post-metadata">

**Author:** ![slion](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@slion](https://forums.imgtec.com/u/slion)\
**Post date:** [July 18, 2010, 9:17am UTC](https://forums.imgtec.com/t/depth-texture-attachment/764/2 "2010-07-18T09:17:57Z")

</div>

As I was writing the above question I suddenly remembered that I totally forgot to search the SDK for some examples. Silly me! Turns out the shadow mapping training course does use a depth textures and it uses **GL\_UNSIGNED\_INT** as pixel types. So my mistake was to use GL\_UNSIGNED\_BYTE as pixel type.

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [July 19, 2010, 7:49am UTC](https://forums.imgtec.com/t/depth-texture-attachment/764/3 "2010-07-19T07:49:09Z")

</div>

I’m glad you managed to resolve the issue. It’s an easy mistake to make 🙂
