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

Author Topic: Mac OS X - High Sierra - RenderTexture::clear  (Read 6695 times)

0 Members and 1 Guest are viewing this topic.

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Mac OS X - High Sierra - RenderTexture::clear
« 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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #1 on: November 13, 2017, 04:08:35 pm »
See issue #1132 and test branch bugfix/osx_render_target.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #2 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)

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #3 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.


Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #5 on: November 14, 2017, 10:56:54 am »
make sure you're compiling your project and SFML with the same standard library.
SFML / OS X developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #6 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?

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #7 on: November 14, 2017, 11:02:10 am »
PS: i guess i compile it with same standart libraries, because i do not specify it

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #8 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.
SFML / OS X developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #9 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++?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #10 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.
SFML / OS X developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #11 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?  :)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #12 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!
SFML / OS X developer

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #13 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  :)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac OS X - High Sierra - RenderTexture::clear
« Reply #14 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.
SFML / OS X developer

 

anything