PDA

View Full Version : Which method is faster - glVertex OR glDrawPixels



powervr
10-07-2004, 06:22 AM
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. :)

dorbie
10-07-2004, 02:23 PM
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.

roffe
10-07-2004, 09:46 PM
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.

powervr
10-07-2004, 10:54 PM
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. :)

dorbie
10-07-2004, 11:33 PM
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.

powervr
10-08-2004, 08:01 AM
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?
:)

chowe6685
10-08-2004, 08:46 AM
put all the pixels an array and call
glDrawPixels(width, length, GL_RGBA, GL_FLOAT, pointarray);

that will be MUCH faster