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 - Artexflow

Pages: [1]
1
Hi ! Thanks for your answer :)

Of course ! States are pushed and popped like they should be.
I've managed to solve my problem, and it was quite dumb, I was using some SFML libraries in debug mode, and some other in release mode...

Now everything works like a charm !

2
Graphics / Re: sf::Text setString() causing segfault (symbol not found)
« on: October 29, 2015, 11:29:24 pm »
Yep VS version numbers are hard to get :)

Btw, I've managed to get rid of that segfault by compiling myself and using the 2.3.1 version of SFML. You could guess it's a good news - and it is, but now I've got another problem.
As you can see on the upper left corner of my screenshot, the text does not draw letters, but instead... rectangles.



Any ideas on what could be causing this and how to fix it ?

Code concerning text has not been changed.

Update :
That rectangle seems to be linked to a texture. Here is what happens when I use another texture :


When I unbind it or disable it on OpenGL it stays the same.

glBindTexture(GL_TEXTURE_2D, 0);
or
glDisable(GL_TEXTURE_2D);
 

When I don't load any texture on OpenGL, I have a white rectangle.
If I set the font color using setColor(), my texture just turns to the text color I've just set.


Thanks !

3
Hi everyone,

I'm experiencing a strange behavior on SFML 2.3.2 with Visual Studio 14. I'm using the precompiled library that can be found here : http://www.sfml-dev.org/download/sfml/2.3.2/
I'm using the debug dlls.

The symptom is a segfault when I try to use the member function setString on an sf::Text object.

Useful infos :
    - _statsString is an attribute of the Application class ;
    - I'm mixing SFML and openGL calls ;
    - this is part of a game engine (some of you may recognize some things from the SFML Game Dev book - great book !).

Here are the most relevant parts of the code :

In the Application constructor, where I load my font and set some options of _statsString :
Application::Application() :
    ...
{  
        if (!_statsFont.loadFromFile("Sansation.ttf"))
                throw std::runtime_error("Error loading statistics font");
        _statsString.setFont(_statsFont);
        _statsString.setPosition(5.f, 5.f);
        _statsString.setCharacterSize(10);
}
 

When the segfault occurs :
void    Application::_updateStats(sf::Time dt)
{
        _statsUpdateTime += dt;
        _statsFrameCount += 1;

        if (_statsUpdateTime >= sf::seconds(1.0f))
        {
                _statsString.setFont(_statsFont);
                _statsString.setString("FPS: " + std::to_string(_statsFrameCount)); // <- Oh damn.
                _statsUpdateTime -= sf::seconds(1.0f);
                _statsFrameCount = 0;
        }
}

Visual's debugger is telling me that _statsString is a symbol not found, which is strange cause any other method seems to work properly...

Last but not least, under the MSYS2 toolchain (msys2 + mingw-w64) and with the 2.3.1 which I compiled myself, this bug does not occur.

Anyone has a clue on what's happening ?
Thanks a lot !

4
General / Re: [SFML Game Dev Book] - Low FPS at Chapter 4
« on: October 08, 2015, 12:53:17 am »
Are you compiling in Release mode, with no debugger running?

Hi !
I may have compiled SFML in debug mode now that you're asking me, do you think this lead is worth a try ? No debugger is running.

Is it really only the line
_sceneLayers[Background]->attachChild(std::move(backgroundSprite));
that makes the difference?

Totally :)

EDIT :
I've updated my NVIDIA driver and now everything goes smoothly. I even run at 1000 FPS.
kek.

5
General / Re: [SFML Game Dev Book] - Low FPS at Chapter 4
« on: October 08, 2015, 12:46:26 am »
Do you have a fixed framerate?
Hi, thanks for your time !

I'm not using
sf::RenderWindow::setFramerateLimit()
if that is what you're asking, nonetheless, the game loop uses fixed timesteps, as you can see here :

