I'm writing an app for Mac OS X with OpenGL 2.1

I have a `CVOpenGLTextureRef` which holds the texture that I render with GL\_QUADS and everything works fine.

I now need to determine which pixels of the texture are black, therefore I have written this code to read raw data from texture:

```
//"image" is the CVOpenGLTextureRef

GLenum textureTarget = CVOpenGLTextureGetTarget(image);
GLuint textureName = CVOpenGLTextureGetName(image);

glEnable(textureTarget);
glBindTexture(textureTarget, textureName);

GLint textureWidth, textureHeight;
int bytes;
glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth);
glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight);
bytes = textureWidth*textureHeight;

GLfloat buffer[bytes];
glGetTexImage(textureTarget, 0, GL_LUMINANCE, GL_FLOAT, &buffer);
GLenum error = glGetError();

```

`glGetError()` reports `GL_NO_ERROR` but buffer is unchanged after the call to `glGetTexImage()`...it's still blank.

Am I doing something wrong?

Note that I can't use `glReadPixels()` because I modify the texture before rendering it and I need to get raw data of the unmodified texture.

**EDIT:** I tried even with the sequent approach but I still have zero buffer as output

```
unsigned char *buffer = (unsigned char *)malloc(textureWidth * textureHeight * sizeof(unsigned char));
glGetTexImage(textureTarget, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, buffer);

```

**EDIT2:** Same problem is reported [here](http://markmail.org/message/myx33irugn3um5yy) and [here](http://web.archiveorange.com/archive/v/CdR6fbrIuMurz6ILaoS8)