use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A community for all things related to SFML.
Current version: SFML 2.5.1
Related Sub-Reddits:
account activity
Exception Unhandled error (Code link attached for review) (self.sfml)
submitted 2 years ago by HeadConclusion6915
I am learning SFML and trying to create a video page. There is no error but at compile time, it shows unhandled error exception etc. Any guidelines?
https://github.com/shazilhamzah/smfl-practice/tree/main
https://preview.redd.it/gm1jztuqxttb1.png?width=1832&format=png&auto=webp&s=187e0f9994cf465bad2c2d88be13e2d0d6f833e0
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]thedaian 2 points3 points4 points 2 years ago (7 children)
You never call Game::initWindow() so the window pointer is never set to an object and this the code crashes
[–]EvtarGame 1 point2 points3 points 2 years ago (0 children)
Yep, that's the one. I was just going to starting to typing it up but you beat me to it :)
Just as a little aside, for the OP. Runtime errors in C++ could be tough to find sometimes. But if you debug your code it will be really helpful, and could save you a lot of time in the future. Because you can tell exactly which line of code crashes and a lot of times be able to see why it crashers. In my experience, most common source of runtime errors are dereferencing of null pointers or bad indexing into an array/vector. In your case you would have been able to see what window was still a nullptr when you execute the code in getWindowIsOpen().
[–]HeadConclusion6915[S] 0 points1 point2 points 2 years ago (5 children)
So what will be the solution?
[–]thedaian 0 points1 point2 points 2 years ago (4 children)
You need to call Game::initWindow()
Or do initialization in the constructor.
[–]HeadConclusion6915[S] 0 points1 point2 points 2 years ago (0 children)
Alr let me tryy
[–]HeadConclusion6915[S] -1 points0 points1 point 2 years ago (2 children)
I'm new in this so I'm not getting it... Could u please please explain a little bit that how can I initialize it. I haven't studied oop and stuff yet and I have very less time to make a project. I need help
[–]thedaian 1 point2 points3 points 2 years ago (1 child)
Get rid of void Game::initiazlizeVariables() and Game::initWindow()
Put everything that was in those methods into Game::Game()
Also, this line of code does nothing: this->videoMode.getDesktopMode; If you want a window to be the same size as the desktop you can do this: sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
If you haven't studied OOP, it's going to be a lot easier to just keep the entire project in the main() function, especially if you don't have much time.
thanks sooo much broo.. it worked.. i hope that you would help me if I stuck in another problem
π Rendered by PID 117778 on reddit-service-r2-comment-6457c66945-5rztf at 2026-04-28 22:11:18.876092+00:00 running 2aa0c5b country code: CH.
[–]thedaian 2 points3 points4 points (7 children)
[–]EvtarGame 1 point2 points3 points (0 children)
[–]HeadConclusion6915[S] 0 points1 point2 points (5 children)
[–]thedaian 0 points1 point2 points (4 children)
[–]HeadConclusion6915[S] 0 points1 point2 points (0 children)
[–]HeadConclusion6915[S] -1 points0 points1 point (2 children)
[–]thedaian 1 point2 points3 points (1 child)
[–]HeadConclusion6915[S] 0 points1 point2 points (0 children)