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 - andywood

Pages: [1]
Graphics / Re: Rendering problem with RenderTexture.getTexture()
« on: June 19, 2016, 02:36:23 am »
Cool! Mystery solved. Thank you.

Graphics / Re: Rendering problem with RenderTexture.getTexture()
« on: June 19, 2016, 01:56:53 am »
According to my theory, your code works because you always draw the same thing into rt1. If you draw something different in rt1 on each iteration, then I suspect that upon rt2.display(), rt2 will be covered in whatever the last thing you drew into rt1, rather than what was in rt1 at the time of each call to rt2.draw().

Graphics / Re: Broken TexCoords when zooming sf::View
« on: June 19, 2016, 12:14:51 am »
I'm not sure if this is the most correct solution, but I've solved this problem by making the tiles slightly larger than my desired tile size by a fixed, tiny amount.

Graphics / Re: Rendering problem with RenderTexture.getTexture()
« on: June 18, 2016, 11:59:51 pm »
After much experimenting, I think that maybe I understand what's happening here. Maybe someone can confirm. This is slightly unexpected, but I can understand if this is the way it works. First, an expanded outline of what I'm doing:

sf::RenderTexture finalTexture;
finalTexture.create(32, 32);

sf::RenderTexture tempTexture;
tempTexture.create(16, 16);

for (int i = 0; i < 4; ++i)
    // draw varied stuff in tempTexture here

    sf::Sprite sprite(tempTexture.getTexture());    // sf::Sprite sprite(sf::Texture(tempTexture.getTexture())); here would fix the problem
    sprite.setPosition((i % 2) * 16, (i / 2) * 16);

    // alternately, finalTexture.display(); here would also fix the problem


So, I am guessing that finalTexture.draw() is actually deferred until finalTexture.display(). Whatever command-list kind of system is used for the deferral, it must store a reference to tempTexture's texture, rather than a copy of its contents at the time the draw call happened. This is why explicitly making copies of tempTexture's texture solves the problem, but also forcing the draw to happen each iteration also solves the problem.

Is this right?

Graphics / Re: Rendering problem with RenderTexture.getTexture()
« on: June 18, 2016, 07:10:55 am »
Am definitely doing that, before the getTexture().

Graphics / Rendering problem with RenderTexture.getTexture()
« on: June 18, 2016, 02:41:43 am »
I have code like this:

sf::Sprite sprite(myRenderTexture.getTexture());

It renders incorrectly. I'm not sure where the bits are coming from, but it's drawing the wrong bits. However if I simply introduce one intermediate texture:

sf::Texture texture = myRenderTexture.getTexture();
sf::Sprite sprite(texture);

Then it renders correctly. The second version is acceptable, but the seemingly needless copy is bothering me. It also makes me think there is something going on in SFML that I don't understand. Also, there is another part in my code (the rendering of the main surface to the window, in fact) that works like the first example, and it's fine. I've rearranged things a few different ways and made sure object lifetime isn't an issue, but every time I remove that texture copy, I get the same bad render (the bad result is always the same, not random).

Pages: [1]