PDA

View Full Version : glCopyPixels() & glCopyTexSubImage2D(() difference ?



def
12-23-2005, 04:57 AM
Hi,

should there be a difference in pixeldata between glReadPixels() and glCopyTexSubImage2D()?
I am doing the following:

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_tex);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, 800, 600, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, 0, 800, 600);
/* could do some processing here ... */
glGetTexImage( GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data);The Results in Data differ from a call to

glReadPixels(0, 0, 800, 600, GL_RGBA, GL_UNSIGNED_BYTE, Data);When using 8xS antialiasing (or more) the differences are visible. It seems the results of glGetTexture() are not antialiased properly, but there is some difference to the non-antialiased results...

Running on 7800GTX with 81.95 driver.

def
12-23-2005, 07:08 AM
This seems to be a NVidia issue. Happens on a few different cards and drivers.
Seems to work on ATI, although I could only do one test...

def
12-28-2005, 12:34 AM
I should rename this thread to "glGetTexImage() Bug". glCopySubImage2D() is not the problem.

It seems glGetTexImage() does not return the right data, for whatever reasons. The most I could find out about other peoples experiences with glGetTexImage() is "I've never used it" ...

I sure feel like I'm talking to myself. :rolleyes:

sqrt[-1]
12-28-2005, 05:35 AM
I can't help you, but perhaps a few images of the differences would help other people?

def
12-28-2005, 06:54 AM
Good idea! :)

http://img279.imageshack.us/img279/6960/screen9zj.jpg

This screenshot shows the strange quality I get when using glCopyTexSubImage2D(). The bottom half of the image is a screen aligned quad with the top half applied as a texture.
I used LINEAR filtering just to make sure its not a filtering issue, but NEAREST shows the same result ( texel to pixel screen aligned )

The difference is most obvious in the vertical lines but you can also see it on the pink polygons edges.

Maybe this looks familiar to someone...
Thanks

zed
12-28-2005, 10:35 AM
try sticking a glFinsh() before u do the read/copy
also perhaps antialaisng might be interferring somehow (i dont know much about AA) so disable it

tamlin
12-28-2005, 11:27 PM
If the driver is doing its job, the Finish() call would be redundant. Sure, it never hurts testing it, but in this case I'm almost certain it'll not make a difference.

Instead, I think this just ties in with the recent discussion about multisample FBO (I think it was).

def
12-29-2005, 01:00 AM
Although it is not recommended for SLI use I tried a glFinish(), same difference.
Without antialiasing it works just fine, but that's not an option for me.
Actually, multisample FBOs would just be a workaround to the buggy glCopyTexSubImage2D()...