1
Graphics / 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
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