window flickering in macOs
« on: 15 March 2014, 13:03:09 »
I just updated my XCode to final release of 5.1.

And I have a problem with tgui, probably gui.draw() is not working or it might be something else.  Code i am about to post works great on linux. Here i get window flickering, which shouldn't happen.

main.cpp:
Code: [Select]
#include <TGUI/TGUI.hpp>


#include "loginScreen.hpp"

// Here is a small helper for you ! Have a look.
#include "ResourcePath.hpp"

int main(int, char const**)
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    tgui::Gui gui(window);
   
    gui.setGlobalFont("Data/Fonts/DejaVuSans.ttf");
    loginScreen(gui);
   
    gui.get("loginScreen")->show();
   
    // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        while (window.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed) {
                window.close();
            }

            // Espace pressed : exit
            if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
                window.close();
            }
           
            gui.handleEvent(event);
        }
       
        tgui::Callback callback;
        while (gui.pollCallback(callback))
        {
            // Make sure that callback comes from the button
            if (callback.id == 1) // login button
            {
            }
        }

        // Clear screen
        window.clear();
       
        gui.draw();


        // Update the window
        window.display();
    }
   
    return EXIT_SUCCESS;
}

loginScreen.hpp:
Code: [Select]
#ifndef fml_test_loginScreen_hpp
#define fml_test_loginScreen_hpp

void loginScreen( tgui::Gui& gui )
{
   
    tgui::Panel::Ptr loginScreen(gui, "loginScreen");
    loginScreen->setSize(800, 600);
   
    // Create the background image
    tgui::Picture::Ptr picture(*loginScreen);
    picture->load("Data/Backgrounds/loginBackground.tex");
    picture->setSize(800, 600);

   
    tgui::Button::Ptr jebise(*loginScreen);
    jebise->load("Data/Buttons/Black.conf");
    jebise->setSize(80,25);
    jebise->setText("Tuck off");
    jebise->setPosition(100, 100);
    jebise->bindCallback(tgui::Button::LeftMouseClicked);
    jebise->setCallbackId(1);
   
}
#endif


only output i get in terminal is:
Code: [Select]
objc[2442]: Class SFApplication is implemented in both /Library/Frameworks/sfml-window.framework/Versions/2.1.0/sfml-window and /Users/cola/Desktop/fml test/Debug/fml test.app/Contents/Frameworks/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[2442]: Class SFOpenGLView is implemented in both /Library/Frameworks/sfml-window.framework/Versions/2.1.0/sfml-window and /Users/cola/Desktop/fml test/Debug/fml test.app/Contents/Frameworks/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[2442]: Class SFSilentResponder is implemented in both /Library/Frameworks/sfml-window.framework/Versions/2.1.0/sfml-window and /Users/cola/Desktop/fml test/Debug/fml test.app/Contents/Frameworks/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[2442]: Class SFWindow is implemented in both /Library/Frameworks/sfml-window.framework/Versions/2.1.0/sfml-window and /Users/cola/Desktop/fml test/Debug/fml test.app/Contents/Frameworks/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[2442]: Class SFWindowController is implemented in both /Library/Frameworks/sfml-window.framework/Versions/2.1.0/sfml-window and /Users/cola/Desktop/fml test/Debug/fml test.app/Contents/Frameworks/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
objc[2442]: Class SFViewController is implemented in both /Library/Frameworks/sfml-window.framework/Versions/2.1.0/sfml-window and /Users/cola/Desktop/fml test/Debug/fml test.app/Contents/Frameworks/libsfml-window.2.dylib. One of the two will be used. Which one is undefined.
Segmentation fault: 11


Just sfml code without tGui works great.
EDIT: i just updated tGui to 0.6.2, i have same problem.
« Last Edit: 15 March 2014, 13:27:59 by ColaGGS »

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: window flickering in macOs
« Reply #1 on: 15 March 2014, 14:21:36 »
What exactly do you mean with "window flickering"?

I just tested and I didn't have any problems. I didn't even get that terminal output.

I only changed a few things, as your code didn't work out-of-the-box.
Code: [Select]
picture->load("Data/Backgrounds/loginBackground.tex");First of all, I used the cute_image.jpg as image instead (as you didn't provide that tex file).
But I had to write the following, becuase otherwise it wouldn't search for it in the correct directory:
Code: [Select]
picture->load(resourcePath() + "cute_image.jpg");Same thing for the other load functions.

Did you use the sfml template for your xcode project?


Edit:
I didn't really look close enough at the console output when writing the post.
It looks like you are linking to both the dylibs and the framework of sfml.
« Last Edit: 15 March 2014, 14:23:17 by texus »

Re: window flickering in macOs
« Reply #2 on: 15 March 2014, 14:33:28 »
I'm using SFML template when i create a project, here's flags that xcode uses
Code: [Select]
-lsfml-system
-lsfml-window
-lsfml-graphics
-lsfml-audio
-lsfml-network
-ltgui
When I created the project instead of using frameworks i told it to use dylibs.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: window flickering in macOs
« Reply #3 on: 15 March 2014, 14:35:52 »
I just let it use frameworks and then only add -ltgui myself.

I'll have a look at what happens when I use dylibs.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: window flickering in macOs
« Reply #4 on: 15 March 2014, 14:42:24 »
Ok, I get the flickering too now.

So for some reason you will have to use the sfml framework with tgui, not the dylibs. This might be because the tgui libraries are compiled against the sfml framework.

But I don't have time to look into this in detail right now, so I'll just add a notice in the tutorial about this.

Re: window flickering in macOs
« Reply #5 on: 15 March 2014, 14:45:20 »
Ok, cuz last time, in 5.0 we had problems with framework, and now its the other way around. K i'll give it a try

Re: window flickering in macOs
« Reply #6 on: 15 March 2014, 15:33:50 »
Thanks, need to figure out SFML, waiting for their response to help me with frameworks. I'll post an update once I sort SFML.

Re: window flickering in macOs
« Reply #7 on: 16 March 2014, 12:28:17 »
Sorry I have to ask you this, but I got no reply on SFML. Share me your secret how did you get frameworks to work, i checked shared_libs and build frameworks in cmake and compiled it. I probably messed up somewhere. :P

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: window flickering in macOs
« Reply #8 on: 16 March 2014, 12:34:12 »
Its been a while since I installed sfml on my mac.

Did you download the "Templates for Xcode 5" from the sfml download page?

Quote
clang: error: unknown argument: '-frameworksfml-system' [-Wunused-command-line-argument-hard-error-in-future]
I think the mistake is just that there should be a space, so it should be  '-framework sfml-system'.

Re: window flickering in macOs
« Reply #9 on: 16 March 2014, 12:36:04 »
yep i did, but i'll do it again, since I updated XCode so i'll give it a try. And I'll keep doing what i can :)
And that did the trick. It never crossed my mind that i might have overwritten it when i tired install.sh or that new XCode might messed it up after install/upgrade from DP2. Thanks!
« Last Edit: 16 March 2014, 12:43:03 by ColaGGS »

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: window flickering in macOs
« Reply #10 on: 16 March 2014, 12:44:40 »
Quote
i checked shared_libs and build frameworks in cmake and compiled it
I don't even think that I compiled sfml myself. I just downloaded sfml 2.1 and used the install.sh script. (after running the install script you should install the correct template for xcode 5, because it installs the old template).

Edit: Ignore this post, I hadn't seen your edit yet