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

Author Topic: Drawing text immediately crashes  (Read 3493 times)

0 Members and 1 Guest are viewing this topic.

ThatOneGuyThatDoesStuff

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Drawing text immediately crashes
« on: February 23, 2020, 10:42:20 pm »
I just... don't understand why...

I am writing a large application and after some 500 lines of code I need to draw text to the screen for the first time. And it just won't. I opened up a new project to recreate the code doing the work to try and find the problem, but it just crashes with even the bare minimum.

int main(){
  sf::RenderWindow renderWindow(sf::VideoMode(800, 600), "Test app");
  sf::Event event;
 
  sf::Font font;
  font.loadFromFile("Image/arial.ttf");
  sf::Text test ("Hello", font);
 
  while (renderWindow.isOpen()){
    while(renderWindow.pollEvent(event)){
      if (event.type == sf::Event::Closed){
        renderWindow.close();
      }
    }
    renderWindow.clear();
    renderWindow.draw(test);

    renderWindow.display();
  }
}
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Drawing text immediately crashes
« Reply #1 on: February 24, 2020, 06:35:42 am »
1. Check the console output
2. Use a debugger, to figure out at least where it crashes
3. Check your build configuration (no debug/release mix)
4. Post details about your environment (OS, compiler, version of SFML)

Thank you.
Laurent Gomila - SFML developer

ThatOneGuyThatDoesStuff

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: Drawing text immediately crashes
« Reply #2 on: February 24, 2020, 04:52:26 pm »
1. Check the console output
2. Use a debugger, to figure out at least where it crashes
3. Check your build configuration (no debug/release mix)
4. Post details about your environment (OS, compiler, version of SFML)

Thank you.

1. Process terminated with status -1073741510 (0 minute(s), 5 second(s))
2. Debugger doesn't do or say anything except "finsihed with status 1"
3. ?
4. Windows 7 64 bit/Codeblocks 17.12/MinGW compiler/sfml 2.5.1
« Last Edit: February 24, 2020, 04:54:49 pm by ThatOneGuyThatDoesStuff »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Drawing text immediately crashes
« Reply #3 on: February 24, 2020, 05:34:31 pm »
Quote
1. Process terminated with status -1073741510 (0 minute(s), 5 second(s))
Nothing in stdout/stderr?

Quote
2. Debugger doesn't do or say anything except "finsihed with status 1"
Probably because you don't know how to use it ;)
That would be something to learn in priority.

Quote
3. ?
Typically, running a debug build that links to release SFML libraries can lead to such crashes.

Quote
Windows 7 64 bit/Codeblocks 17.12/MinGW compiler/sfml 2.5.1
Make sure that your version of MinGW exactly matches the one that SFML was compiled with (it's clearly mentioned on the download page).
Laurent Gomila - SFML developer

ThatOneGuyThatDoesStuff

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: Drawing text immediately crashes
« Reply #4 on: February 24, 2020, 09:36:18 pm »
Quote
1. Process terminated with status -1073741510 (0 minute(s), 5 second(s))
Nothing in stdout/stderr?

Quote
2. Debugger doesn't do or say anything except "finsihed with status 1"
Probably because you don't know how to use it ;)
That would be something to learn in priority.

Quote
3. ?
Typically, running a debug build that links to release SFML libraries can lead to such crashes.

Quote
Windows 7 64 bit/Codeblocks 17.12/MinGW compiler/sfml 2.5.1
Make sure that your version of MinGW exactly matches the one that SFML was compiled with (it's clearly mentioned on the download page).

1. nothing at all

2. Know how to use it, but that is all it says. The program instantly crashes when I attempt a debug and it doesn't show anything.

3 && 4. I've checked all compiler/debugger settings. Unless I'm missing something, everything is as it should be.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Drawing text immediately crashes
« Reply #5 on: February 24, 2020, 10:20:06 pm »
So what you say is that your code doesn't even start? From your first message I understood that it was working, and suddenly crashed on some code that you added to draw text.

Code that doesn't start (ie. nothing shows in the debugger) might be caused by a missing DLL.
Laurent Gomila - SFML developer

ThatOneGuyThatDoesStuff

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: Drawing text immediately crashes
« Reply #6 on: February 25, 2020, 08:27:18 am »
So what you say is that your code doesn't even start? From your first message I understood that it was working, and suddenly crashed on some code that you added to draw text.

Code that doesn't start (ie. nothing shows in the debugger) might be caused by a missing DLL.

My program works 100% fine, including all sfml features I have used. I reached a point where I needed to draw text on the ui and as soon as I implement renderWindow.draw(text), in any capacity, it crashes. I can modify the text, I can std::cout any and all of it's information, but as soon as I uncomment renderWindow.draw(text) it crashes as soon as it reaches that line of code.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Drawing text immediately crashes
« Reply #7 on: February 25, 2020, 10:17:42 am »
If it crashes on that specific line, then you should definitely be able to get some basic information with your debugger. The call stack (ie. where it crashes inside SFML) would be very helpful.

But as I said, such crashes on apparently valid code often occur because of environment issues. Are you 100% sure that the SFML release that you downloaded was compiled with the exact same compiler version as your application? If you're not sure, you can also recompile SFML yourself.
Laurent Gomila - SFML developer

ThatOneGuyThatDoesStuff

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: Drawing text immediately crashes
« Reply #8 on: February 26, 2020, 09:56:56 pm »
If it crashes on that specific line, then you should definitely be able to get some basic information with your debugger. The call stack (ie. where it crashes inside SFML) would be very helpful.

But as I said, such crashes on apparently valid code often occur because of environment issues. Are you 100% sure that the SFML release that you downloaded was compiled with the exact same compiler version as your application? If you're not sure, you can also recompile SFML yourself.

I checked and double checked everything I can think of. Compiler version is exactly the same. Can you perhaps give me some exact things to check in the build options? Maybe I'm missing something obvious.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Drawing text immediately crashes
« Reply #9 on: February 27, 2020, 08:06:42 am »
To be 100% sure, there are two options:
- download the matching compiler, with the link given on the download page of SFML, and use it to compile your project
- recompile SFML with the compiler that you currently use for your project
Laurent Gomila - SFML developer

ThatOneGuyThatDoesStuff

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: Drawing text immediately crashes
« Reply #10 on: July 09, 2020, 11:01:53 pm »
To be 100% sure, there are two options:
- download the matching compiler, with the link given on the download page of SFML, and use it to compile your project
- recompile SFML with the compiler that you currently use for your project

So, I left this issue alone since I wasn't getting anywhere. I kinda need it to work now though, so I've been trying to figure out the problem again. I reinstalled all compiler/libraries from scratch to be sure there is no issue there. I ran the debugger then and now got this from the call stack:
":\Windows\SysWOW64\ig4icd32.dll"
Any ideas?

Thanks for the help, btw

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Drawing text immediately crashes
« Reply #11 on: July 12, 2020, 11:18:04 pm »
Are you sure that the font is loading successfully? You aren't checking its return value. If the font doesn't load, you're asking the text to draw using an invalid font.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*