# how to create GL\_DEPTH24\_STENCIL8\_OES tex ?

**URL:** <https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308>\
**Category:** PowerVR Insider\
**Created:** [February 14, 2012, 5:42am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308 "2012-02-14T05:42:35Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)\
**Post date:** [February 14, 2012, 5:42am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/1 "2012-02-14T05:42:35Z")

</div>

Hi,  
  
  
  
  
  
I am trying to create a depth24\_stencil8 texture for my framebuffer. I need it to be a texture and not render buffer.  
  
  
here is the code for it  
  
  
  
  
  
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  
  
glGenFramebuffers(1, &preLightFBO);  
  
  
glBindFramebuffer(GL\_FRAMEBUFFER, preLightFBO);  
  
  
  
  
  
  
  
  
glGenTextures(1, &preLight\_depthTex);  
  
  
glBindTexture(GL\_TEXTURE\_2D, preLight\_depthTex);  
  
  
  
  
  
glTexImage2D(GL\_TEXTURE\_2D, 0, GL\_DEPTH24\_STENCIL8\_OES, prePassBuffersWidth, prePassBuffersHeight, 0, GL\_DEPTH\_STENCIL\_OES, GL\_UNSIGNED\_INT\_24\_8\_OES, 0);  
  
  
glTexParameteri(GL\_TEXTURE\_2D, GL\_TEXTURE\_WRAP\_S, GL\_CLAMP\_TO\_EDGE);  
  
  
glTexParameteri(GL\_TEXTURE\_2D, GL\_TEXTURE\_WRAP\_T, GL\_CLAMP\_TO\_EDGE);  
  
  
glTexParameteri(GL\_TEXTURE\_2D, GL\_TEXTURE\_MIN\_FILTER, GL\_NEAREST);  
  
  
glTexParameteri(GL\_TEXTURE\_2D, GL\_TEXTURE\_MAG\_FILTER, GL\_NEAREST);  
  
  
  
  
  
glFramebufferTexture2D(GL\_FRAMEBUFFER, GL\_DEPTH\_ATTACHMENT, GL\_TEXTURE\_2D, preLight\_depthTex, 0);  
  
  
glFramebufferTexture2D(GL\_FRAMEBUFFER, GL\_STENCIL\_ATTACHMENT,GL\_TEXTURE\_2D, preLight\_depthTex, 0);  
  
  
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  
  
  
  
  
I am getting GL\_FRAMEBUFFER\_INCOMPLETE\_ATTACHMENT. I check with glError after glTexImage2D, I get GL\_INVALID\_OPERATION.  
  
  
  
  
  
Using these params  
  
  
glTexImage2D(GL\_TEXTURE\_2D, 0, GL\_DEPTH\_STENCIL\_OES, prePassBuffersWidth, prePassBuffersHeight, 0, GL\_DEPTH\_STENCIL\_OES , GL\_UNSIGNED\_INT\_24\_8\_OES, NULL)  
  
  
  
  
  
I get GL\_INVALID\_VALUE  
  
  
  
  
  
I am not doing anything different than whats here  
  
  
[http://www.khronos.org/registry/gles/extensions/OES/OES\_packed\_depth\_stencil.txt](http://www.khronos.org/registry/gles/extensions/OES/OES_packed_depth_stencil.txt)  
  
  
  
  
  
  
  
  
Can someone please help me understand why this will not work ?

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 14, 2012, 9:08am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/2 "2012-02-14T09:08:31Z")

</div>

Hi,  
  
  
  
  
  
Your call to glTexImage2D has GL\_DEPTH24\_STENCIL8\_OES as \<internalFormat\>. According to the spec, only GL\_DEPTH\_STENCIL\_OES is valid. GL\_DEPTH24\_STENCIL8\_OES is valid as \<internalFormat\> for glRenderbufferStorage.

---

<div class="post-metadata">

**Author:** ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)\
**Post date:** [February 14, 2012, 9:37am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/3 "2012-02-14T09:37:30Z")

</div>

Hi,  
  
  
  
  
  
Thanks for the reply !  
  
  
Doing  
  
  
glTexImage2D(GL\_TEXTURE\_2D, 0, GL\_DEPTH\_STENCIL\_OES, prePassBuffersWidth, prePassBuffersHeight, 0, GL\_DEPTH\_STENCIL\_OES, GL\_UNSIGNED\_INT\_24\_8\_OES, 0);  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
  
  
is giving me GL\_INVALID\_VALUE.  
  
  
  
  
  
What would cause this then ?

---

<div class="post-metadata">

