pixel operations

I was wondering why all pixel operations such as glCopyPixels and glAccum are so slow on my machine(piii 450,diamond riva tnt2 ultra,asus p2bf). Even with the area set to say 300 x 300 (RGBA). I realize that is still alot of pixels, but, if windows GDI functions can blt the whole screen in a flash, why can’t glCopyPixels be faster with a much smaller area?. How do real time programs that -seem- to use these functions manage to render with decent frame rates on the very same machine?

The reason is fairly straight forward, once you know the solution. so: to draw images fast, bind them as texture objects, and draw them as a textured quad or tri-strip.

the reason this is faster is that when texture objects are created, the texture is (given enough vram) dumped onto the graphics card, so it’s got fast access from then on.

glCopyPixels(), on the other hand, takes as an argument a pointer to system ram. that means you’ve got a system ram to video ram transfer every_time you call glCopyPixels(). hence, it doesn’t go so terribly fast.

Thanks, that is pretty straight forward. But supposing I need to create scene motion blur or something else that needs the contents of the front and back buffer; can textures be created from the contents of the buffers in less time than an accumul-buffer op?

Hrrrrm. I don’t really know. Neither one of those operations are hardware accelerated on consumer-grade cards, though. I’m not sure which is faster, but I’d be surprised if either were actually fast.

I’d be interested to know how it works out for you, though. :slight_smile:

U should try to use the glCopyTexSubImage2D function. U can draw in a buffer and copy an area of this buffer into a texture.

I used it with a GeForce II and it worked pretty well.

If u can, u would better copy many small areas than a big one (but it must depend on the graphic card).

Hope that will help you.

ps: the spec of this func is:

      glCopyTexSubImage2D - copy a two-dimensional texture

      void glCopyTexSubImage2D( GLenum target,
                                GLint level,
                                GLint xoffset,
                                GLint yoffset,
                                GLint x,
                                GLint y,
                                GLsizei width,
                                GLsizei height )

      target   Specifies the target texture.  Must be

      level    Specifies the level-of-detail number.  Level 0 is
               the base image level.  Level n is the nth mipmap
               reduction image.

      xoffset  Specifies a texel offset in the x direction within
               the texture array.

      yoffset  Specifies a texel offset in the y direction within
               the texture array.

      x, y     Specify the window coordinates of the lower left
               corner of the rectangular region of pixels to be

      width    Specifies the width of the texture subimage.

      height   Specifies the height of the texture subimage.