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

Author Topic: Draw directly into an image  (Read 2746 times)

0 Members and 1 Guest are viewing this topic.

psnake

  • Newbie
  • *
  • Posts: 1
    • View Profile
Draw directly into an image
« on: January 13, 2009, 08:26:57 pm »
Hi,

  I want to draw directly into an image, but I highly suspect that that is not possible. But still I'll expose my idea to see if you can help me out since I'm starting so I don't have much experience.

  The objective is: every object in my game lights up when the mouse moves over them, to achieve this I thought that I could draw the objects normaly to the screen and then I would take that same pixels, give them one unique color and draw the object again to an image. The color chosen corresponds to the object ID, so when I want to check if the mouse is over an object I would just do get_pixel() at mouse coordinates and that would instantly give me which object to light up.

  Is there a cheap easy way to do this?

  I thought in making my own "buffer" image, but one big disadvantage is that I would have to replicate the sf::Shape functionality (since the object drawing function relies heavily on it).

Best Regards,
PSnake

dorkfish

  • Newbie
  • *
  • Posts: 38
    • View Profile
Draw directly into an image
« Reply #1 on: January 14, 2009, 04:22:43 pm »
Check the roadmap, there's a link to it on the front page. Laurent is already planning to implement render to image. :)

Edit: You might also try PostFX, which uses GLSL shaders. You could colorize your buttons using that, and I suspect it would be a lot easier.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Draw directly into an image
« Reply #2 on: January 15, 2009, 01:23:59 am »
Quote from: "psnake"
The objective is: every object in my game lights up when the mouse moves over them

I have implemented this a while ago. The way I did it was setting the sprite's color and alpha value so that it would appear darker. When you move the mouse over it, reset the color to its original value, and the sprite is drawn normally.

To light it even more up, you could lay bright partially-transparent sprites over the sprite or use post effects.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Draw directly into an image
« Reply #3 on: January 17, 2009, 04:50:30 pm »
You just have to modulate the drawable's color to be brighter when the mouse is over it.

 

anything