Fast pixel plotting with opengl

I have been trying to find a fast way to plot pixels (one at a time and lots of them) with opengl. Every method I’ve tried has been inadequate. The fastest way I’ve come up with is to have an array of pixels (the size of the full viewport) which I write pixels to, then once they are all ready, draw them with a single call to glDrawPixels. This is the fastest way I’ve found, but it is still too slow. Using glVertex in points mode is also waaaay too slow. So is there a faster way to do it?

>> The fastest way I’ve come up with is to have an array of pixels (the size of the full viewport) which I write pixels to, then once they are all ready, draw them with a single call to glDrawPixels<<

instead of drawpixels update the data into an existing texture ie
glTexSubImage2d(…)

  • draw that texture as a polygon (everything switched off eg lighting/depth test etc)

I have two questions:

  1. How many pixels are you plotting ?
  2. If you plot the pixels yourself in a bitmap, I guess you calculate their coordinates yourself: are you plotting 3D points ? If yes, why are you doing the calcs yourself ? If not, perhaps OpenGL is not a solution at all…

Regards.

Eric

Well, since you ask…

I started working on a new 3d engine a week or two ago. At first, I made no decisions about what sort of output device I would use, and I had never written a single line of GL code. The idea at first was that there would be an opengl renderer, and an internal software renderer. Everything is object oriented, and there are two virtual classes OutputDevice, and Projector. The derived ProjectorInternal class was what knew how to draw 3d objects pixel by pixel. It required that you gave it some output device that knew how to draw pixels, and it would do the rest. Well…of course I dont want to do 3d with opengl pixel by pixel, but I just though it would be cool if my ProjectorInternal would work with GL as well as my ProjectorGL(which is optimized for GL). Anyway, today I decided to abandon the software renderer entirely(which used SDL without OpenGL). Still, I would like to find a fast way of plotting pixels (havent tried the one suggestion above yet), because it would be a nice feature of the class library I’m creating.

[This message has been edited by ioquan (edited 04-08-2002).]

Originally posted by zed:
[b]>> The fastest way I’ve come up with is to have an array of pixels (the size of the full viewport) which I write pixels to, then once they are all ready, draw them with a single call to glDrawPixels<<

instead of drawpixels update the data into an existing texture ie
glTexSubImage2d(…)

  • draw that texture as a polygon (everything switched off eg lighting/depth test etc)[/b]

I am sorry for the duplicate question, but just need it urgent.
if the screen size is not the power of 2, is it possible to save it.

here is my code.

int port[4];
glGetIntegerv(GL_VIEWPORT,port);

colorSave = (unsigned char*)malloc(port[2] * port[3] * 4 * sizeof(unsigned char));

glReadPixels(port[0],port[1], port[2],port[3], GL_RGB , GL_UNSIGNED_BYTE,
    colorSave);

glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,port[2],port[3],0,GL_RGB,GL_UNSIGNED_BYTE,colorSave);

glBindTexture(GL_TEXTURE_2D,texName);

glTexSubImage2D(GL_TEXTURE_2D,0,port[0],port[1],port[2],port[3],GL_RGB,GL_UNSIGNED_BYTE,colorSave);

i know glTexImage2D need power of 2 size but the size of the screen not always power of 2. Can you tell me how to do it?
thanks in advance.

All very fancy suggestions, but how about single buffered rendering with a glFlush() after you glBegin(GL_POINTS) glColor*()glVertex*() glEnd() for any given point. You did insist on drawing them one at a time.

Of course this heavily affects whatever else you might want to draw.

[This message has been edited by dorbie (edited 06-13-2003).]