What would be the best way to make a friends list using TGUI objects? We need interactable buttons for each name.
This is the design:
This is the design:
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 17 August 2013, 11:57:55
I found the issue.
You were linking to the static sfml libraries, but to the dynamic tgui libraries. This isn't possible (because tgui uses the SFML_STATIC as well). I am very surprised that this is even possible, I would have expected tons of errors or warnings in this situation.
So if you link to tgui-s.lib instead of tgui.lib then the problem should go away.
Quote from: texus on 16 August 2013, 22:59:28
Ok, could you send me everything needed to reproduce this?
The source code, executable, images u use, even the compiled sfml and tgui libraries.
I want to test this with the exact same resources.
int main ( int argc, char *argv[] )
{
// Create a new render-window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
//tgui::Form form(window);
// Create a new render-texture
sf::RenderTexture texture;
if (!texture.create(800, 600))
return -1;
// Create a textured vertex array
sf::VertexArray va;
va.resize(4);
va.setPrimitiveType(sf::Quads);
va[0].position = sf::Vector2f(0, 0);
va[1].position = sf::Vector2f(0, 600);
va[2].position = sf::Vector2f(800, 600);
va[3].position = sf::Vector2f(800, 0);
va[0].texCoords = sf::Vector2f(0, 0);
va[1].texCoords = sf::Vector2f(0, 459);
va[2].texCoords = sf::Vector2f(624, 459);
va[3].texCoords = sf::Vector2f(624, 0);
sf::Texture vatex;
vatex.loadFromFile("rsc/sprites.png");
// Add GUI elements
//tgui::Button* button = form.add<tgui::Button>();
//button->load("rsc/GUI/Button");
//button->setPosition(100, 100);
//button->setText("Hello World");
//button->callbackID = 1;
//button->show();
// The main loop
while (window.isOpen())
{
// Event handling
sf::Event Event;
while (window.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
window.close();
//form.handleEvent(Event);
}
//tgui::Callback callback;
//while(form.getCallback(callback))
//{
//if((callback.callbackID == 1))
//std::cout << "pressed\n";
//}
// Clear the whole texture with red color
texture.clear(sf::Color::Red);
// Draw stuff to the texture
texture.draw(va, &vatex);
// We're done drawing to the texture
texture.display();
// Now we start rendering to the window, clear it first
window.clear();
// Draw the texture
sf::Sprite sprite(texture.getTexture());
window.draw(sprite);
//form.draw();
// End the current frame and display its contents on screen
window.display();
}
return 0;
}
int main ( int argc, char *argv[] )
{
// Create a new render-window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
tgui::Form form(window);
// Create a new render-texture
sf::RenderTexture texture;
if (!texture.create(800, 600))
return -1;
// Create a textured vertex array
sf::VertexArray va;
va.resize(4);
va.setPrimitiveType(sf::Quads);
va[0].position = sf::Vector2f(0, 0);
va[1].position = sf::Vector2f(0, 600);
va[2].position = sf::Vector2f(800, 600);
va[3].position = sf::Vector2f(800, 0);
va[0].texCoords = sf::Vector2f(0, 0);
va[1].texCoords = sf::Vector2f(0, 459);
va[2].texCoords = sf::Vector2f(624, 459);
va[3].texCoords = sf::Vector2f(624, 0);
sf::Texture vatex;
vatex.loadFromFile("rsc/sprites.png");
// Add GUI elements
tgui::Button* button = form.add<tgui::Button>();
button->load("rsc/GUI/Button");
button->setPosition(100, 100);
button->setText("Hello World");
button->callbackID = 1;
button->show();
// The main loop
while (window.isOpen())
{
// Event handling
sf::Event Event;
while (window.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
window.close();
//form.handleEvent(Event);
}
tgui::Callback callback;
while(form.getCallback(callback))
{
if((callback.callbackID == 1))
std::cout << "pressed\n";
}
// Clear the whole texture with red color
texture.clear(sf::Color::Red);
// Draw stuff to the texture
texture.draw(va, &vatex);
// We're done drawing to the texture
texture.display();
// Now we start rendering to the window, clear it first
window.clear();
// Draw the texture
sf::Sprite sprite(texture.getTexture());
window.draw(sprite);
//form.draw();
// End the current frame and display its contents on screen
window.display();
}
return 0;
}
int main ( int argc, char *argv[] )
{
// Create a new render-window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
tgui::Form form(window);
// Create a new render-texture
sf::RenderTexture texture;
if (!texture.create(800, 600))
return -1;
// Create a textured vertex array
sf::VertexArray va;
va.resize(4);
va.setPrimitiveType(sf::Quads);
va[0].position = sf::Vector2f(0, 0);
va[1].position = sf::Vector2f(0, 600);
va[2].position = sf::Vector2f(800, 600);
va[3].position = sf::Vector2f(800, 0);
va[0].texCoords = sf::Vector2f(0, 0);
va[1].texCoords = sf::Vector2f(0, 459);
va[2].texCoords = sf::Vector2f(624, 459);
va[3].texCoords = sf::Vector2f(624, 0);
sf::Texture vatex;
vatex.loadFromFile("rsc/sprites.png");
// Add GUI elements
tgui::Button* button = form.add<tgui::Button>();
button->load("rsc/GUI/Button");
button->setPosition(100, 100);
button->setText("Hello World");
button->callbackID = 1;
button->show();
// The main loop
while (window.isOpen())
{
// Event handling
sf::Event Event;
while (window.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
window.close();
//form.handleEvent(Event);
}
tgui::Callback callback;
while(form.getCallback(callback))
{
if((callback.callbackID == 1))
std::cout << "pressed\n";
}
// Clear the whole texture with red color
texture.clear(sf::Color::Red);
// Draw stuff to the texture
texture.draw(va, &vatex);
// We're done drawing to the texture
texture.display();
// Now we start rendering to the window, clear it first
window.clear();
// Draw the texture
sf::Sprite sprite(texture.getTexture());
window.draw(sprite);
form.draw();
// End the current frame and display its contents on screen
window.display();
}
return 0;
}
Quote from: texus on 16 August 2013, 09:35:37
But you are definately not running the latest tgui and sfml versions.
You are passing a pointer to the Form constructor, I changed it to a reference on 21 August.
You should try again with TGUI v0.5.2 and SFML 2.1.
#include <fstream>
#include <iostream>
#include <string>
#include <TGUI\TGUI.hpp>
int main ( int argc, char *argv[] )
{
// Create a new render-window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
tgui::Form form(&window);
// Create a new render-texture
sf::RenderTexture texture;
if (!texture.create(800, 600))
return -1;
// Create a textured vertex array
sf::VertexArray va;
va.resize(4);
va.setPrimitiveType(sf::Quads);
va[0].position = sf::Vector2f(0, 0);
va[1].position = sf::Vector2f(0, 600);
va[2].position = sf::Vector2f(800, 600);
va[3].position = sf::Vector2f(800, 0);
va[0].texCoords = sf::Vector2f(0, 0);
va[1].texCoords = sf::Vector2f(0, 384);
va[2].texCoords = sf::Vector2f(224, 384);
va[3].texCoords = sf::Vector2f(224, 0);
sf::Texture vatex;
vatex.loadFromFile("rsc/sprites.png");
// Add GUI elements
tgui::Button* button = form.add<tgui::Button>();
button->load("rsc/GUI/Button");
button->setPosition(100, 100);
button->setText("Hello World");
button->callbackID = 1;
button->show();
// The main loop
while (window.isOpen())
{
// Event handling
sf::Event Event;
while (window.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
window.close();
form.handleEvent(Event);
}
tgui::Callback callback;
while(form.getCallback(callback))
{
if((callback.callbackID == 1))
std::cout << "pressed\n";
}
// Clear the whole texture with red color
texture.clear(sf::Color::Red);
// Draw stuff to the texture
texture.draw(va, &vatex);
// We're done drawing to the texture
texture.display();
// Now we start rendering to the window, clear it first
window.clear();
// Draw the texture
sf::Sprite sprite(texture.getTexture());
window.draw(sprite);
form.draw();
// End the current frame and display its contents on screen
window.display();
}
return 0;
}
#include <fstream>
#include <iostream>
#include <string>
#include <TGUI\TGUI.hpp>
#include <fstream>
#include <iostream>
#include <string>
#include <TGUI\TGUI.hpp>
int main ( int argc, char *argv[] )
{
// Create a new render-window
tgui::Window window(sf::VideoMode(800, 600), "SFML window");
// Create a new render-texture
sf::RenderTexture texture;
if (!texture.create(800, 600))
return -1;
// Create a textured vertex array
sf::VertexArray va;
va.resize(4);
va.setPrimitiveType(sf::Quads);
va[0].position = sf::Vector2f(0, 0);
va[1].position = sf::Vector2f(0, 600);
va[2].position = sf::Vector2f(800, 600);
va[3].position = sf::Vector2f(800, 0);
va[0].texCoords = sf::Vector2f(0, 0);
va[1].texCoords = sf::Vector2f(0, 384);
va[2].texCoords = sf::Vector2f(224, 384);
va[3].texCoords = sf::Vector2f(224, 0);
sf::Texture vatex;
vatex.loadFromFile("rsc/sprites.png");
// The main loop
while (window.isOpen())
{
// Event handling
sf::Event Event;
while (window.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
window.close();
}
// Clear the whole texture with red color
texture.clear(sf::Color::Red);
// Draw stuff to the texture
texture.draw(va, &vatex);
// We're done drawing to the texture
texture.display();
// Now we start rendering to the window, clear it first
window.clear();
// Draw the texture
sf::Sprite sprite(texture.getTexture());
window.draw(sprite);
// End the current frame and display its contents on screen
window.display();
}
return 0;
}
Quote from: texus on 15 August 2013, 23:15:11
I don't even see how it is technically possible that it works with sf::RenderWindow but not with tgui::Window.
tgui::Window just inherits from sf::RenderWindow.