SFML community forums
Help => Graphics => Topic started by: JeZ-l-Lee on February 06, 2009, 07:01:51 pm
-
Is There A Function To Draw A Single Pixel ??
Hi,
I am making a 2-d space shooter game now.
I would like to have moving stars in the background.
How would I draw a single pixel at (x,y) in a certain color to screen buffer?
Thanks
You can track the progress of this game at this URL:
http://www.silentheroproductions.com/LastDefense100PerceT.htm
-
Use OpenGl directly is the best way!
Instead you can make sprites of 1*1 and move them in the screen;
-
Here's what I did, I made an sf::Image the size of the renderwindow. Then I used setpixel() to set the appropriate pixels white/black when needed.
-
If you are a little bit used to OpenGL, I think it's the easiest and most performant (in the last few days, I looked at the NeHe OpenGL tutorials, and at the moment I am experimenting a little... I think one learns the basics quite fast.)
Otherwise Phreak's method is probably not bad, either. Alternatively, you could use a sf::Shape to draw very small objects. The problem is, if your star has got a texture, you have to take a sprite or use OpenGL.
-
I found a way to fill a square sf::Shape (no outline) to draw a single pixel, but like the other workarounds mentioned previously, it seems more interesting than practical or efficient.
I know OpenGL isn't that hard, but that doesn't take the painful irony out of saying it to someone who wants to draw one pixel.
I vote to put something in the API to draw a single pixel (or list of points). Perhaps even a variation of the sf::Shape class itself, or style of outline even.
It just seems the perfect fit for SFML's level of API: It would not be as fast as the pure OpenGL, but it would provide a speed up for the many people who expect it.
Hopefully the SFML team will agree, and not see it as lame feature creep...
-
Yep, maybe I can find a way to provide this kind of feature :)
-
Many Thanks!
throw Horns("sfml rocks");