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

Author Topic: Window unhandled exception error  (Read 3861 times)

0 Members and 1 Guest are viewing this topic.

robvleugel

  • Newbie
  • *
  • Posts: 29
    • View Profile
Window unhandled exception error
« on: March 31, 2012, 02:13:56 pm »
Ugh now what, everything seemed to work fine yesterday, but today started to open my game again and I suffered from another breakpoint memory error. I deleted basicly all of my game code and it comes down to the code below:

It breaks at WglContext.cpp
Code: [Select]
void WglContext::display()
{
    if (m_deviceContext && m_context)
        SwapBuffers(m_deviceContext);
}


Output window:

+      m_context   0x00010002 {unused=0 }   HGLRC__ *
+      m_deviceContext   0x590118ed {unused=??? }   HDC__ *
+      this   0x09224fd0 {m_window=0x0010085a m_deviceContext=0x590118ed m_context=0x00010002 ...}   sf::priv::WglContext * const

My code:

Code: [Select]
#include <SFML\Graphics.hpp>

int main()
{
sf::RenderWindow m_app;
m_app.create(sf::VideoMode(500, 500, 32), "MyProgram");

while(true)
{
m_app.clear(sf::Color(65,5,23));
m_app.display();
}

return 0;
}


Because this code is so basic (and because the example program on the documentation website gives me the same error), it can't be my code right?
I downloaded the newest snapshot of SFML2 and build/installed it but it still gives me the same error.
I'm pretty sure I'm linking with the static debug libraries correctly, as I did not change anything and it used to work fine til today. Removing the "m_app.display();" makes it run.

Linking with:
sfml-system-s-d.lib;sfml-window-s-d.lib;sfml-graphics-s-d.lib;libpq.lib;%(AdditionalDependencies)


What is going on here? I'm completely clueless.

« Last Edit: March 31, 2012, 02:41:29 pm by robvleugel »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Window breakpoint error
« Reply #1 on: March 31, 2012, 02:28:21 pm »
I have no idea why there is 'breakpoint' in the title or description, also I don't quite get when it crashes.
SFML has some troubles with it's context handling so we need a little bit more information.
The code looks fine btw, although you should use #include <SFML/Graphics.hpp for various reasons. MSVC will understand it.
  • Which compiler do you use? (Okay it's obvious that you use MSVC, but always state this!)
  • What are your computer specs, specially GPU?
  • When does it break (start, exit, calling display(), etc.)?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

robvleugel

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Window breakpoint error
« Reply #2 on: March 31, 2012, 02:37:30 pm »
Ow sorry forgot about that, the error I get is:

Code: [Select]
"Unhandled exception at 0x0af28e0b in MyProgram.exe: 0x0000005: Acces violation reading location 0x0b0f7cf8

[Break] [Continue]

An error like this usually means reading to an unitialized variable.

Running in debug mode, it breaks when calling m_app.display();

I'm using MS Visual studio express edition, on a HP laptop running Windows 7 (intel i5 core with ATI mobility Radeon), 4gig ram.

« Last Edit: March 31, 2012, 02:40:43 pm by robvleugel »

robvleugel

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Window unhandled exception error
« Reply #3 on: March 31, 2012, 05:24:20 pm »
After rebooting my system everything works fine again.
Weird..

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Window unhandled exception error
« Reply #4 on: March 31, 2012, 06:51:55 pm »
Quote
After rebooting my system everything works fine again
You should always do that first, when something that has always worked suddenly breaks without any modification ;)
Laurent Gomila - SFML developer

robvleugel

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Window unhandled exception error
« Reply #5 on: March 31, 2012, 07:43:26 pm »
Quote
After rebooting my system everything works fine again
You should always do that first, when something that has always worked suddenly breaks without any modification ;)

Yeah, or pull the plug and put it back in.
That's actually how I could've fixed this one as well.
It seems my laptop changes to some other graphics mode when I remove the power cable to save on the battery. It turns out SFML does not work while in this mode, which is strange as most other applications run just fine. I had the power cable back in when this message appeared in the morning, but I guess I forgot to press the "change graphic mode" button on the popup that appears.

I can reproduce the error now simply by changing to this mode.