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.


Topics - eXpl0it3r

Pages: 1 ... 4 5 [6]
76
I just got this idea, although I'm not sure if it could get annoying or if it's even possible to implement (in a simple way) but I write it down anyway.

When ever some one writes down the class name of a SFML class the forum should automatically link the class to the documentation.
For the class name I would suggest that only names in the form of sf::ClassName get recognized and if they're not in a code block (or other blocks).

For the linking I could think of two diffrent ways:
  • The entry gets 'postprocessed' and with that the sf::ClassName get surrounded with the specific link.
  • Before the text is sent to the user the sf::ClassName get linked to the documentation.
Additionally one could also add the tt-block to let it stand out more.

The question now is which version of SFML to link to. I'd go for SFML 2 (at least as soon as it gets released).

I think it would greatly help specially for the new users to discover the documentation.

77
System / [SFML 2.0] sf::Thread doesn't display sf::Text correctly
« on: January 25, 2012, 07:37:02 pm »
At the moment I'm experimenting with sf::Thread but I get some problems with global sf::Text variables and I'm not sure if SFML is messing something up or my lack of knowledge.

I choose to use the member function version for thread creation and setup three files as an example.

What I basicly want to do is display how each thread is running.
So the code seems in my opinion okay and using a sf::Mutex for the mUPS doesn't change anything.
The problem now is, that only some random numbers get displayed on the window altough the std::cout looks okay.
When further tempering with the text output I noticed that:
1) When setting the text outside of the Draw() function it doesn't get displayed at all (I set it at the intitializastion).
2) Using the mFPS which is declared outside of the Draw function and assign some numbers all the '0' don't get displayed.
3) When using a sf::Text local to the thread it gets displayed without problems.
4) It seems everything works fine with a non-member function without argument.

What I ask myself now, can't I use external sf::Text? If not how would I share text between threads? Or better how would a use threads to draw stuff?

main.cpp
#include "Task.hpp"

int main(int argc, char **argv)
{
        Task test;
       
        test.Run();
   
        return EXIT_SUCCESS;
}
Task.hpp
#ifndef TASK_HPP
#define TASK_HPP

#include <SFML/Graphics.hpp>

class Task
{
public:
        Task();
        ~Task();

        void Draw();
        void Update();

        void Run();

private:
        sf::Text mFPS;
        sf::Text mUPS;
        bool mRun;
        sf::Mutex mLocker;
        sf::Font mFont;
};

#endif // TASK_HPP

Task.cpp
#include "Task.hpp"

#include <SFML/System.hpp>
#include <sstream>
#include <iostream>

Task::Task() : mFPS(sf::String("FPS: 30")),
                           mUPS(sf::String("UPS: 30")),
                           mRun(false),
                           mLocker(),
                           mFont()
{
        mFont.LoadFromFile("FreeMono.ttf");

        mFPS.SetFont(mFont);
        mFPS.SetPosition(sf::Vector2f(10.f, 10.f));
        mFPS.SetColor(sf::Color::White);

        mUPS.SetFont(mFont);
        mUPS.SetPosition(sf::Vector2f(10.f, 50.f));
        mUPS.SetColor(sf::Color::White);
}

Task::~Task() { }

void Task::Draw()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
        window.SetFramerateLimit(30);
        sf::Clock clock;

        float currentFPS = 30;

        while(mRun)
        {
                // Process events
                sf::Event event;
                while (window.PollEvent(event))
                {
                        // Close window : exit
                        if (event.Type == sf::Event::Closed)
                        {
                                mRun = false;
                                window.Close();
                        }
                }

                std::stringstream ss;
                currentFPS = 1.f/clock.GetElapsedTime().AsSeconds();
                ss << "FPS: " << currentFPS;
                std::cout << ss.str() << std::endl;
                mFPS.SetString(sf::String(ss.str()));

                window.Clear();
                window.Draw(mFPS);
                window.Draw(mUPS);
                window.Display();

                // Reset
                clock.Restart();
        }
}

void Task::Update()
{
        sf::Clock clock;

        float currentUPS = 30;

        while(mRun)
        {
                currentUPS = 1.f/clock.GetElapsedTime().AsSeconds();
                std::ostringstream oss;
                oss << "UPS: " << (unsigned int)(currentUPS);
                {
                        sf::Lock::Lock(mLocker);
                        mUPS.SetString(sf::String(oss.str()));
                }

                // Reset
                clock.Restart();
        }
}

void Task::Run()
{
        mRun = true;

        sf::Thread thread1(&Task::Draw, this);
        thread1.Launch();

        sf::Thread thread2(&Task::Update, this);
        thread2.Launch();

        thread2.Wait();
        thread1.Wait();
}

Thanks for any help!

eXpl0it3r

78
Graphics / [SFML2.0] sf::Shape vs. sf::Sprite
« on: January 04, 2012, 04:38:49 pm »
I was just looking at the SFML 2.0 API with the merged drawables and noticed that sf::Shape and sf::Sprite kinda do the same thing.
Sure Sprites can't have an outer color but the rest seems equally on the top.
Now I was wondering what's diffrent at the bottom and which would perform better (theoreticly). I could figure it out and test it myself but ... I'm too lazy.  :lol:
Is it now just a question of desgin and/or taste or are there some real advantages?

79
SFML website / SFML 1.7 snapshot??
« on: February 22, 2011, 03:46:03 pm »
I was browsing through the website and noticed on the download page:
"SFML 1.7 snapshot"

But the SFML release thread doesn't list that version.
And SVN repository doesn't have any clue to version 1.7...

So it seems like a mistake, or is the rest of the website just not uptodate?  :D

eXp

80
SFML website / ['request'] Overall navigationbar
« on: January 18, 2011, 01:44:59 am »
Heyho!

I know I'm the newbie here and should first look around a bit more, but there's that 'thing' that I really don't like about the website...
When programming and learning new stuff, I jump pretty often between many diffrent sites, tuts, docs, forum and so on. Normaly not that big of a deal, but here at sfml-dev, I always have to edit the URL to get my navigation back...
I know the diffrent parts run with diffrent 'software' and so it's not that easy to get a navibar over all the websites, but try it and it will please the user! ;-)

It doesn't have to be as big as the one on the front page but just a few small links to navigate between Download, Forum, Wiki, Doc and Tuts!

Thanks in advance and my respect for the great work with SFML! =)
Greets

Pages: 1 ... 4 5 [6]