Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is There A Function To Draw A Single Pixel ??  (Read 7200 times)

0 Members and 1 Guest are viewing this topic.

JeZ-l-Lee

  • Jr. Member
  • **
  • Posts: 80
    • ICQ Messenger - 223180991
    • MSN Messenger - JeZLee@Live.com
    • AOL Instant Messenger - SLNTHERO@aol.com
    • View Profile
    • http://www.SilentHeroProductions.com
    • Email
Is There A Function To Draw A Single Pixel ??
« 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
JeZ+Lee
Silent Hero Productions(R)
Video Game Design Studio

http://www.SilentHeroProductions.com

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
Is There A Function To Draw A Single Pixel ??
« Reply #1 on: February 06, 2009, 09:46:05 pm »
Use OpenGl directly is the best way!

Instead you can make sprites of 1*1 and move them in the screen;
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

Pfhreak

  • Newbie
  • *
  • Posts: 11
    • View Profile
Is There A Function To Draw A Single Pixel ??
« Reply #2 on: February 06, 2009, 10:11:44 pm »
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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Is There A Function To Draw A Single Pixel ??
« Reply #3 on: February 07, 2009, 03:18:24 am »
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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

til

  • Newbie
  • *
  • Posts: 5
    • View Profile
Is There A Function To Draw A Single Pixel ??
« Reply #4 on: January 05, 2010, 06:43:01 am »
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...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Is There A Function To Draw A Single Pixel ??
« Reply #5 on: January 05, 2010, 12:08:34 pm »
Yep, maybe I can find a way to provide this kind of feature :)
Laurent Gomila - SFML developer

til

  • Newbie
  • *
  • Posts: 5
    • View Profile
Is There A Function To Draw A Single Pixel ??
« Reply #6 on: January 05, 2010, 07:00:46 pm »
Many Thanks!  
throw Horns("sfml rocks");