Sorry because i have create a same topic in the advance forum but i realize that it is just a simple question which i should put it in the beginner forum.
i need to save my client area to a texture, the problem is glTexImage2D need the width and height to be power of 2 size. But the client area will not possible to be power of 2 always. Somebody told me that glTexSubImage2D can help but how?
here is my code
int port[4];
glGetIntegerv(GL_VIEWPORT,port);
if(colorSave != NULL)
free(colorSave);
colorSave = (unsigned char*)malloc(port[2] * port[3] * 4 * sizeof(unsigned char));
glReadPixels(port[0],port[1], port[2],port[3], GL_RGB , GL_UNSIGNED_BYTE,
colorSave);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1,&texName);
glBindTexture(GL_TEXTURE_2D,texName);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,port[2],port[3],0,GL_RGB,GL_UNSIGNED_BYTE,colorSave);
glBindTexture(GL_TEXTURE_2D,texName);
glTexSubImage2D(GL_TEXTURE_2D,0,port[0],port[1],port[2],port[3],GL_RGB,GL_UNSIGNED_BYTE,colorSave);
can somebody please correct my code so that it can save a the client area that is not a power of 2 in to a texture. Thanks in Advance