# glGetIntegerv and GL\_ACTIVE\_TEXTURE

**URL:** <https://forums.imgtec.com/t/glgetintegerv-and-gl-active-texture/524>\
**Category:** PowerVR Insider\
**Created:** [November 6, 2009, 10:11am UTC](https://forums.imgtec.com/t/glgetintegerv-and-gl-active-texture/524 "2009-11-06T10:11:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miraglia](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@miraglia](https://forums.imgtec.com/u/miraglia)\
**Post date:** [November 6, 2009, 10:11am UTC](https://forums.imgtec.com/t/glgetintegerv-and-gl-active-texture/524/1 "2009-11-06T10:11:21Z")

</div>

I am using OGLES-1.1\_WINDOWS\_PCEMULATION\_2.05.25.0804.  
I am developing on Visual Studio 2003 and using “OpenGLES common” version.  
  
I am using the following code lines to retrive the current texture unit in my own project:  
&nbsp;&nbsp; GLint activeTxtUnit;  
&nbsp;&nbsp; glGetIntegerv(GL\_ACTIVE\_TEXTURE, &activeTxtUnit);  
  
it seems that this function call corrupts the stack and it does not retrieve the correct value.  
  
I tryed the same code into the following training project  
PowerVR SDKOGLES-1.1\_WINDOWS\_PCEMULATION\_2.05.25.0804TrainingCourse10\_MultitextureOGLES (into the function OGLESMultitexture::EnableStates).  
The result is the same.  
  
Does anyone had the same problem or can help me?  
Is it a PowerVR SDK bug?

---

<div class="post-metadata">

**Author:** ![jacekc](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@jacekc](https://forums.imgtec.com/u/jacekc)\
**Post date:** [November 16, 2009, 9:21am UTC](https://forums.imgtec.com/t/glgetintegerv-and-gl-active-texture/524/2 "2009-11-16T09:21:07Z")

</div>

I'm sorry for a late reposne. Yes, this is a bug in pcemulation. Fix for it will be included in our next release. Thanks for reporting it to us.

---

<div class="post-metadata">

**Author:** ![jbuck](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jbuck](https://forums.imgtec.com/u/jbuck)\
**Post date:** [August 10, 2011, 6:20am UTC](https://forums.imgtec.com/t/glgetintegerv-and-gl-active-texture/524/3 "2011-08-10T06:20:31Z")

</div>

I am using 2.08.28.0634, and the two bugs named in the original posting (corrupt stack and incorrect value) appear to still be there. I get a “Run-Time Check Failure #2 - Stack around the variable ‘prevActiveTexUnit’ was corrupted.” when I exit a function that contains:  
  
  
  
  
  
GLint prevActiveTexUnit;  
  
  
glGetIntegerv(GL\_ACTIVE\_TEXTURE, &prevActiveTexUnit);  
  
  
glActiveTexture(GL\_TEXTURE0 + 1);  
  
  
// etc.  
  
  
glActiveTexture(GL\_TEXTURE0 + prevActiveTexUnit);  
  
  
  
  
  
This code was fine before adding the code for putting back the prevActiveTexUnit. Also, the value for prevActiveTexUnit seems to be 0-based instead of GL\_TEXTURE0-based. From my reading of the standard, it seems that it should be GL\_TEXTURE0-based.

---

<div class="post-metadata">

**Author:** ![jacekc](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@jacekc](https://forums.imgtec.com/u/jacekc)\
**Post date:** [August 10, 2011, 7:34am UTC](https://forums.imgtec.com/t/glgetintegerv-and-gl-active-texture/524/4 "2011-08-10T07:34:01Z")

</div>

Thanks for your report. We will be looking at that shortly.

Regards,

---

<div class="post-metadata">

**Author:** ![xmas](https://avatars.discourse-cdn.com/v4/letter/x/958977/32.png) [@xmas](https://forums.imgtec.com/u/xmas)\
**Post date:** [August 18, 2011, 8:57am UTC](https://forums.imgtec.com/t/glgetintegerv-and-gl-active-texture/524/5 "2011-08-18T08:57:40Z")

</div>

jbuck wrote:

This code was fine before adding the code for putting back the prevActiveTexUnit. Also, the value for prevActiveTexUnit seems to be 0-based instead of GL\_TEXTURE0-based. From my reading of the standard, it seems that it should be GL\_TEXTURE0-based.

  
GL\_ACTIVE\_TEXTURE stores the enum value, not the number of the unit starting from 0. As the specification states, the initial value is GL\_TEXTURE0.
