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 - 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 / Re: FPS are falling down
« on: June 26, 2012, 04:05:04 pm »
    static int frames = 0;
    static int updateTime = 1000000;
    static double fps = 0;
 
Why are you using int and double?
Oh, I used other algorithm earlier and I forgot change this.


sf::RenderWindow* renderTarget = new sf::RenderWindow

If you create something with new, you must delete it
It's not required if object that I create with new is used to the end. It isn't memory leak. All allocated memory is freed automatically when application is closed.
If I lose last pointer to the object then it's memory leak.


And it starts with 2100 fps. But after 20-30 minutes it's only 1100 fps.

Maybe some other program using OpenGL?
Only NetBeans is running.

3
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.

4
Feature requests / Re: Few suggestions
« on: June 22, 2012, 01:48:50 pm »
Quote
Do you even know what it means? :P
Sorry, my mistake. I didn't know trivial constructor is something different than default constructor.

So, could I ask why something that don't have trivial contructor can't be in union?

5
Feature requests / Re: Few suggestions
« on: June 22, 2012, 01:08:17 pm »
Quote
One of the problems with using Vector2 in the events (instead of two fields x and y) is the use of unions. IIRC, Vector2 does not have a trivial default constructor, and so cannot be in a union.

So Vector2 should have a trivial default constructor. ;)

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.

6
Feature requests / Re: Few suggestions
« on: June 21, 2012, 11:24:14 pm »
Quote
Although there's no explicit decleration of a assignment operator it's still there since there's an copy constructor.

You are right. I forgot about that.
What about other suggestions?

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