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

Pages: [1]
1
Graphics / Re: Text/font causes crash on shutdown
« on: January 08, 2019, 07:05:23 pm »
Good, seems as if I will be able to do that!

Is there a way to let CMake create a new VS project and automatically generate the result of the steps in the "SFML and Visual studio" tutorial https://www.sfml-dev.org/tutorials/2.5/start-vc.php ?

2
Graphics / Re: Text/font causes crash on shutdown
« on: January 06, 2019, 05:38:18 pm »
Thank you for help and suggestions! My environment was not in order, it can be that I used 2.5 header files and 2.4 libs even :-[

I will take a look at CMake. I really like the VC++ debugger but I find its configuration/project/solution handling really cumbersome. I always find myself spending too much time searching among strange menu choices when I work with VC++, even though I should have spent more time there this time  :)

again, thanks it work now 8)

3
Graphics / Re: Text/font causes crash on shutdown
« on: January 06, 2019, 01:36:18 am »
On a closer inspection I see that I link with 2.4.2 library of unknown origin. I had downloaded  a more recent version from the download site but apparently I had failed to make the correct settings in the IDE  :-[

Hm, it seems as if I have to upgrade Visual Studio if I want to use the latest lib:

https://en.sfml-dev.org/forums/index.php?topic=24044.msg163201#msg163201

Thank you for the swift answer! I must get my environment in order. It was probably a bad lib  :)

4
Graphics / Text/font causes crash on shutdown
« on: January 06, 2019, 12:12:31 am »
I have started with the tutorials and let my project grow. When I added a text it started to crash at shutdown, it does not affect the gameplay but it is annoying. Now, I have shrunk the code to a minimal example. Can you see what is wrong?

#include <SFML/Graphics.hpp>
int main()
{
        sf::RenderWindow window(sf::VideoMode(700, 400), "hejsan", sf::Style::Default);
        sf::Font font_;
        sf::Text text_;
        // Just any font. (Still crashes at shutdown even if the line is removed.):
        font_.loadFromFile("C:\\Windows\\fonts\\DejaVuSansMono.ttf");
        text_.setFont(font_);
        text_.setString("hejsan");

        // run the program as long as the window is open
        while (window.isOpen())
        {
                // check all the window's events that were triggered since the last iteration of the loop
                sf::Event event;
                while (window.pollEvent(event))
                {
                        // "close requested" event: we close the window
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
                window.draw(text_);

                window.display();
        }
        return 0;
}
 
Compiler (build chain):
Microsoft Visual C++ 2017
Error message:
Exception thrown at 0x00303A18 in ConsoleApplication1.exe: 0xC0000005: Access violation writing location 0xCDCDCDCD
Call stack:
   ConsoleApplication1.exe!std::_Container_base12::_Orphan_all() Line 256   C++   Non-user code. Symbols loaded.    ConsoleApplication1.exe!std::_Vector_alloc<std::_Vec_base_types<sf::Vertex,std::allocator<sf::Vertex> > >::_Orphan_all() Line 580   C++   Non-user code. Symbols loaded.
    ConsoleApplication1.exe!std::vector<sf::Vertex,std::allocator<sf::Vertex> >::_Tidy() Line 2003   C++   Non-user code. Symbols loaded.
    ConsoleApplication1.exe!std::vector<sf::Vertex,std::allocator<sf::Vertex> >::~vector<sf::Vertex,std::allocator<sf::Vertex> >() Line 921   C++   Non-user code. Symbols loaded.
    ConsoleApplication1.exe!sf::VertexArray::~VertexArray()   C++   Non-user code. Symbols loaded.
    ConsoleApplication1.exe!sf::Text::~Text()   C++   Non-user code. Symbols loaded.
>   ConsoleApplication1.exe!main() Line 27   C++   Symbols loaded.
    [External Code]      Annotated Frame


Pages: [1]