Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Just a question about the progress  (Read 13546 times)

0 Members and 1 Guest are viewing this topic.

ptrxyz

  • Newbie
  • *
  • Posts: 32
    • View Profile
Just a question about the progress
« on: May 19, 2009, 12:26:54 am »
Hello.

I will start a new projekt next month and we are thinking about switching from SDL to SFML. As mentioned in several topics and in the todo-list there is a major issue with SFML crashing when the main program closes and you used drawtext (or however it's called...) before.
I myself would prefer to use SFML for that projekt but i wonder if that bug will be fixed during the next few days / weeks. I checked the todo-list and found out that the last edit was on 06 March =(. So, my question is if there is a chance that this bug will get fixed "soon" or if there is a work around for that crashing issue...
Does anyone know?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just a question about the progress
« Reply #1 on: May 19, 2009, 07:51:36 am »
Quote
if there is a chance that this bug will get fixed "soon"

No.

Quote
if there is a work around for that crashing issue...

If you've read several topics about it, then you already know the workarounds ;)
Laurent Gomila - SFML developer

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Just a question about the progress
« Reply #2 on: May 19, 2009, 08:49:16 am »
So far avoid using the default sfml font and you're Ok. SFML is good and robust enough to be used both in free and commercial projects.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just a question about the progress
« Reply #3 on: May 19, 2009, 10:09:52 am »
I tested with the sfml2 branch, and it seems that this bug doesn't appear anymore in this branch :)
Laurent Gomila - SFML developer

ptrxyz

  • Newbie
  • *
  • Posts: 32
    • View Profile
Just a question about the progress
« Reply #4 on: May 19, 2009, 12:30:20 pm »
Hm, yes, i read i should avoid the default font and it should work ... but seems it doesnt work for the .NET package (at least it doesnt for me.... O.O)
But i will try to use the SFML2 branch. It's this one, right? /branches/sfml2/dotnet/

Oh, just in case i am doing something wrong, here is the quick'n'dirty code i used for testing the crashing:

Code: [Select]

Imports SFML.Graphics
Imports SFML.Audio
Imports SFML.Window
Imports System

Module Module1
    Dim WithEvents App As RenderWindow
    Dim doit As Boolean = True

    Public Sub Main()
        Dim vMode As New VideoMode(640, 480, 32)
        App = New RenderWindow(vMode, "Test", Styles.None Or Styles.Titlebar)

        Dim img As New Image("somefile.png")
        Dim sprite As New Sprite(img)

        Dim fnt As Font = New Font("c:\windows\fonts\Calibri.ttf", 14)
        Dim str2D As New String2D("Hello World", fnt, 14)

        Dim ff As Long = 0
        Dim st As Long = Now.TimeOfDay.TotalMilliseconds
        Dim fps As Single = 0

        App.UseVerticalSync(True)
        App.SetFramerateLimit(60)

        While App.IsOpened And doIt

            App.Clear(New SFML.Graphics.Color(0, 0, 0, 1))
           
            sprite.Position = New Vector2(sprite.Position.X + 1, 10)
            If sprite.Position.X > 600 Then sprite.Position = New Vector2(0, 10)
            sprite.BlendMode = BlendMode.Alpha
            App.Draw(sprite)

            sprite.Position = New Vector2(sprite.Position.X + 1, 100)
            sprite.BlendMode = BlendMode.Multiply
            App.Draw(sprite)

            ff += 1
            If Now.TimeOfDay.TotalMilliseconds - st >= 1000 Then
                fps = (ff / (Now.TimeOfDay.TotalMilliseconds - st) * 1000)

                'str2D.Dispose()      'Even if this line is commented out I get the crash.
                'str2D = New String2D(fps, fnt, 14)

                st = Now.TimeOfDay.TotalMilliseconds : ff = 0
            End If

            'App.Draw(str2D)        'No need to draw it...crash occures anyways.
            App.Display()
            App.DispatchEvents()
        End While

        str2D.Dispose()
        fnt.Dispose()
        fnt = Nothing
        str2D = Nothing
        App.Close
    End Sub

    Private Sub App_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles App.Closed
        doit = False
        'App.Close() '<- no need here. Releaseing Resources in Sub Main...
    End Sub

    Private Sub App_KeyPressed(ByVal sender As Object, ByVal e As SFML.Window.KeyEventArgs) Handles App.KeyPressed
        doit = False
        'App.Close() '<- no need here. Releaseing Resources in Sub Main...
    End Sub
End Module


Edit:
I compiled the .NET libs i found here: /branches/sfml2/dotnet/
I tried my little testprogram again...still same error. =(
Maybe someone can tell me what I am doing wrong? I uploaded everything I used for testing (Test-Project and the latestet SFML2 dotnet-library): http://www.itak.de/share/SFMLTest.rar

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just a question about the progress
« Reply #5 on: May 19, 2009, 01:05:14 pm »
Quote
but seems it doesnt work for the .NET package

Yes, in SFML.Net the internal sf::String of the String2D class is always constructed with the default font first.

Quote
I compiled the .NET libs i found here: /branches/sfml2/dotnet/
I tried my little testprogram again...still same error. =(

You have to recompile SFML (static release), CSFML (dynamic release) and then SFML.Net.
Laurent Gomila - SFML developer

ptrxyz

  • Newbie
  • *
  • Posts: 32
    • View Profile
Just a question about the progress
« Reply #6 on: May 19, 2009, 09:02:57 pm »
Quote from: "Laurent"
Quote
but seems it doesnt work for the .NET package

Yes, in SFML.Net the internal sf::String of the String2D class is always constructed with the default font first.

Quote
I compiled the .NET libs i found here: /branches/sfml2/dotnet/
I tried my little testprogram again...still same error. =(

You have to recompile SFML (static release), CSFML (dynamic release) and then SFML.Net.


Ok, i recompiled it like you said i should. Then i copied the new files (csfml-???.dll) to dotnet/extlibs/ and recompiled the dotnet-projekt. Then i copied all new libs (csfml-???.dll and fsmlnet-???.dll) to my test project and set up the links correctly. the problem got partly solved:

running the executable out of the IDE (VS2008, Debugging mode) --> error on exit
running the executable (release-build, not out of IDE) --> no error on exit
running the executable (debug-build, but not out of IDE) --> no error on exit

I figured out that the error is still caused by the string2D class. As long as i dont create that class, i wont get an error. but maybe it's just an IDE issue? Any ideas anyone?

edit: Disabeling the VS-Host-Process fixes the error, too...

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Just a question about the progress
« Reply #7 on: May 21, 2009, 12:08:01 am »
I found that deleting the main RenderWindow object is the reason.

I don't know if in Visual Basic you can just let it alive, but in C++ I just never free it and I'm doing OK.

I'm most certain that it has to do with the OpenGL context. Even if there is a global context until the application exits, the Window context dies when closing the RenderWindow.
And when the default font tries to free it's textures, it crashes.

I've already posted that if the library skips the wglDeleteContext in the WM_DESTROY event... SFML wont crash.

ptrxyz

  • Newbie
  • *
  • Posts: 32
    • View Profile
Just a question about the progress
« Reply #8 on: May 22, 2009, 12:50:57 pm »
Quote

I don't know if in Visual Basic you can just let it alive, but in C++ I just never free it and I'm doing OK.

Hm, I think there is no way to keep it alive since .NET destroys it automatically i guess.

Quote

I've already posted that if the library skips the wglDeleteContext in the WM_DESTROY event... SFML wont crash.

I will comment out those lines and recompile SFML and see what happens.

But isnt it strange that deactivating the VS.NET's debug host process fixes the crashes too...?

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Just a question about the progress
« Reply #9 on: May 22, 2009, 05:06:37 pm »
It's kind of weird. But in my case it happens with Native C++ (VC++ Express 2008).
Even in release mode, so in my case it's not a debug thing.

I found that removing the "delete myWindow;" in Window::Close()
(Window.cpp, line 167) solved this.

But in debug mode it could whine about memory leaks.

Good luck!
-Martín

mouster

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • http://mouster.ovh.org
Just a question about the progress
« Reply #10 on: July 03, 2009, 10:20:48 pm »
Quote from: "Laurent"
Quote
but seems it doesnt work for the .NET package

Yes, in SFML.Net the internal sf::String of the String2D class is always constructed with the default font first.


I've deleted all references to DefaultFont i C# lib (even import function of default font getter from c lib). So now, there is no initialization of font in C# package. I've recompiled only C# package. I've still have problem of making this work. There is no way to omit that problem in simple way on C# for 1.5 version?

PS: That my first post, so I would like to say... gr8 JOB, that Lib is really gr8.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just a question about the progress
« Reply #11 on: July 03, 2009, 10:41:24 pm »
The default font is instancianted implicitely when sfString_Create is called. And this function is the only way to create a string, so I'm afraid there's no immediate solution to this problem with SFML 1.5.
Laurent Gomila - SFML developer

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
Just a question about the progress
« Reply #12 on: July 08, 2009, 02:08:14 am »
In sfml 2.0:

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>

struct structure
{
    structure() :
    font(sf::Font::GetDefaultFont())
    {
    }

    sf::Font font;
};

static structure s_structure;

int main()
{
    //===========================================
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Events");

    // Get a reference to the input manager associated to our window, and store it for later use
    const sf::Input& Input = App.GetInput();

    // Start main loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
        }

        // Display window on screen
        App.Display();
    }
    //==================================
    return EXIT_SUCCESS;
}


It leave an openGL error with and without the section between the equals.

I've also tried with image but it seem to be ok ^^.
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just a question about the progress
« Reply #13 on: July 08, 2009, 07:45:00 am »
Using SFML outside main is dangerous ;)
Laurent Gomila - SFML developer

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
Just a question about the progress
« Reply #14 on: July 08, 2009, 02:03:44 pm »
It's an example. The problem is that i made a little gui with a template loader and i use a static templateManager that i fill with the config in a xml file.
The templateManager contain structure and are used in all element to initialise their parameter with the content of the structure. So it cause me an error!

So if sfml doesn't support the use of static member it's a little sad.... (maybe more than little)....

I don't know how i will fix it..
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

 

anything