glCopyTexSubImage2D -> slow

Hello,
I’m having some performance issues with glCopyTexSubImage2D. Actually, my program doesn’t do much exciting. It simple copies a 500x500 pixel region from the framebuffer, and then renders it as a texture. But I still get a framerate of +/- 3.
Here’s my code:

glBindTexture(GL_TEXTURE_2D, TextureIndex);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width()-1, height()-1);
glClear(GL_COLOR_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, TextureIndex);
glBegin(GL_QUADS);
	glTexCoord2d(0.0, 0.0); glVertex2f(-5.0, -5.0);
	glTexCoord2f(1.0, 0.0); glVertex2f(5.0, -5.0);
	glTexCoord2f(1.0, 1.0); glVertex2f(5.0, 5.0);
	glTexCoord2f(0.0, 1.0); glVertex2f(-5.0, 5.0);
glEnd();
glBegin(GL_POINTS);
	glColor3fv(dotcolor);
	glVertex2f(float(players[i].oldpos[0]) / float(PixelsPerUnitX) - 5.0, float(players[i].oldpos[1]) / float(PixelsPerUnitY) - 5.0);
	glVertex2f(float(players[i].position[0]) / float(PixelsPerUnitX) - 5.0, float(players[i].position[1]) / float(PixelsPerUnitY) - 5.0);
glEnd();

That’s all it does, but still I have sucha slow FPS. Is this normal(because I wouldn’t expect sucha low FPS for sucha easy task)?
And is there someway to improve the performance a bit?
Btw, I have a Geforce FX 5600.
Thanks in advance,
Hylke

What’s the size of the original texture image?
Remember GeForce 5xxx have no non-power-of-two (NPOT) textures. You might want to use the GL_TEXTURE_RECTANGLE target and unnormalized texcoords if you can’t go to 512*512, which both should be snappy.

BTW, the second of your glBindTexture(GL_TEXTURE_2D, TextureIndex) calls is redundant.

The FX5600 hw does not support textures that have dimensions that are not power of two trough the normal GL_TEXTURE_2D interface so their rendering is reverting to the software fallback. You have to use the (ARB|EXT|NV)_texture_rectangle extension.

Thanks for the replies.
It all seems to work well, except for one function, glCopyTexSubImage2D
this makes my screen go black, although my texture image is just the half of my screen.
I didn’t changed anything in my code except for replacing GL_TEXTURE_2D with GL_TEXTURE_RECTANGLE_ARB.
Does this mean glCopyTexSubImage2D doesn’t support NPOT textures?

Originally posted by Hylke Donker:
I didn’t changed anything in my code except for replacing GL_TEXTURE_2D with GL_TEXTURE_RECTANGLE_ARB.

The GL_TEXTURE_2D uses normalized texture coordinates. To address entire texture you use texture coordinate range <0,0>-<1,1>.

The GL_TEXTURE_RECTANGLE_ARB uses unnormalized texture coordinates. To address entire texture you need to use texture coordinate range <0,0>-<texture_width,texture_height>.

Ah, thanks :slight_smile:
Hylke