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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Dienes

Pages: [1]
1
Network / Re: After sending a packet (seems) receiving wrong header...
« on: November 29, 2014, 02:49:58 pm »
You are sharing your "header*" variables between 2 threads and you arent using a mutex which means you are more than likely getting a race condition because 1 thread is a writer.

No synchronization is needed here.

The "header_*" globals do not change and the "header" global is only written to in the main thread before the second thread launches. And even the "quit" global, which is used in both threads (one reading, one writing) does not need a mutex.

2
General / AW: Re: Storing Sprites In A Vector?
« on: October 26, 2014, 01:08:23 pm »


If by "references" you mean raw pointers, then also correct.  But actual references can't be copied at all, you can't even have a vector of references, etc.  So let's try not to misuse that term anymore.

He was talking about reference_wrapper before, so I guess that's what he meant. Although references (including reference_wrapper) never have ownership, so it's still irrelevant to talk about moving them.

3
Graphics / Re: Clearing only a part of a sf::RenderTexture
« on: April 23, 2012, 06:48:58 pm »
Somewhat related to the thread we had here:
http://en.sfml-dev.org/forums/index.php?topic=7427.0

Since it seems like you want to clear a rectangular shape, use the method shown by Laurent where you draw a shape with sf::Color::Transparent and sf::BlendNone.

4
Graphics / Re: Sprite Masking in SFML2
« on: April 12, 2012, 03:18:20 pm »
Just tested it and it works perfectly, thank you!

Much better and faster solution!

5
Graphics / Re: Sprite Masking in SFML2
« on: April 12, 2012, 02:45:14 pm »
Okay, this version prevents you from using a texture to cut out areas. It will remove the complete bounding box of the sprite, no matter what the texture contains (I guess due to the BlendNone thing).

I will stick to my version for now, as it seems to work fine if used sparingly. I'd like to try out the pixel shader one, but I have absolutely no clue how to write shaders.

6
Graphics / Re: Sprite Masking in SFML2
« on: April 12, 2012, 11:32:59 am »
To Laurent:
This looks interesting. I currently cannot test it, but would this approach allow for alphas between 0 and 255 to correctly make the RenderTexture's content half transparent?

To ChonDee:
They do not collide with each other. Once a particle comes to rest, I draw it onto the RenderTexture and remove it. Live particles do only collide with what's on the RenderTexture (I maintain a separate Bitfield for that). Physics themselves are just a gravity vector and a force I apply when spawning a particle. No physics engine/library behind it.

7
Graphics / Re: Sprite Masking in SFML2
« on: April 11, 2012, 02:54:06 pm »
It is actually possible. I made a small test demonstrating it:



And it works exactly like ChonDee's idea. The trick is to use a RenderTexture, draw the part you want to cut out with a specific color (in my test I draw a CircleShape in Color::Magenta), extract the underlying Texture to a Image, apply a mask and use it for a Sprite (instead of using the RenderTexture's Texture):

Code: [Select]
// renderTex is the sf::RenderTexture
// img is a sf::Image
// tex is a sf::Texture
// spr is a sf::Sprite

// Update RenderTexture
renderTex.display();

// Turn the contents with your magenta shape into an Image and apply mask
img = renderTex.getTexture().copyToImage();
img.createMaskFromColor(sf::Color::Magenta);

// Update Texture from Image
tex.loadFromImage(img);

// Update Sprite from Texture
spr.setTexture(tex);

When drawing, just draw the Sprite.
I wrapped this in a class for easy and automated usage.

It might not be very fast, so just do it when really necessary (i.e. when you updated the content).

Pages: [1]