Advertisement

Tessellating the frame buffer

Started by January 03, 2003 04:18 PM
0 comments, last by Crispy 22 years, 2 months ago
Hi, I want to read the framebuffer, tessellate it into a bunch of smaller images and display a distorted image with the smaller images'' texcoords modified. However the simplistic method I''m using is terribly slow (pulls the framerate down to .5). To save some space I''ll just post the code:
  
void TLensEffect::Process()
{
  static unsigned x, y, Index;

  Index = 0;
  for(y = 0; y < Height; y += BlockSize)
    {
    for(x = 0; x < Width; x += BlockSize)
      {
      //bind the next texture in the texture container

      DistortionTC->Bind(Index++);
      //this place is the bottleneck

      glCopyPixels(x, y, BlockWidth, BlockHeight, GL_COLOR);
      }
    }

  OpenGLOrtho(&Window->WindowRect);
  //glDisable(GL_CULL_FACE);


  //draw the fragments

  Index = 0;
  glBegin(GL_QUADS);
  for(y = 0; y < Height; y += BlockSize)
    {
    for(x = 0; x < Width; x += BlockSize)
      {
      DistortionTC->Bind(Index++);

      glTexCoord2fv(TexCoords[Index]);
      glVertex2f(x, y);
      glTexCoord2fv(TexCoords[Index + 1]);
      glVertex2f(x + BlockWidth, y);
      glTexCoord2fv(TexCoords[Index + BlockCountX + 1]);
      glVertex2f(x + BlockWidth, y + BlockHeight);
      glTexCoord2fv(TexCoords[Index + BlockCountX]);
      glVertex2f(x, y + BlockHeight);
      }
    }
  glEnd();
  OpenGLPerspective();
}
  
Why''s glCopyPixels() the bottleneck? Should I be using glCopySubImage2D() instead? Thanks in advance, Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
How to get rendered image into a texture?


  • glReadPixels() ! glTexImage*() ?

    Slow.


  • glCopyTexImage*()

    Better.


  • glCopyTexSubImage*()

    Even Better.


  • Render Directly to Texture

    Eliminates “texture copy” – potentially optimal


see http://developer.nvidia.com/view.asp?IO=gdc_oglrtt for more info about rendering to textures.


- Jono AH

[edited by - jonox on January 4, 2003 7:14:23 AM]
- JonoRule #1: If you build it, they will come -- to hack and cheat.

This topic is closed to new replies.

Advertisement