SFML community forums

Help => Graphics => Topic started by: Nexus on September 02, 2008, 08:59:57 pm

Title: sf::WindowSettings access violation
Post by: Nexus on September 02, 2008, 08:59:57 pm
Hi,
when I use the following code:
Code: [Select]
sf::WindowSettings Settings(24, 8, 4);
sf::RenderWindow App(sf::VideoMode(500, 300), "app", sf::Style::Close, Settings);
or
Code: [Select]
sf::RenderWindow App(sf::VideoMode(500, 300), "app", sf::Style::Close, sf::WindowSettings(24, 8, 4));, I get the following error:
Quote
Uncaught exception at 0x00000000 in Project.exe: 0xC0000005: Access violation.   (translated)

If I set the AntiAliasing value to zero, it works just fine. Every other value leads to crash.
When running in debug mode, it stops in file "WindowImplWin32.cpp" at line 450 (function WindowImplWin32::CreateContext()). The code in this line is:
Code: [Select]
bool  IsValid = wglChoosePixelFormatARB(myDeviceContext, IntAttributes, FloatAttributes, sizeof(Formats) / sizeof(*Formats), Formats, &NbFormats) != 0;The variable myDeviceContext seems to be corrupted, myHandle too. wglChoosePixelFormatARB shows the value 0 (0x00000000), IsValid is true...

The problem is, I reinstalled MSVC++ and redownloaded SFML some days ago - before everything worked fine. I also recompiled the SFML libraries, and I think I am linking to the correct version.

Maybe it's not SFML's fault, since it always worked in past... But I can't really imagine how this can happen...?
Title: sf::WindowSettings access violation
Post by: Laurent on September 02, 2008, 09:26:11 pm
Are you linking to the debug libraries in debug build ?
Title: sf::WindowSettings access violation
Post by: Nexus on September 02, 2008, 10:38:58 pm
Yes, in debug mode I link to:
sfml-window-s-d.lib sfml-system-s-d.lib sfml-graphics-s-d.lib

And in release to:
sfml-window-s.lib sfml-system-s.lib sfml-graphics-s.lib

The access violation occurs in both release and debug build. At debug only I get to the file where the error occurs...

But as I said, it's really strange, I'm not sure at all if it's a SFML problem because I haven't ever had this yet.
Title: sf::WindowSettings access violation
Post by: Nexus on September 10, 2008, 03:24:07 pm
Now I reinstalled MSVC++ and downloaded the newest SFML svn version. Unfortunately, the problem further exists. I really don't know what I can do...

Isn't there anyone having similar problems? Is there certainly no bug or something in sf::WindowSettings or sf::RenderWindow?

P.S.: The error occurs both in static and dynamic link against SFML.
Title: sf::WindowSettings access violation
Post by: zarka on September 10, 2008, 05:29:10 pm
what kind of graphics card do you use ? ... he does invoke an ARB function .. which could possibly be NULL since i belive it depends on your graphics driver ...
Title: sf::WindowSettings access violation
Post by: Nexus on September 10, 2008, 07:26:03 pm
I use a NVIDIA GeForce 6100 nForce 405. I updated its driver, but the result remains the same.

Some weeks ago, i had to reinstall windows on this computer. Before everything went perfectly, it's really strange... :roll:
Title: sf::WindowSettings access violation
Post by: Avency on September 11, 2008, 02:38:33 pm
I now noticed the same problem.
On my new computer everything runs fine, but on my old computer, there are problems with the ati opengl driver (crash - atioglxx.dll). I get the same error code
Code: [Select]
0xC0000005
An older compile however runs fine.
Title: sf::WindowSettings access violation
Post by: kdmiller3 on September 11, 2008, 10:49:42 pm
I get the same problem.  It looks like wglGetProcAddress("wglChoosePixelFormatARB") in WindowImplWin32::CreateContext() returns NULL, so the attempt to use it crashes.  I'm running an NVIDIA GeForce 8800GTX with driver version 175.19 if it matters.

SDL's ChoosePixelFormatARB function creates a (dummy) window, gets the device context, sets the pixel format, creates an OpenGL context, finds the wglGetExtensionsStringARB function, uses that (if found) to get extensions, finds the wglChoosePixelFormatARB function, uses that (if found) to pick a pixel format, releases the OpenGL context, releases the device context, and destroys the window.  Only then does it use that pixel format to create a new window with the appropriate OpenGL context.

From what I've read, those functions require a functioning OpenGL context to work, even if that means you have to create a dummy one first.
Title: sf::WindowSettings access violation
Post by: Laurent on September 12, 2008, 11:03:26 am
Ok I see, I recently changed this part of the code. I'll fix this issue as soon as possible.

Thanks for your feedbacks :)
Title: sf::WindowSettings access violation
Post by: Laurent on September 12, 2008, 03:11:29 pm
Is everything ok now ?
Title: sf::WindowSettings access violation
Post by: Avency on September 12, 2008, 03:56:33 pm
Ok, I did a clean svn checkout, but it's still not working.
BTW: It works on my 8800GTX, as opposed to kdmiller3s one.
Title: sf::WindowSettings access violation
Post by: Laurent on September 12, 2008, 04:02:31 pm
Are you creating your window at global startup ?
Title: sf::WindowSettings access violation
Post by: Nexus on September 12, 2008, 04:29:06 pm
At me it works now. Thanks a lot, Laurent! :)

BTW: In the last days, performance of SFML was very bad in my programs. This seems to be fixed now, too! Thank you!
Title: sf::WindowSettings access violation
Post by: Avency on September 12, 2008, 05:00:42 pm
I also compiled the opengl-sample, which produces the same error.
Title: sf::WindowSettings access violation
Post by: kdmiller3 on September 13, 2008, 07:21:57 am
Yup, that works for me too.  Hurrah!
Title: sf::WindowSettings access violation
Post by: Avency on October 02, 2008, 04:38:24 pm
Does anyone use the svn-version of sfml in combination with an ati card?
So far all my experiments with various ati cards have failed.