I have a screenshot taken from the first opengl canvas which i need to draw in the second opengl canvas. I have taken the screenshot using glReadPixels
:
glReadPixels(posx, posy, pageWidth , pageHeight, GL_RGB, GL_UNSIGNED_BYTE, data);
The first opengl canvas has two or more images with some lines and text data around it. I am using the second opengl canvas to show the tiling of the images with the surrounding data as a whole.I do not want to redraw the same in the second opengl canvas and hence want to take a screenshot and draw the tiling part of the screenshot in the second canvas.
I also have saved the snapshot taken in to a jpg file which is coming perfectly.
But the problem comes when I need to draw the pixel data using glTexImage2d as the pageWidth or pageHeight used cannot be represented as 2K+ 2. Hence the error is coming as GL_INVALID_VALUE
.
glTexImage2D (GL_TEXTURE_2D, 0, imgSamplesPerPixel),
pageWidth, pageHeight, 0,SamplesPerPixel, GL_UNSIGNED_BYTE, data);
The pageWidth and pageHeight can be of any value (lesser than the GL_MAX_TEXTURE_SIZE
), for example 240 X 600. So how should I solve this problem ?