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

Pages: [1]
1
Graphics / Huge problem with SFML
« on: January 12, 2010, 11:26:11 pm »
Quote from: "Oz1571"
I have had similar issues during the past two months or so, sometimes it will freeze whenever I move the mouse cursor (GetEvent), and it won't go away until I restart my computer. Most of the time it works fine, though.


Ah yes, that was something else I did, I restarted my computer. Still, every other application ran fine, so it was something specifically to do with SFML.


Just happened again in fact. My computer had been running for a day or two, and I started one of the samples ( the box one ) and same thing, mouse movement slowed down the rotating cube. I reset my computer and it was all smooth again.

2
Graphics / Huge problem with SFML
« on: January 08, 2010, 07:04:54 pm »
I ran it again and everything is running smoothly now. I have no idea why :?

Yesterday I installed Visual C++ 2008 express. Then I uninstalled microsoft presentation foundation, which I think came with VC++ 2008 express.

Those are the only things I remember doing between the time it wasn't working and now.

Very strange.

3
Graphics / Huge problem with SFML
« on: January 08, 2010, 05:08:21 am »
Quote from: "phear-"
use a log file or something other than sf::strings to see if it has something to do with that.


It has nothing to do with sf::strings.

If I comment out the event loop everything runs smoothly.

4
Graphics / Huge problem with SFML
« on: January 07, 2010, 06:06:02 pm »
Quote from: "Laurent"
How many events do you have when you press a single key?


I go through the event loop twice. Looks like one for the press and one for the release.

5
Graphics / Huge problem with SFML
« on: January 07, 2010, 04:09:12 pm »
Quote from: "Laurent"
What happens when you stop moving the mouse? Does the program run smoothly again, or does it stay frozen?


It starts running smoothly again.

The mouse movement makes the most visible effect, but it also gets choppy when I hold down a key on the keyboard.

6
Graphics / Huge problem with SFML
« on: January 07, 2010, 12:22:32 pm »
Quote from: "Laurent"
Did you try the samples provided in the SFML SDK?


Yep, just ran pong and same problem. When I move the mouse the ball freezes.

Same thing with opengl, the rotating cube freezes.

7
Graphics / Huge problem with SFML
« on: January 07, 2010, 12:56:31 am »
Quote from: "Laurent"
Maybe you receive a huge amount of unexpected events. Can you add some logs in your event loop to know what is received exactly?


Ok here is what I did. I added a counter to the event loop to increment each time there is an event. Then I displayed the counter on screen to see how many times the event loop was running.

The result was that the event looped maybe 3 times when I moved the mouse cursor a small distance. However this was still freezing both the fps and the main program loop counter. So for some reason App.GetEvent(Event) is running hella slow on my system.

Here is the new code:

Code: [Select]

#include <SFML/Graphics.hpp>

int main()
{
    sf::Font MyFont;
    sf::String fps;
    sf::String counter;
    sf::String EventCount;
    char buffer[200];
    int num = 0;
    int evnum = 0;

    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");

    if (!MyFont.LoadFromFile("font/small/XPAIDERP.TTF", 8))
        return EXIT_FAILURE;

    fps.SetFont(MyFont);
    fps.SetSize(8);
    fps.SetPosition(100.f, 100.f);

    counter.SetFont(MyFont);
    counter.SetSize(8);
    counter.SetPosition(100.f, 200.f);

    EventCount.SetFont(MyFont);
    EventCount.SetSize(8);
    EventCount.SetPosition(100.f, 300.f);

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if( Event.Type == sf::Event::Closed )
                App.Close();

            evnum++;
        }

        App.Clear();

        sprintf( buffer, "FPS = %f", 100.f / App.GetFrameTime() );
        fps.SetText( buffer );
        App.Draw( fps );

        sprintf( buffer, "COUNTER = %d", num );
        counter.SetText( buffer );
        App.Draw( counter );

        sprintf( buffer, "EVENTS = %d", evnum );
        EventCount.SetText( buffer );
        App.Draw( EventCount );

        App.Display();

        num++;
    }

    return EXIT_SUCCESS;
}


I am using sfml version 1.5

8
Graphics / Huge problem with SFML
« on: January 06, 2010, 08:50:57 pm »
This is a total game breaker for me unless I am missing something huge here.