void    Game::run()
{
        sf::Clock       clock;
        sf::Time        timeSinceLastUpdate = sf::Time::Zero;

        while (_window.isOpen())
        {
                sf::Time        elapsedTime = clock.restart();
                timeSinceLastUpdate += elapsedTime;

                while (timeSinceLastUpdate > _timePerFrame)
                {
                        timeSinceLastUpdate -= _timePerFrame;
                        _processInput();
                        _update(_timePerFrame);
                }
                _updateStatistics(elapsedTime);
                _render();
        }
}
 

Did it help ? :)

6
General / [SFML Game Dev Book] - Low FPS at Chapter 4 [SOLVED]
« on: October 08, 2015, 12:31:34 am »
Hi everyone,

tl;dr : is this normal ?

First of all, let me say SFML is a great library.
I've started to read this great book here : https://www.packtpub.com/game-development/sfml-game-development

I really like the overall architecture which is developped in this book, and the philosophy behind it. I even agree on most of your formatting style choices ! Ahaha.

Anyway I'm now delving into chapter 4 (input handling) and noticed I had slow FPS when drawing my background texture, which by the way seems to repeat itself badly (see the picture)



You can see I'm running 46 FPS and that I have a black line on top of every desert picture.

Now if I comment the code section where I add that background to the scene graph, here is what happens :
void    World::_buildScene()
{
        // Init layers
        for (std::size_t i = 0; i < LayerCount; ++i)
        {
                SceneNode::Ptr  layer(new SceneNode());

                _sceneLayers[i] = layer.get();
                _sceneGraph.attachChild(std::move(layer));
        }

        // Init background
        //sf::Texture & texture = _textures.get(Textures::Desert);
        //sf::IntRect           textureRect(_worldBounds);
        //texture.setRepeated(true);

        // Adding background sprite
        //std::unique_ptr<SpriteNode>   backgroundSprite(new SpriteNode{texture, textureRect});
        //backgroundSprite->setPosition(_worldBounds.left, _worldBounds.top);
        //_sceneLayers[Background]->attachChild(std::move(backgroundSprite));

        // Adding player aircraft
        std::unique_ptr<Aircraft>       leader(new Aircraft{Aircraft::Eagle, _textures});
        _playerAircraft = leader.get();
        ...


As you can see I'm now running at more than 450 FPS.
I guess I could hope for a small improvement on the FPS rate, removing my background texture, but it seems quite exagerated.

Here is how SpriteNodes are drawn :
void SpriteNode::_drawCurrent(sf::RenderTarget & target, sf::RenderStates states) const
{
        target.draw(_sprite, states);
}

Here is how ScenesNodes are updated and drawn (SpriteNode inherits from them) :
void    SceneNode::_updateCurrent(sf::Time)
{
        // lel
}

void    SceneNode::_updateChildren(sf::Time dt)
{
        for (const Ptr & child : _children)
                child->update(dt);
}

void    SceneNode::draw(sf::RenderTarget & target, sf::RenderStates states) const
{
        states.transform *= getTransform();
        _drawCurrent(target, states);
        _drawChildren(target, states);
}

void    SceneNode::_drawCurrent(sf::RenderTarget &, sf::RenderStates) const
{
}

void    SceneNode::_drawChildren(sf::RenderTarget & target, sf::RenderStates states) const
{
        for (const Ptr & child : _children)
                child->draw(target, states);
}

If you haven't read this book, believe me it's really cool !
You can see how background is loaded in that method I've commented earlier.

I'm compiling using mingw-w64 under msys2 on Windows. I've compiled SFML myself using this toolchain. I've got a poor PC though, having an i3 @ 1.90Ghz and one of those NVIDIA GeForce 710M.

My question is :
Have I done something wrong, or is it the best performance I can achieve given my system ?
Thanks for your time,

Artexflow
(I'm obviously sorry if this has no place in this forum section)

Pages: [1]