Page 1 of 1

OpenGL in VC++

Posted: Sun Jun 06, 2010 11:26 am
by XianForce
Well, to start off, I love VC++ and I'd love to start using OpenGL. I started using VC++ because I couldn't get OpenGL to work with Code::Blocks, and so I switched. Unfortunately I couldn't get it to work with VC++ either.

So basically I just copy + paste the code from LazyFoo or NeHe, and put it into a project and compile it. It's all fine, no build errors.

But when I run it I get an Access Violation:

Code: Select all

Unhandled exception at 0x0431f2c0 in testOGL.exe: 0xC0000005: Access violation
That mem address isn't exactly the same each time. Another time it was this:

Code: Select all

Unhandled exception at 0x0443f2c0 in testOGL.exe: 0xC0000005: Access violation.
Anyways, davidthefat posted an OpenGL app that I ran without even thinking. It ran fine, and when I realized my computer was successfully using OpenGL, I started working with it again.

I compiled it in Code::Blocks and it worked.

But I'm not a huge fan of Code::Blocks, I'd rather use VC++.

So anyone have any ideas of what the problem might be? Because at the moment, I haven't the slightest clue of what to do.

Thanks in advance for any responses =D.

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 1:04 pm
by Falco Girgis
I'm guessing it has to do with the dynamic linking of your library. Probably an incompatible OpenGL DLL? Where did you get it from? You might have to compile it yourself.

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 1:40 pm
by K-Bal
Try using a debugger and see at which line the exception is raised.

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 3:48 pm
by XianForce
K-Bal wrote:Try using a debugger and see at which line the exception is raised.
Done that. It's on glClear. And if I comment that out, it's another line, if I comment that out it's another, and so on and so forth until no OpenGL code exists.

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 3:49 pm
by XianForce
GyroVorbis wrote:I'm guessing it has to do with the dynamic linking of your library. Probably an incompatible OpenGL DLL? Where did you get it from? You might have to compile it yourself.
It was just one that was already in my windows folder I'm assuming. I never actually went out and 'got' an OpenGL DLL...

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 4:25 pm
by Falco Girgis
XianForce wrote:
GyroVorbis wrote:I'm guessing it has to do with the dynamic linking of your library. Probably an incompatible OpenGL DLL? Where did you get it from? You might have to compile it yourself.
It was just one that was already in my windows folder I'm assuming. I never actually went out and 'got' an OpenGL DLL...
Windows ships with OpenGL? What the fuck? Really?

Windows XP didn't. I'm running Windows 7, but I've never checked... hrm...

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 4:43 pm
by combatant936
GyroVorbis wrote:
XianForce wrote:
GyroVorbis wrote:I'm guessing it has to do with the dynamic linking of your library. Probably an incompatible OpenGL DLL? Where did you get it from? You might have to compile it yourself.
It was just one that was already in my windows folder I'm assuming. I never actually went out and 'got' an OpenGL DLL...
Windows ships with OpenGL? What the fuck? Really?

Windows XP didn't. I'm running Windows 7, but I've never checked... hrm...
If for some reason Windows doesn't already come with it (which I always thought it did), I guess it'd have to be installed with video card drivers.

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 5:21 pm
by XianForce
GyroVorbis wrote:
XianForce wrote:
GyroVorbis wrote:I'm guessing it has to do with the dynamic linking of your library. Probably an incompatible OpenGL DLL? Where did you get it from? You might have to compile it yourself.
It was just one that was already in my windows folder I'm assuming. I never actually went out and 'got' an OpenGL DLL...
Windows ships with OpenGL? What the fuck? Really?

Windows XP didn't. I'm running Windows 7, but I've never checked... hrm...
Well maybe WINDOWS didn't come with it. If it wasn't windows, I'd assume the ATI Driver manager I installed

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 7:14 pm
by Falco Girgis
Oh yeah, must be from your video card drivers. Windows DEFINITELY doesn't come with it. At least not when I installed Windows 7.

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 7:46 pm
by Live-Dimension
Visual Studio ships with a VERY, VERY old version of OGL back from win98 days (1.1 I think).

Re: OpenGL in VC++

Posted: Sun Jun 06, 2010 8:22 pm
by XianForce
So does anyone have any idea for a solution haha?

Re: OpenGL in VC++

Posted: Mon Jun 07, 2010 8:27 am
by Falco Girgis
It still sounds like a dynamic linking problem to me. Sounds like it's shitting its pants every time Windows tries to link against the lib dynamically. I would try finding a STATIC build of OpenGL (.lib) and see if you get any linker issues. That would at least tell you at compile-time what the hell is going on...

Re: OpenGL in VC++

Posted: Mon Jun 07, 2010 10:01 am
by XianForce
GyroVorbis wrote:It still sounds like a dynamic linking problem to me. Sounds like it's shitting its pants every time Windows tries to link against the lib dynamically. I would try finding a STATIC build of OpenGL (.lib) and see if you get any linker issues. That would at least tell you at compile-time what the hell is going on...
Alright thanks. I'll have to look around some more; can't seem to find a static lib file >.>.

So if anyone knows where I can easily dl one, let me know =D.

EDIT: Well I can't find any static lib, and I keep hearing from plenty people that it's impossible to get a static build of OpenGL, because the functions are actually defined in the drivers...?