window flickering in macOs

Started by ColaGGS, 15 March 2014, 13:03:09

ColaGGS

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:

#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:

#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:

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.

texus

#1
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.
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:
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.

ColaGGS

I'm using SFML template when i create a project, here's flags that xcode uses

-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

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

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.

ColaGGS

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

ColaGGS

Thanks, need to figure out SFML, waiting for their response to help me with frameworks. I'll post an update once I sort SFML.

ColaGGS

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

Its been a while since I installed sfml on my mac.

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

Quoteclang: 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'.

ColaGGS

#9
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!

texus

Quotei 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