**Author:** ![marco](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/marco/32/96_2.png) [@marco](https://forums.imgtec.com/u/marco)\
**Post date:** [February 14, 2012, 9:47am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/4 "2012-02-14T09:47:01Z")

</div>

Hi,  
  
do you need the stencil buffer at all?   
Have you checked that the OES\_packed\_depth\_stencil externsion is supported on your device?  
  
If you don’t need the stencil buffer, we’ve got an example in our SDK that boils down to:  
  
//Create the shadow map texture  
glGenTextures(1, &m\_uiShadowMapTexture);  
glBindTexture(GL\_TEXTURE\_2D, m\_uiShadowMapTexture);  
  
// Create the depth texture.  
glTexImage2D(GL\_TEXTURE\_2D, 0, GL\_DEPTH\_COMPONENT, m\_ui32ShadowMapSize, m\_ui32ShadowMapSize, 0, GL\_DEPTH\_COMPONENT, GL\_UNSIGNED\_INT, NULL);  
[…]  
glGenFramebuffers(1, &m\_uiFrameBufferObject);  
glBindFramebuffer(GL\_FRAMEBUFFER, m\_uiFrameBufferObject);  
glFramebufferTexture2D(GL\_FRAMEBUFFER, GL\_DEPTH\_ATTACHMENT, GL\_TEXTURE\_2D, m\_uiShadowMapTexture, 0);

---

<div class="post-metadata">

**Author:** ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)\
**Post date:** [February 14, 2012, 10:09am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/5 "2012-02-14T10:09:19Z")

</div>

Hi Marco,  
  
  
  
  
  
I have the depth component based FBO texture working and I do need the stencil bufffer for this case.  
  
  
My target device is iPhone and iPad which I am sure supports the stencil buffer.  
  
  
  
  
  
I am running the PVR SDK windows emulation. What I don’t understand is why  
  
  
 CPVRTgles2Ext::IsGLExtensionSupported(“GL\_OES\_packed\_depth\_stencil”) is returning false on my PC. My graphic card supports shader model 4.0 and even DX9 supports the packed depth stencil !!

---

<div class="post-metadata">

**Author:** ![marco](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/marco/32/96_2.png) [@marco](https://forums.imgtec.com/u/marco)\
**Post date:** [February 14, 2012, 10:27am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/6 "2012-02-14T10:27:54Z")

</div>

Hi mkandula,  
  
the emulation only exposes extensions that are actually available on PowerVR platforms.

---

<div class="post-metadata">

**Author:** ![peter-quayle](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@peter-quayle](https://forums.imgtec.com/u/peter-quayle)\
**Post date:** [February 14, 2012, 10:37am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/7 "2012-02-14T10:37:08Z")

</div>

mkandula, what version of the SDK are you using?

---

<div class="post-metadata">

**Author:** ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)\
**Post date:** [February 14, 2012, 11:34am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/8 "2012-02-14T11:34:39Z")

</div>

OGLES2\_WINDOWS\_X86EMULATION\_2.08.28.0634

---

<div class="post-metadata">

**Author:** ![marco](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/marco/32/96_2.png) [@marco](https://forums.imgtec.com/u/marco)\
**Post date:** [February 14, 2012, 11:52am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/9 "2012-02-14T11:52:16Z")

</div>

mkandula,  
Could you download and install the most recent SDK version (2.09.29.0649) and try again?  
It should be supported in that release.

---

<div class="post-metadata">

**Author:** ![peter-quayle](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@peter-quayle](https://forums.imgtec.com/u/peter-quayle)\
**Post date:** [February 14, 2012, 11:53am UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/10 "2012-02-14T11:53:23Z")

</div>

Edit : Whoops, Marco beat me to it.  
  
  
  
  
  
GL\_OES\_packed\_depth\_stencil was introduced in the 2.9 version of VFrame so you will need to upgrade to use that extension.peter.quayle2012-02-14 13:13:53

---

<div class="post-metadata">

**Author:** ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)\
**Post date:** [February 14, 2012, 12:54pm UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/11 "2012-02-14T12:54:56Z")

</div>

But can someone tell me if this feature is supported on iPad and iPhone4 atleast ?

---

<div class="post-metadata">

**Author:** ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)\
**Post date:** [February 14, 2012, 1:32pm UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/12 "2012-02-14T13:32:29Z")

</div>

A good way to check these things is to take a look at the GLBenchmark website.  
  
  
  
  
  
Here is the page to the iPhone4 GL environment: [http://www.glbenchmark.com/phonedetails.jsp?benchmark=glpro21&D=Apple+iPhone+4&testgroup=gl](http://www.glbenchmark.com/phonedetails.jsp?benchmark=glpro21&D=Apple+iPhone+4&testgroup=gl).  
  
  
  
  
  
In this case, the iPhone4 does indeed support GL\_OES\_packed\_depth\_stencil.  
  
  
  
  
  
You should be able to find all major consumer devices on that website.

---

<div class="post-metadata">

**Author:** ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)\
**Post date:** [February 14, 2012, 4:00pm UTC](https://forums.imgtec.com/t/how-to-create-gl-depth24-stencil8-oes-tex/1308/13 "2012-02-14T16:00:50Z")

</div>

Wohoo !! updating sorted this issue out !!  
  
  
You guys are the GODs of PVR !!  
  
  
  
  
  
Thank you very much !
