# OpenGL How can I draw a single point?

This topic is 3958 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How can I draw a single point in Opengl?

##### Share on other sites
Did you try glDrawPixels()?

##### Share on other sites

glBegin(GL_POINTS); glVertex2f(x,y); glEnd();

##### Share on other sites
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.

##### Share on other sites
How do I draw many points in opengl?

##### Share on other sites
Quote:
 Original post by SiCraneDid you try glDrawPixels()?

##### Share on other sites
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.

##### Share on other sites
Quote:
 Original post by ed209How 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)

##### Share on other sites
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.

##### Share on other sites
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.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633667
• Total Posts
3013253
×