Main Menu
Menu

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.

Show posts Menu

Messages - Jimmyee

#1
Quote from: texus on 28 July 2013, 14:40:22
Are you by any chance using c++11?

Yeah I do... And I didn't read the whole tutorial. Thank you for the information. Next time I'll read everything.

EDIT: It works now.
#2
QuoteAre you still using the exact same code as above with only the button->load line changed?
I will paste the code I'm using now.

#include <TGUI/TGUI.hpp>

int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);

    // Load the font (you should check the return value to make sure that it is loaded)
    gui.setGlobalFont("gfx/fonts/DejaVuSans.ttf");

    tgui::Button::Ptr button(gui, "btnTileset");
    if(!button->load("gfx/gui/widgets/BabyBlue.conf"))
    {
        puts("Could not load button graphics!");
    }
    button->setText("Tileset");
    button->setSize(100, 50);
    button->setPosition(50, 50);

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

            // Pass the event to all the widgets (if there would be widgets)
            gui.handleEvent(event);
        }

        tgui::Callback callback;
        while (gui.pollCallback(callback))
        {
        }

        window.clear();

        // Draw all created widgets
        gui.draw();

        window.display();
    }

    return EXIT_SUCCESS;
}


QuoteWhat does the load function return, true of false?
It returns true for me (it doesn't display the error message).

QuoteDid you copy the widgets folder from tgui as-is, without changing any files?
Yep... I didn't change anything there.

QuoteYou could also try loading Black.conf instead and see if it gives the same result.
I'll try but first I wanna show you something.
There is an app crash when I close the window. After debugging I get this:


EDIT: using Black.conf it works the same way like with BabyBlue.conf
#3
Thank you for the answer! The problem seems to be solved but I still see just a black screen...
#4
Can you tell me how you did it? I got the same problem.
#5
Hello. I was trying to compile this code:

#include <TGUI/TGUI.hpp>

int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);

    // Load the font (you should check the return value to make sure that it is loaded)
    gui.setGlobalFont("fonts/DejaVuSans.ttf");

    tgui::Button::Ptr button(gui, "btnTileset");
    button->load("widgets/Button/BabyBlue");
    button->setText("Tileset");
    button->setSize(80, 20);
    button->setPosition(4, 4);

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

            // Pass the event to all the widgets (if there would be widgets)
            gui.handleEvent(event);
        }

        window.clear();

        // Draw all created widgets
        gui.draw();

        window.display();
    }

    return EXIT_SUCCESS;
}


The "widgets" and "fonts" folders are in the same folder as the app is. What might be the problem?
This is TGUI v0.6 of course.
#6
Help requests / Re: Child window and controls
28 July 2013, 00:04:55
Oh OK. I think I'm using depreciated version because Button::Ptr doesn't exit for me. I guess I should update to v0.6 ;) Thank you.
#7
Help requests / Child window and controls
27 July 2013, 23:35:54
How can I add controls to a child window and handle them? It seems different than it is done in the main GUI window...
#8
Help requests / Re: Problem with TGUI basics
14 July 2013, 01:25:51
I have pasted the whole example code to the main.cpp file.
I get this error: "E:\code\SFML Test 2\src\main.cpp|50|error: 'setPosition' was not declared in this scope|"
It is about this line:
"checkbox-setPosition(20, 50);"

EDIT: nevermind, it was "-" instead of "->".

EDIT: I got the code compiled and it works O.o I'll try to find what did I do wrong...

EDIT: I found the cause. I was using the window object declared in the Game class instead of the tgui::Window object and it was just using the uninitialized/unused window object... Anyways, thanks for all your help and your time. Peace!
#9
Help requests / Re: Problem with TGUI basics
13 July 2013, 23:36:46
Well. I've compiled it and... still the same problem. BLACK SCREEN.
#10
Help requests / Re: Problem with TGUI basics
13 July 2013, 23:25:15
Thank you for your help but when I use libtgui-s I get bunch of linker errors:
Quote
||=== SFML Test 2, Release ===|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getString() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getString() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getGlobalBounds() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setFont(sf::Font const&)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getString() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getString() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setString(sf::String const&)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setCharacterSize(unsigned int)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getCharacterSize() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getLocalBounds() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setCharacterSize(unsigned int)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getGlobalBounds() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getGlobalBounds() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setCharacterSize(unsigned int)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getCharacterSize() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getLocalBounds() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setColor(sf::Color const&)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| more undefined references to `vtable for sf::Text' follow|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::Text()'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setColor(sf::Color const&)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getCharacterSize() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getColor() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setColor(sf::Color const&)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::getFont() const'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setFont(sf::Font const&)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp|| undefined reference to `sf::Text::setCharacterSize(unsigned int)'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp:(.text$_ZN2sf4TextD1Ev[__ZN2sf4TextD1Ev]+0x3e)||undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Button.cpp.obj):Button.cpp:(.text$_ZN2sf4TextD1Ev[__ZN2sf4TextD1Ev]+0x45)||undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setFont(sf::Font const&)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setColor(sf::Color const&)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setString(sf::String const&)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setCharacterSize(unsigned int)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::getCharacterSize() const'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::getLocalBounds() const'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setCharacterSize(unsigned int)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setCharacterSize(unsigned int)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setString(sf::String const&)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::getLocalBounds() const'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setString(sf::String const&)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::getLocalBounds() const'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::Text()'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `vtable for sf::Text'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::setString(sf::String const&)'|
E:\code\TGUI\lib\libtgui-s.a(Tab.cpp.obj):Tab.cpp|| undefined reference to `sf::Text::getLocalBounds() const'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|

