Which method is faster - glVertex OR glDrawPixels

Hi,

I would like to draw a lot of points(i.e. pixels) on the screen, I would like to know which of the following methods is faster.

  1. Using glDrawPixels
  2. Using glVertex

Thanks. :slight_smile:

DrawPixels will almost certainly be faster but will only draw a regular rectangle of points and will not project that rectangle in 3D, it will only project the origin of the rectangle then draw the regular array of information.

For your benchmarking adventures I would also try using a single texture and glTexSubImage2D for updates. Try NV_pixel_data_range if available/wait for ARB_Pixel_Buffer_Object some more.

Originally posted by dorbie:
DrawPixels will almost certainly be faster but will only draw a regular rectangle of points and will not project that rectangle in 3D, it will only project the origin of the rectangle then draw the regular array of information.
Thanks.

As I am only concerning 2D space, so I should use drawPixel. :slight_smile:

If you just do it once yes, however if youโ€™re animating you should almost certainly load to a texture and draw a textured quad, even for the 2D case, it will be faster guaranteed (provided you use bind texture objects). It may even be faster for a single draw call since texture loading is optimized.

Keep it simple at first then try to optimize with fancy memory extensions.

hi dorbie,

thanks for your reply.

In fact, what i am doing is to fill a large area by pixels.

today i have tried to compare the speed of using glDrawPixels & glVertex

it seems to me that when i repeat a lot of - glrasterpos() + glDrawPixels(), the speed is slower than glvertex()

the code is :

GLfloat single_point[3] = {255,0,0};
glRasterPos2d(x,y);
glDrawPixels(1,1, GL_RGBA , GL_FLOAT , single_point )

any suggestion?
:slight_smile:

put all the pixels an array and call
glDrawPixels(width, length, GL_RGBA, GL_FLOAT, pointarray);

that will be MUCH faster