1
General / Drawing over previous drawing
« on: December 04, 2012, 10:44:26 pm »
Hello
In my game I have a function asking the player for number. I use it in the game's options menu among other things. It can look like this:
"PROJECTILE DELAY (ms) : 25"
And when you press return with this one selected, the player can modify this number, it should look like this:
"PROJECTILE DELAY (ms): 25_"
Where the "_" is the cursor for editing the number.
I recently switched from SDL to SFML 2.0, which I'm mostly very happy about. But I'm stuck on this function.
In SDL, the calling function first rendered its things (options menu), then called the number query function with parameters given for where to draw the number while its being typed. The query function simply drew the number over the background left from the calling function.
SFML's "philosophy" seems to be that everything should be drawn at once from a cleared screen. This gives me a problem here. The query function doesn't know anything about the background images.
One solution I see is to have the query function take a screen shot, using sf::RenderWindow::capture(). Saving that to a png file. Then load that to a texture, and render over that while the player edits the number. But it just seems... dumb somehow
How can I do this? What about my idea?
Can I capture the screen and use that for drawing directly, instead of having to save it to a file first?
In my game I have a function asking the player for number. I use it in the game's options menu among other things. It can look like this:
"PROJECTILE DELAY (ms) : 25"
And when you press return with this one selected, the player can modify this number, it should look like this:
"PROJECTILE DELAY (ms): 25_"
Where the "_" is the cursor for editing the number.
I recently switched from SDL to SFML 2.0, which I'm mostly very happy about. But I'm stuck on this function.
In SDL, the calling function first rendered its things (options menu), then called the number query function with parameters given for where to draw the number while its being typed. The query function simply drew the number over the background left from the calling function.
SFML's "philosophy" seems to be that everything should be drawn at once from a cleared screen. This gives me a problem here. The query function doesn't know anything about the background images.
One solution I see is to have the query function take a screen shot, using sf::RenderWindow::capture(). Saving that to a png file. Then load that to a texture, and render over that while the player edits the number. But it just seems... dumb somehow
How can I do this? What about my idea?
Can I capture the screen and use that for drawing directly, instead of having to save it to a file first?