View Full Version : glCopyTexSubImage2D can' t work?

10-23-2005, 03:19 AM
I want to use content in frame buffer as texture.
following code do the job:
glReadBuffer( GL_BACK);
glReadPixels(0, 0, 500, 500, GL_RGB, GL_UNSIGNED_BYTE, pPixels);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 500,
500, 0, GL_RGB, GL_UNSIGNED_BYTE, pPixels);

however, following code does not:
glReadBuffer( GL_BACK);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 500, 500);

why? I think glCopyTexSubImage2D copy frame buffer to texture.

10-23-2005, 03:38 AM
that is really confusing. I change glCopyTexSubImage2D into glCopyTexImage2D, it works. What happens, then?

10-23-2005, 04:56 AM
Before you use CopyTexSubImage, you should specify the format and dimension of your texture object.
How it can be done? By CopyTexImage or by TexImage, it doesn't matter.
For example, you should alter code like this:

if (FirstTime) {
FirstTime = false;
} else {

10-23-2005, 07:51 AM
Maybe this is true, for first time to use glCopyTexImage2D, the internal format is not given.

10-23-2005, 09:00 AM
This is not maybe, this is simply like that ;)

10-23-2005, 03:12 PM
You can also call glTexImage with NULL for the pixels before the first time to eliminate the special case. This initializes the texture to undefined contents, which you can override with glCopyTexSubImage.

Depends on your overall code structure which one is better...