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

Author Topic: [mostly solved]Clear() for sprites/images too?  (Read 4957 times)

0 Members and 1 Guest are viewing this topic.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[mostly solved]Clear() for sprites/images too?
« on: April 10, 2010, 06:45:03 pm »
Hi, when I worked in flash with blitting you had control over the 'clear' (fill) of each image to clean up the pixels before drawing.

Are you doing this automatically in SFML?

How do I get control of this in SFML?

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
[mostly solved]Clear() for sprites/images too?
« Reply #1 on: April 10, 2010, 07:02:52 pm »
Why clear the images?

You can clear the screen with App.Clear(), read the tutorials.

You can also clear a sf::RenderImage.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[mostly solved]Clear() for sprites/images too?
« Reply #2 on: April 11, 2010, 02:57:48 am »
Quote from: "Spidyy"
Why clear the images?

You can clear the screen with App.Clear(), read the tutorials.

You can also clear a sf::RenderImage.


Hi, thanks for the tips.

I'm aware of App.Clear(), that's why I used 'too'.

The question is what OpenGL/SFML does for drawing/clean up.

When you are blitting the pixels are copied into an image to give the appearance of a stack. If you don't copy clear (or bg colored) pixels into the image than it remains 'dirty'.

I haven't checked the source, but 'App.Clear()' appears to effect everything to make it easy. But I might need certain images to be 'dirty'. Maybe it's doing buffer swaps or something like that.

I'll try to look at the source, but it would be nice if there was a diagram/chart/explanation of how opengl works in SFML (it's probably different in 2.x too).

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
[mostly solved]Clear() for sprites/images too?
« Reply #3 on: April 11, 2010, 08:52:24 am »
Quote
The question is what OpenGL/SFML does for drawing/clean up.

For cleaning up: You can have a look at RenderTarget.cpp. It calls glClear, which basically fill a color across the backbuffer.
For drawing: It uses the 3D hardware to draw a textured quad. The whole copying of pixels, rotating, scaling ... is left to the GPU.

Quote
When you are blitting the pixels are copied into an image to give the appearance of a stack. If you don't copy clear (or bg colored) pixels into the image than it remains 'dirty'.

You can choose not to call Clear. Instead, you can draw a blank image on top of the part you need to clear. However, I recommend using an sf::RenderImage

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
[mostly solved]Clear() for sprites/images too?
« Reply #4 on: April 12, 2010, 01:00:51 am »
Quote from: "bullno1"
Quote
The question is what OpenGL/SFML does for drawing/clean up.

For cleaning up: You can have a look at RenderTarget.cpp. It calls glClear, which basically fill a color across the backbuffer.
For drawing: It uses the 3D hardware to draw a textured quad. The whole copying of pixels, rotating, scaling ... is left to the GPU.

Quote
When you are blitting the pixels are copied into an image to give the appearance of a stack. If you don't copy clear (or bg colored) pixels into the image than it remains 'dirty'.

You can choose not to call Clear. Instead, you can draw a blank image on top of the part you need to clear. However, I recommend using an sf::RenderImage


Thanks a lot. This seems to do what I need/want.

I'll have to see how it affects performance.

 

anything