SFML community forums

Help => Graphics => Topic started by: achpile on November 13, 2017, 03:58:50 pm

Title: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 13, 2017, 03:58:50 pm
Hey guys! I have some troubles with clearing render textures (or may be RenderWindow). And made some investigations. Here's the code:

#include "include/SFML/Graphics.hpp"

int main() {
        sf::RenderWindow app(sf::VideoMode(400,400), "test");
        sf::RectangleShape a(sf::Vector2f(10,10)), b(sf::Vector2f(1,1));

        sf::RenderTexture tex;
        sf::Sprite spr;

        tex.create(400,400);
        tex.setActive();
        tex.clear(sf::Color(0,0,0,0));
        int pos = 10;
        spr.setTexture(tex.getTexture());

        while (app.isOpen()) {
                sf::Event event;
                while (app.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)
                                app.close();
                }

                pos += 1;
                a.setPosition(sf::Vector2f(pos, 10));

                app.clear();

                // Uncomment this to fix
                //app.draw(b);

                tex.draw(a);
                tex.display();
                app.draw(spr);

                tex.clear();
                app.display();
        }
}

 

If there's no draw calls on RenderWindow except the one with drawing RenderTexture it leads to some artifacts.
I attached the image from my game and from the example. As you can see - there's kinda trail, but it is not the same as without "clear" call.

And there were no such issues before High Sierra update.
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: eXpl0it3r on November 13, 2017, 04:08:35 pm
See issue #1132 (https://github.com/SFML/SFML/issues/1132) and test branch bugfix/osx_render_target (https://github.com/SFML/SFML/tree/bugfix/osx_render_target).
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 13, 2017, 04:10:26 pm
thanks for reply, Lukas :) i'll try tomorrow (have no own mac, so use one from my work)
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 14, 2017, 10:11:39 am
I tried this patch on sfml 2.4.1 - it doesn't help, everything is the same.

I tried to compile branch bugfix/osx_render_target, but got this on compiling my project (i had no such issue with 2.4.1, that's why tested this patch on this version)

Undefined symbols for architecture x86_64:
  "sf::String::String(char const*, std::__1::locale const&)", referenced from:
 

Used simple "cmake . && make" to compile.
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 14, 2017, 10:27:15 am
Tried night build from here https://www.sfml-dev.org/artifacts/by-branch/bugfix/osx_render_target/
 got same linker error
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: Hiura on November 14, 2017, 10:56:54 am
make sure you're compiling your project and SFML with the same standard library.
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 14, 2017, 10:59:15 am
make sure you're compiling your project and SFML with the same standard library.

but why I can compile 2.4.1 and it works. i can use precompiled 2.4.2, 2.4.1 and it works. but it fails if i use precompiled nightly build or compile that branch by myself?
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 14, 2017, 11:02:10 am
PS: i guess i compile it with same standart libraries, because i do not specify it
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: Hiura on November 14, 2017, 11:06:45 am
I don't know what you mean by "precompile", but this error is most likely due to a mismatch in standard library used to compile your project and SFML. The nightly build are compiled with libstdc++ at the moment but the official release are compiled with libc++. Don't mix those two or you'll get such linker errors.
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 14, 2017, 11:09:03 am
I don't know what you mean by "precompile", but this error is most likely due to a mismatch in standard library used to compile your project and SFML. The nightly build are compiled with libstdc++ at the moment but the official release are compiled with libc++. Don't mix those two or you'll get such linker errors.

oh, sorry, not precompiled. i meant compiled binaries  :) how can i build it with libc++ instead of libstdc++?
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: Hiura on November 14, 2017, 11:12:03 am
have a look at the options presented in §C++11 and Mac OS X of https://www.sfml-dev.org/tutorials/2.4/compile-with-cmake.php.
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 14, 2017, 01:13:27 pm
have a look at the options presented in §C++11 and Mac OS X of https://www.sfml-dev.org/tutorials/2.4/compile-with-cmake.php.

thanks, that works  :)

but, unfortunately issue still exists and this branch didn't helped.

also why clang and libc++ isn't set as default in CMake?  :)
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: Hiura on November 14, 2017, 03:08:04 pm
also why clang and libc++ isn't set as default in CMake?  :)

'Cause I haven't got around creating a PR for that. If you want to do it, your help is more than welcomed!
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 14, 2017, 03:10:46 pm
also why clang and libc++ isn't set as default in CMake?  :)

'Cause I haven't got around creating a PR for that. If you want to do it, your help is more than welcomed!

Sorry, i'm not familiar with Mac OS at all and i'm afraid to do something wrong.

And about the issue - may be if someone familiar with OpenGL debugging could get trace of my example with and without the line i specified - it possibly help with fixing that  :)
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: Hiura on November 22, 2017, 03:58:48 pm
I tried to reproduce this issue on my laptop but couldn't. Since I haven't upgraded to High Sierra yet, I also tested in a VM but still couldn't reproduce the issue.

Now, using a VM is far from perfect to test such things, but it would be great if this bug could be reproduced by someone else using similar hardware as you do.

BTW, (if there's a bug) I'm not sure it's the same bug as #1132; the symptoms look too different.
Title: Re: Mac OS X - High Sierra - RenderTexture::clear
Post by: achpile on November 22, 2017, 04:09:44 pm
I tried to reproduce this issue on my laptop but couldn't. Since I haven't upgraded to High Sierra yet, I also tested in a VM but still couldn't reproduce the issue.

Now, using a VM is far from perfect to test such things, but it would be great if this bug could be reproduced by someone else using similar hardware as you do.

BTW, (if there's a bug) I'm not sure it's the same bug as #1132; the symptoms look too different.

Thanks for your time :) Laptop is "Pro Mid 2014" as I know.
Yeah, probably app will work fine on other configurations, but I made drawing black square just for sure  :)