OpenGL in VC++

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

OpenGL in VC++

Post 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.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: OpenGL in VC++

Post 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.
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: OpenGL in VC++

Post by K-Bal »

Try using a debugger and see at which line the exception is raised.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: OpenGL in VC++

Post 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.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: OpenGL in VC++

Post 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...
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: OpenGL in VC++

Post 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...
User avatar
combatant936
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Wed Jul 29, 2009 11:11 pm
Current Project: It's a secret!!
Favorite Gaming Platforms: N64, SNES, PS2, PC
Programming Language of Choice: C++, 65816 asm
Location: Pennsylvania
Contact:

Re: OpenGL in VC++

Post 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.
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: OpenGL in VC++

Post 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
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: OpenGL in VC++

Post 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.
Live-Dimension
Chaos Rift Junior
Chaos Rift Junior
Posts: 345
Joined: Tue Jan 12, 2010 7:23 pm
Favorite Gaming Platforms: PC - Windows 7
Programming Language of Choice: c++;haxe
Contact:

Re: OpenGL in VC++

Post by Live-Dimension »

Visual Studio ships with a VERY, VERY old version of OGL back from win98 days (1.1 I think).
Image
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: OpenGL in VC++

Post by XianForce »

So does anyone have any idea for a solution haha?
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: OpenGL in VC++

Post 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...
XianForce
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 767
Joined: Wed Oct 29, 2008 8:36 pm

Re: OpenGL in VC++

Post 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...?
Post Reply