glCopyTexImage2D() SLOW?!?

Hi, my program has to do lots of frame buffer reads and texturing for each frame, I have a loop which does about 50 iterations and each iteration does a glCopyTexImage2D() call 3 times. So that’s 150 of them all together, I am only getting about 1 frame per sec, surely this is REALLY slow, even with the number of frame buffer reads?? I am using a GF FX 5500.

Is there a chance it’s not using the hardware? I tried the GL_RENDERER and it returns the card’s details. Any advice? Comments?

Thanks,

Ben.

If you’re updating existing textures, use glCopyTexSubImage instead.

Thanks Bob,

Using that function does speed my program up a little, but it still won’t run at more than about 2 frames per sec.

I have no idea how long a copy should take on my card, but I guessed that 150 per frame should still run quicker than 2FPS? Am I wrong?

I am using the Mesa libraries with GLUT to compile, could this have anything to do with it?

Thanks everyone!

Ben

Which texture format you use? Try to change to BGR or BGRA.

Why using MESA?

yooyo

Yooyo, today you can be really happy in knowing that you are the man! That BGRA rather than RGBA thing worked a treat. Please can you explain why to me?

I was using Mesa as when I started out with OpenGL I was told that you had to pay for the libraries from SG, I never questioned it until recently, today I have removed Mesa. Sadly doesn’t seem any faster though!

Thanks alot,

Ben.

Oops, forget that last post, it didn’t work :frowning: I’m just getting a gray screen now!

well. If you have an array for the texture like so

int a,b;
for(a=0;a<16;a++){
     for(b=0;b<16;b++){
          array[a][b][0]=255;
          array[a][b][1]=255;
          array[a][b][2]=0;
          array[a][b][3]=255;
     }
}

You have to use GL_RGBA. If you used GL_RGB earlier you have to add all the alpha values. The reason it might be faster is because It alignes better in memory most of the time. I would assume in GL_UNSIGNED_BYTE is what Opengl Programming guide meant.

Oh and when he said to use glTexSubImage2D he didn’t mean replace all of glTexImage2D with that. I doubt you eddited you code in less than a minute, so I think you misunderstood. Every time you change a part of a texture, have a different array of the changed part(doesn’t have to be a power of 2) then use that function(it does have different parameters)