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

Author Topic: glFlush() error. [SOLVED]  (Read 6363 times)

0 Members and 1 Guest are viewing this topic.

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: glFlush() error.
« Reply #15 on: September 22, 2020, 03:26:58 pm »
I couldn't say what the crash is without more info like an error or seeing the call stack. What I can say though, is that you're creating a copy of the texture again, this time in your Entity class.

Riser

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: glFlush() error.
« Reply #16 on: September 23, 2020, 01:00:36 pm »
Oh my God there was a second page this whole time!

The output window didn't display anything, but when running the debugger I got an exception pointing to this line in a file named "xtree":
(Scroll sideways to see the exception)


I think I already established that I'm very inexperienced, so this is way beyond me.
« Last Edit: September 23, 2020, 01:06:14 pm by Riser »

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: glFlush() error.
« Reply #17 on: September 23, 2020, 02:46:43 pm »
In the pane on the bottom right there is a tab labelled 'call stack'. This is often useful when debugging as it tells you the order of the functions called leading up to the crash.

In this case however it looks like the info you've shared is saying the std::map inside your asset manager is currently null. It crashes when you try to read a texture from it. This is probably because you haven't instanciated the AssetManager at least once, so there's no singleton instance created yet.

This can be fixed by adding
AssetManager assetManager;
 

or so, right at the beginning of your program, perhaps even in main(). The book from which you got this code *ought* to explain why this works, although perhaps it doesn't... again in my opinion singletons are not the best solution to this and I much prefer the asset management outlined in SFML Game Development. At the very least there should be an assert that sInstance != nullptr in LoadTexture()/LoadFont() etc, this would indicate right away the reason for the crash.

Riser

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: glFlush() error.
« Reply #18 on: September 25, 2020, 12:47:50 am »
Alright it worked!
Thank you, I'm planning on reading all the other SFML books at some point and learn better practices, but for now I'm satisfied with the results.
The derived player class also works fine and I removed the texture member and instead called the asset manager directly as an argument:
entity_sprite = spr.set_sprite(AssetManager::LoadTexture("res/wildcard.png"), { 0,0,36,63 }, { 36,63 });

I'm gonna go and update the SFML library when I feel like it, but for now, thank you both, your help was invaluable, seriously, thank you so much!

 

anything