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

Pages: [1]
1
Graphics / sf::Font bug (SFML 2.0)
« on: February 17, 2013, 02:28:44 pm »
It's possible I have found a bug in sf::Font class.
If I have this code:
int main() {
    sf::RenderWindow window;
    sf::Font font;
    sf::Text text("Lalala", font);
    window.draw(text);

    return 0;
}
 
Everything is right. But if I have this:
int main() {
    sf::RenderWindow window;
    sf::Text text("Lalala", sf::Font());
    window.draw(text);

    return 0;
}
 

then valgrind says:
==3636== 92 bytes in 1 blocks are definitely lost in loss record 42 of 56
==3636==    at 0x4026C33: operator new(unsigned int) (vg_replace_malloc.c:282)
==3636==    by 0x41A72F1: std::_Rb_tree<unsigned int, std::pair<unsigned int const, sf::Font::Page>, std::_Select1st<std::pair<unsigned int const, sf::Font::Page> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sf::Font::Page> > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, std::pair<unsigned int const, sf::Font::Page> const&) (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41A75B0: std::_Rb_tree<unsigned int, std::pair<unsigned int const, sf::Font::Page>, std::_Select1st<std::pair<unsigned int const, sf::Font::Page> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sf::Font::Page> > >::_M_insert_unique(std::pair<unsigned int const, sf::Font::Page> const&) (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41A76EA: std::_Rb_tree<unsigned int, std::pair<unsigned int const, sf::Font::Page>, std::_Select1st<std::pair<unsigned int const, sf::Font::Page> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sf::Font::Page> > >::_M_insert_unique_(std::_Rb_tree_const_iterator<std::pair<unsigned int const, sf::Font::Page> >, std::pair<unsigned int const, sf::Font::Page> const&) (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41A5B0E: sf::Font::getTexture(unsigned int) const (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41C65F1: sf::Text::draw(sf::RenderTarget&, sf::RenderStates) const (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41BF23B: sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) (in /usr/local/lib/libsfml-graphics.so.2.0)
 

I use SFML 2.0 and I updated it two days ago from github repo.

2
Window / FPS are falling down
« on: June 25, 2012, 04:09:09 am »
Hello,

I have following code:
#include <SFML/Graphics.hpp>
#include <cstdio>
#include <SFML/System.hpp>
#include <queue>

int getFPS() {
    static sf::Clock clock;
    static int frames = 0;
    static int updateTime = 1000000;
    static double fps = 0;
    frames++;

    if (clock.getElapsedTime().asMicroseconds() > updateTime) {
        fps = frames;
        frames = 0;
        clock.restart();
    }

    return fps;
}

int main() {

    sf::RenderWindow* renderTarget = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "Trololo", sf::Style::Close);

    char str[50] = "0";

    while (true) {
        renderTarget->clear();

        sprintf(str, "%d\n", getFPS());
        sf::String string(str);
        sf::Text fpsText(string);
        fpsText.setColor(sf::Color(0, 0, 255));
        renderTarget->draw(fpsText);

        renderTarget->display();
    }

    return 0;
}

 

And it starts with 2100 fps. But after 20-30 minutes it's only 1100 fps.
I have no idea what is the reason for it.

3
Feature requests / Few suggestions
« on: June 21, 2012, 10:15:15 pm »
I think there should be an assignment operator in Vector2<T> and Vector3<T>.

Update
Ok. I have few other suggestions:
- There should be a Vector2d typedef for Vector2<double> too.
- All mouse events should have attribute Vector2 position instead of two fields x and y.
- There should be additional field prevPos in MouseMoveEvent.

Update 2
I changed thread subject. :)

Update 3
New suggestion:
I think class sf::Shape should have a method "bool contains(Vector2 point)" to check if a point is contained.
And maybe it should be separated Shape and DrawableShape. Like a Rect<T> and RectangleShape. It's to be discussed.

Pages: [1]