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.
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 MenuQuote from: texus on 28 July 2013, 14:40:22
Are you by any chance using c++11?
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.
#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;
}
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 ===|
Quote from: texus on 13 July 2013, 22:03:26
Do you have v0.5.2?
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));
}
}
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);
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));
}
}