The problem is when I add GetEvent(Event) in my code it slows or even STOPS my program when I move the mouse around.

I display the fps and even added a counter to increment each time the program loops and they both stop dead when I move the mouse.

I have been puzzling over this for quite a while and I cannot find anything on the forum about it.

Here is my code, someone else please run it and see if you get the same results:

Code: [Select]

#include <SFML/Graphics.hpp>

int main()
{
    sf::Font MyFont;
    sf::String fps;
    sf::String counter;
    char buffer[200];
    int num = 0;

    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");

    if (!MyFont.LoadFromFile("font/small/XPAIDERP.TTF", 8))
        return EXIT_FAILURE;

    fps.SetFont(MyFont);
    fps.SetSize(8);
    fps.SetPosition(100.f, 100.f);

    counter.SetFont(MyFont);
    counter.SetSize(8);
    counter.SetPosition(100.f, 200.f);

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        App.Clear();

        sprintf( buffer, "FPS = %f", 100.f / App.GetFrameTime() );
        fps.SetText( buffer );
        App.Draw( fps );

        sprintf( buffer, "COUNTER = %d", num );
        counter.SetText( buffer );
        App.Draw( counter );

        App.Display();

        num++;
    }

    return EXIT_SUCCESS;
}


I move the mouse around and both the counter and the fps freeze. This can only mean the program itself is freezing. If I comment out while (App.GetEvent(Event)) then everything goes smoothly and I can move the mouse around with no freezing.

System:

WindowsXP service pack 3
DirectX 9.0c
AMD athlon 2.21 GHZ
2 GB RAM

Using Code::blocks IDE with MingW

9
Graphics / Re-using sf::Image?
« on: January 06, 2010, 02:17:59 am »
Is it safe to use the same sf::Image variable for more then one bitmap?

If I do this for instance:

Code: [Select]

sf::Image bitmap;
sf::Sprite sprite;

bitmap.LoadFromFile( "bitmap1.bmp" );

sprite.SetImage( bitmap );

App.Draw( sprite );

// and then do this

bitmap.LoadFromFile( "bitmap2.bmp" );

sprite.SetImage( bitmap ); // do I need to do this again?

App.Draw( sprite );


Is this safe or will I get a memory leak somewhere?

10
Graphics / Blurry text
« on: December 30, 2009, 02:11:57 am »
Quote from: "OniLink10"
I don't know about anyone else, but I don't see any blurring.


Look again. It's better when it's at 7pt, but it still blurs. Here's an enlarged version so you can see it better.



Nevermind I fixed it. I just had the pt size too large.

11
Graphics / Blurry text
« on: December 30, 2009, 02:04:14 am »
Quote from: "Laurent"
Without blurring it's even worse. What does 12 pt corresponds to, in pixels?


Ya why is it just blocks of white with sf::Blend::None?

I think 12 pt means 12 pixels, or close anyway.

I turned it down to 7 pt and here is the result ( not enlarged ):



Much clearer, but there is still some blending. The font is about 5 x 5 pixels in most spots.

12
Graphics / Blurry text
« on: December 30, 2009, 12:33:49 am »
I am using 640 x 480 x 32 bit mode and so I use small .ttf fonts, but when I blit them to the screen there is some kind of automatic AA done to them which makes them blurry and ruins the readability.

For example, at 12 pt it looks like this ( enlarged 3x ):



I tried to use this command to turn off blending:

SetBlendMode( sf::Blend::None );

But when I do that I get this ( enlarged 3x ):



Any help would be appreciated.

Here is my code

Code: [Select]


FontClass::FontClass( char *filename, int s )
{
    size = s;

    if( !( font.LoadFromFile( filename, size ) ) )
    {
        char errormsg[200];
        sprintf( errormsg, "Failed to load - %s", filename );
        DisplayError( errormsg );
    }
}

FontClass::~FontClass()
{
}

// function to draw the font
void FontClass::DrawFont( char *text, int x, int y, int cx, int cy )
{
    sf::String Txt( text, font, size );

    Txt.SetPosition( float ( x ), float( y ) );

    App.Draw( Txt );
}

Pages: [1]
anything