I'll be doing this using glTexSubImage2D. However to do that, I need to get the pixel data from the texture. So I'm doing that using glGetTexImage. Here's my code so far:
GLuint CreateMegaTexture(vector<GLuint> texies ){
glBindTexture(GL_TEXTURE_2D,texies.at(0));
GLint textureWidth, textureHeight;
int bytes;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &textureWidth);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &textureHeight);
bytes = textureWidth*textureHeight;
float Pixels[bytes];
glGetTexImage(GL_TEXTURE_2D,0,GL_RGBA,GL_UNSIGNED_BYTE,&Pixels);
//GLenum error = glGetError();//Get error
}
For now, I'm just testing by trying to get the pixel data of the first element in the "texies" array. So first I get the size of the texture so that I know how large I need to make the array to hold the pixel data. Now there is the problem.
The documentation said the "Pixels" array would need to be of the same type that I chose, which is "GL_UNSIGNED_BYTE" in my case. However, if I do:
GL_UNSIGNED_BYTE Pixels[bytes];
I get an error:
"error: expected ';' before 'Pixels'
If I try GLfloat instead:
GLfloat Pixels[bytes];
glGetTexImage(GL_TEXTURE_2D,0,GL_RGBA,GLfloat,&Pixels);
I get an even stranger error:
expected primary-expression before ',' token
I don't think it will work if I have the array as simply "float" (although it doesn't throw any errors by the compiler), so I thought I should fix this issue before moving on to glTexSubImage2D.
Any help would be appreciated, thanks!






