Results 1 to 6 of 6

Thread: glCopyTexSubImage2D -> slow

  1. #1
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    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:
    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

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: glCopyTexSubImage2D -> slow

    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.

  3. #3
    Senior Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    913

    Re: glCopyTexSubImage2D -> slow

    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.

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: glCopyTexSubImage2D -> slow

    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?

  5. #5
    Senior Member Frequent Contributor
    Join Date
    May 2005
    Location
    Prague, Czech Republic
    Posts
    913

    Re: glCopyTexSubImage2D -> slow

    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>.

  6. #6
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: glCopyTexSubImage2D -> slow

    Ah, thanks
    Hylke

Similar Threads

  1. 32 bit value with glCopyTexSubImage2D
    By jos_t_tarigan in forum OpenGL: GLSL
    Replies: 2
    Last Post: 01-25-2011, 04:31 AM
  2. Too Slow -> glCopyPixels, glCopyTexSubImage2D
    By AGL_Music in forum OpenGL: Windows
    Replies: 5
    Last Post: 02-10-2010, 05:43 AM
  3. glCopyTexSubImage2D fp16 -> fp32 slow
    By marco_dup1 in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 10-10-2005, 10:19 AM
  4. Slow app due to glCopyTexSubImage2D()
    By Josh Senecal in forum OpenGL: macOS
    Replies: 1
    Last Post: 09-21-2005, 10:55 PM
  5. glCopyTexSubImage2D slow
    By marco_dup1 in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 11-15-2004, 12:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean