How can I draw a single point?

Started by
13 comments, last by speciesUnknown 16 years, 2 months ago
How can I draw a single point in Opengl?
Advertisement
Did you try glDrawPixels()?
What about GL_POINTS?

glBegin(GL_POINTS); glVertex2f(x,y); glEnd();
Set an appropriate projection with gluOrtho2D, glBegin with GL_POINTS, and draw your point with glVertex2i (with glColor* for color).

Now, this may or may not be an extremely stupid answer. You see, while this is indeed a good and efficient way of drawing a single point, most people who ask "how can I draw a single point?" aren't actually interested in drawing a single point. Rather, they are interested in drawing lots and lots of stuff, a pixel at a time. This is a good way of drawing one point, and a really bad way of drawing millions of points. So if you were mistaken in what you meant to ask, let us know so we can give you a better answer.
How do I draw many points in opengl?
Quote:Original post by SiCrane
Did you try glDrawPixels()?


Do remember though that the moment you start using these points to draw something, like a line, a triangle or an image, that's the moment you start misusing them.
Quote:Original post by ed209
How do I draw many points in opengl?


use a for loop, or three.
glBegin(GL_POINTS); //set opengl to point drawing modefor(int x=0; x<128; x+=2)for(int y=0; y<128; y+=2)for(int z=0; z<128; z+=2){    glColor3f((float)x/128.0f,(float)y/128.0f,(float)z/128.0f);        //slightly different colour for each dot    glVertex3f(x,y,z);        //draw the point}glEnd();//end point drawing mode


you can make this more efficient using vertex arrays (this is VEERY slow when run in real time)
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Do you know how to draw points not only somewhere in space (XYZ) but with per pixel precision. EG. I want to pixel at 8x89y would be red - no matter what ressolution is used by user.
Thanks for the help, but I have two more questions.

#1 Please answer the above poster's question cause that is also my question.

#2 My goal is to make an nes emulator some day and I was wondering if drawing pixels like this would be sufficient? Or is there another way I should be doing it?

I am using VB by the way and there isn't too much documentation on opengl with VB.

This topic is closed to new replies.

Advertisement