PDA

View Full Version : pixel operations



11-05-2000, 10:38 AM
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?
Curious

phlake
11-06-2000, 09:53 AM
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.

11-06-2000, 05:16 PM
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?

phlake
11-07-2000, 05:53 AM
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. ^_^

jc
11-07-2000, 06:43 AM
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:

NAME
glCopyTexSubImage2D - copy a two-dimensional texture
subimage


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


PARAMETERS
target Specifies the target texture. Must be
GL_TEXTURE_2D

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

width Specifies the width of the texture subimage.

height Specifies the height of the texture subimage.