Welcome, Guest. Please login or register. Did you miss your activation email?

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.


Messages - Geheim

Pages: 1 ... 12 13 [14]
196
Graphics / Re: Thread-Text Bug
« on: August 31, 2012, 10:52:37 pm »
Alright, thank you guys you really helped me a lot!
Keep up the good work!^^

197
Graphics / Re: Thread-Text Bug
« on: August 31, 2012, 10:29:20 am »
It is not necessary to clear a std::list explicitly if you don't need it anymore.
Thanks for the advice, I didn't know that!

Furthermore, don't terminate threads. The recommended way is to let them finish execution themselves.
Yes I know, but in my chat the threadfunction is to receive data and so it won't end until it gets a message or?
Because I tried it first with thread.wait() (like it's recommended in the tutorial), but there was something strange (I cannot exactly remember what)?

Always declare variables as late and as locally as possible :)
Again thanks for the advice! I also didn't know that ;) I'll keep it in mind and change it from now on ;)

198
Graphics / Re: Thread-Text Bug
« on: August 31, 2012, 09:31:16 am »
Hey Laurent, I tried it and it really worked! It also worked for the chat!
I gave my best to pruduce the bug, but it was gone ;)

eXpl0it3r, maybe this will also work for you as well?

Thanks Laurent you really helped me a lot! ;)
Will this be in the next update or do I have to do this after every new text?
But I don't understand exactly why this helped... The definition is: "glFlush — force execution of GL commands in finite time", so every letter is a GL command? And because of the thread the command (letter) is not getting executed immediately?

199
Graphics / Re: Thread-Text Bug
« on: August 30, 2012, 11:00:03 pm »
Yes, Laurent does a very good job!
Here is the class, i made it as less as possible!
Chat.h:
#ifndef CHAT_H
#define CHAT_H

#pragma warning(disable : 4355)         //warning C4355: this': wird in Initialisierungslisten für Basisklasse verwendet
#include <list>

class Chat
{
        private:
                sf::RenderWindow &window;
                sf::Clock &clock;
                sf::Thread writeThread;
                std::list<sf::Text> textList;
                std::list<sf::Text>::iterator iText;
                void writeData();
        public:
                Chat(sf::RenderWindow &windowGame, sf::Clock &clockGame);
                ~Chat();
                void update();
                void render();
};
#endif

Chat.cpp:
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <iostream>
#include <list>
#include "chat.h"

Chat::Chat(sf::RenderWindow &windowGame, sf::Clock &clockGame)
: window(windowGame)
, clock(clockGame)
, writeThread(&Chat::writeData, this)
{
        writeThread.launch();
}

Chat::~Chat()
{
        //Don't forget to release memory!
        textList.clear();
        writeThread.terminate();
}

void Chat::update()
{
}

void Chat::render()
{
        for(iText=textList.begin(); iText!=textList.end(); ++iText)
                window.draw((*iText));
}

void Chat::writeData()
{
        while(true)
        {
                std::string text;
                std::getline(std::cin, text);
                sf::Text tempText(text);
                tempText.setColor(sf::Color(102, 23, 123));
                tempText.setPosition(0, static_cast<float>(textList.size()*20));
                textList.push_back(tempText);
        }
}

200
Graphics / Re: Thread-Text Bug
« on: August 30, 2012, 10:39:40 pm »
Haha, yes i know ;) That's the reason I ask here, because the problem wasn't solved yet.
Your suggestion also didn't help :/
Btw welcome to the official SFML forum. :)
Thx^^ In the Spieleprogrammierer forum they recommended me to write here, so here I am.

201
Graphics / Thread-Text Bug
« on: August 30, 2012, 10:12:10 pm »
Good evening guys,
I found a bug with sf::Thread and sf::Text. It's a known bug, because I also found some topics about it, but they didn't help me out with my problem. ( http://en.sfml-dev.org/forums/index.php?topic=7730.0 or http://en.sfml-dev.org/forums/index.php?topic=2073.0 )

To the problem:
I made a chat, where the messages are shown in the window. But in nearly every message some letters are missing, or kinda buggy :/  The strange thing is, when I (or someone else) write more messages, the older messages slowly fill up (sometimes immediately): (Some pictures for better illustration) (I come from Austria, so its in german ;), but you can see it quite good I guess)


I also found out that this happens, when sf::Text is made in a sf::Thread and rendered in the main thread. The text is in a std::list and i have a sf::Thread in one class. I also wrote a simple program that pruduces the bug for me (thats the important part) (writeData is the threadfunction):
void Chat::render()
{
        for(iText=textList.begin(); iText!=textList.end(); ++iText)
                window.draw((*iText));
}

void Chat::writeData()
{
        while(true)
        {
                std::string text;
                std::getline(std::cin, text);
                sf::Text tempText(text);
                tempText.setColor(sf::Color(102, 23, 123));
                tempText.setPosition(0, static_cast<float>(textList.size()*20));
                textList.push_back(tempText);
        }
}

In my chat I use a font called "french grotesque" (http://www.dafont.com/french-grotesque.font)
I also tried out other fonts and the default font, but nothing really helped...
Maybe someone knows how to fix this bug, because it's really annoying, espiacially in a chat ;)
Greetings Geheim!

Pages: 1 ... 12 13 [14]