1

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 ?

  • What is the size of your texture then? Also helps if you include more info such as why you are doing this and what you want to achieve. There might be better ways for that situation specifically. – Grimmy May 13 '13 at 04:48
  • what is the value of imgSamplesPerPixel and SamplesPerPixel? – ds-bos-msk May 13 '13 at 12:26
  • The 2K+2 notion seems bogus? Have you actually verified that it works in a 2K+2 case? Actually, it is more likely that this is an issue with the tezure sizes not beeing a power of two (2^K). Have you checked if your implementation does support the [ARB_non_power_of_two extension](http://www.opengl.org/registry/specs/ARB/texture_non_power_of_two.txt) (although that is rather likely even on quite old GPUs)? – derhass May 13 '13 at 20:41
  • What I meant was that the width or height value cannot be represented as 2^k itself. I found the solution by scaling the snapshot to the nearest 2^k width and height values and then using the scaled imageBuffer in the glTextImage2D to draw it onscreen. Thank you for your help and sorry for the ambiguity in my original question. – Manoranjan Aithal May 16 '13 at 06:22

0 Answers0