Jump to content
  • Advertisement
Sign in to follow this  
ed209

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.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
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 mode
for(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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!