I think it's something with compatibility Should I compile TGUI myself?
#11
Help requests / Re: Problem with TGUI basics
13 July 2013, 22:05:26
Quote from: texus on 13 July 2013, 22:03:26
Do you have v0.5.2?

"TGUI v0.5.2 (with precompiled MinGW-4.7.1-TDM libraries)"

EDIT: I will make a simple program and test it without my game engine. I'll let you know hows it going.

EDIT: I compiled this and there's still black screen (it's from https://tgui.eu/example-code/v05/ example):


void run()
{
    // The window is created like you would create a sf::RenderWindow.
    tgui::Window window(sf::VideoMode(800, 600), "TGUI v0.5");

    // Set the font for all the objects.
    if (window.globalFont.loadFromFile("gfx/fonts/DejaVuSans.ttf") == false)
    {
       // Error
    }

    // In the init function the objects will be created
    tgui::Button* button = tguiWindow.add<tgui::Button>();
    button->load("gfx/gui/objects/Button/Black");
    button->setText("Button 1");
    button->setSize(160, 40);
    button->setPosition(20, 4);

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

            // The events must be passed to TGUI in order to make the objects work
            window.handleEvent(event);
        }

        tgui::Callback callback;
        while (window.getCallback(callback))
        {
            if (callback.callbackID == 1)
            {

            }
        }

        window.clear();

        window.drawGUI();

        window.display();

        sf::sleep(sf::milliseconds(1));
    }
}


EDIT: maybe it's something with the libraries I'm using?
Check this:


EDIT: I've checked the path for graphics and it's correct. No more ideas at this moment \:
#12
Help requests / Re: Problem with TGUI basics
13 July 2013, 21:18:40
I was testing the game with tgui::Form instead of tgui::Window and the screen was black then. Also, the game works fine without the tgui code.
If you want, I can write a simple code working the same way as the game does and I'll post it here. Maybe it will give you more hints...

EDIT: the black screen appears when I add a button to the form. May it be a problem with the TGUI graphics? I'll check them twice.

EDIT2: I have no idea. This is how I add the button:

tgui::Button* button = tguiWindow.add<tgui::Button>();
    button->load("gfx/gui/objects/Button/Black"); // the game draws fine when I remove this line
    //button->setText("Button 1");
    button->setSize(160, 40);
    button->setPosition(20, 4);
#13
Help requests / Problem with TGUI basics
13 July 2013, 20:44:20
Hello. I'm Jimmyee.
I just downloaded TGUI 0.5 and I am trying to compile my game using tgui::window. Seems like everything works fine but nothing is being drawn. There is just a white screen.
I use tdm-gcc-4.7.1-2.

This is my code:

void Game::init()
{
    int fps = v_conv::to_int(config["FPS"]);
    std::string fullscreen = config["Fullscreen"];

    if(fullscreen == "yes")
        window.create(sf::VideoMode(800, 600), "Lucyferian", sf::Style::Close | sf::Style::Titlebar | sf::Style::Fullscreen);
    else
        window.create(sf::VideoMode(800, 600), "Lucyferian", sf::Style::Close | sf::Style::Titlebar);
    window.setVerticalSyncEnabled(true);
    window.setFramerateLimit(fps);

    window.globalFont.loadFromFile("DejaVuSans.ttf");

    gfxLoader = std::shared_ptr<GFXLoader>(new GFXLoader("gfx/"));

    sgui.setTexture(gfxLoader->dir["gui/"].tex[0]);
    sgui.setPosition(0.0f, 0.0f);

    tileset[0].load(gfxLoader, 1);
    tileset[1].load(gfxLoader, 1);
}

Game::Game()
: config("config.ini")
, state(State::Run)
, minimap(false)
{
    init();
}

void Game::handleEvents()
{
    sf::Event event;
    while(window.pollEvent(event))
    {
        handleEvent(event);
        window.handleEvent(event);
    }

    realTimeKeyboardInput();

    tgui::Callback callback;
    while (window.getCallback(callback))
    {
        // here tgui events are handled
    }
}

void Game::draw()
{
    window.clear(sf::Color(0, 0, 0, 255));

    if(map.get())
    {
        window.draw(*map);
        if(minimap)
        {
            sf::RectangleShape rectangle(sf::Vector2f(240, 180));
            rectangle.setFillColor(sf::Color::Black);
            rectangle.setOutlineThickness(1);
            rectangle.setOutlineColor(sf::Color::White);
            rectangle.setPosition(440, 0);
            window.draw(rectangle);

            sf::View transformed_map(sf::FloatRect(0, 0, 800, 600));
            transformed_map.setCenter(((21/2)*32) - 16, ((16/2)*32) + 16);
            transformed_map.setViewport(sf::FloatRect(0.55f, 0, 0.3f, 0.3f));
            transformed_map.zoom(1.5);
            window.setView(transformed_map);
            window.draw(*map.get());
            window.setView(window.getDefaultView());
        }

        if(tileset[1].enabled)
        {
            tileset[1].draw(window);
        }
    }

    window.drawGUI();
    window.display();
}

void Game::run()
{
    MapFile mf("data/maps/testmap.map");
    map = std::shared_ptr<MapRender>(new MapRender(mf, (*this)));
    me = std::shared_ptr<Character>(new Character(*this, 0, 0));
    me->x = map->mapFile.width/2;
    me->y = map->mapFile.height/2;
    me->speed = 4;
    map->addObject(me);
    printf("Player speed: %i\n", me->speed);

    map->update();

    sf::Clock clock;
    while(this->window.isOpen())
    {
        handleEvents();
        sf::Time elapsed = clock.restart();
        process(elapsed);
        draw();
        sf::sleep(sf::milliseconds(5));
    }
}


I can't find the problem but maybe you will. Thanks in advance.