   glReadPixels and glDrawPixels
  Hello!I would like to implement some type of motion blur effect for a game that I'm working on.  The way I was planning to do this was to draw all objects to the screen but before rendering it, I would like to look at the pixel data, taking a sample of a set of pixels (which pixels will depend on whether its a horizontal, vertical motion blur etc.), averaging out these colour values and rewriting the pixel data to the screen and then finally rendering the modified image.  (I hope that was somewhat clear ^^; ).  Anyways, I am messing around with the glReadPixels and glDrawPixels functions to achieve this effect.  I tried rending a simple screen with a square in the center which was successful.  However, to test these functions, I tried adding this bit of code AFTER the glBegin(GL_POLYGON); glVertex3f, .... glEnd(); which draws the square  :GLubyte *pixels = new GLubyte [w*h];glReadBuffer(GL_BACK);glReadPixels(0, h, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);for(int i = 0; i < w*h; i++){pixels = 150;}glDrawPixels(0, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);delete(pixels);My guess was that reassigning the values of the pixel[] array (i.e. pixels = 150) and then calling the glDrawPixels function should basically make the screen some solid colour and the square should no longer be visible.  However, my program runs just as it did before adding the glreadpixels/gldrawpixels snippet of code.  Obviously I'm missing something :p  Could anyone possibly shed some light on this please?  Thanks!
  You could take a look at the demo of NVidia. They have a nice blurring sample in their SDK.EDITED: their algorithm was described here here;  Try glRasterPos2i(0, h) before drawing the data...Also, you really should do delete[] pixels instead, since it's an array :)   ;  "pixels" is a little on the small side there. I don't think that is the source of your problem, but it could cause a few problems later in the program when you want to use whatever you overwrote. I think the problem here is that you can't call read and write pixels in the middle of a begin/end block. The documentation on begin/end lists the functions you can call and those two aren't amoung them.   ;Quote:Original post by LilBudyWizer"pixels" is a little on the small side there. I don't think that is the source of your problem, but it could cause a few problems later in the program when you want to use whatever you overwrote. I think the problem here is that you can't call read and write pixels in the middle of a begin/end block. The documentation on begin/end lists the functions you can call and those two aren't amoung them.That sounds like it would be a problem, however I am doing all of this after all of my begin/end blocks.;  Misread it, but still you're reading w*h*4 bytes into an array that is w*h*1 bytes in size. GL_RGBA means 4 components, GL_UNSIGNED_BYTE means each component is one byte. Also it looks like your draw pixels is specifying the location rather than the size of the bitmap. glRasterPos or glWindowPos sets the position of the bitmap.   ;Quote:Original post by LilBudyWizerMisread it, but still you're reading w*h*4 bytes into an array that is w*h*1 bytes in size. GL_RGBA means 4 components, GL_UNSIGNED_BYTE means each component is one byte. Also it looks like your draw pixels is specifying the location rather than the size of the bitmap. glRasterPos or glWindowPos sets the position of the bitmap.Thank you very much for your help!  I added the glRasterPos command to my code and it worked.  Thanks for all the replies guys!   