MSVS 2010 Professional with OpenGL

I know there are quite a few tutorials and walk-throughs on this subject, but every time I’ve tried to follow along I’ve failed miserably. Can someone please walk me through step-by-step in the simplest words possible on how to get Microsoft Visual Studio 2010 Professional edition setup with OpenGL? For example, could someone show me as detailed as possible where to import which files and then a simple sample program to run that proves that it worked? I’m sure a few of you would like to redirect me to another link that shows how this is done, but I would like to reiterate that I’ve tried all that I could find, and the tutorials seem to expect one to be a master at importing libraries :p.

Thank you!

Do you really mean ‘import files’, because that is not a trivial task for an OpenGl beginner. Have you been able to compile, link, and execute a simple OGL program yet? That should be your first objective. Actually, I can think of something even more basic than that. Have you been able to compile and run a simple ‘Hello World’ program (with no graphics)? If you can do that it means you’ve downloaded and installed MVC 2010 correctly, and have learned the basics of writing a C(++) program. If you can do that, you’re ready to move on to OpenGL.

If you can do that, you’re ready to move on to OpenGL.

I strongly disagree.

Graphics programming is not something that should be undertaken by someone fresh from “Hello World.” And certainly not in C/C++; maybe Python/GL would be a better fit, but probably not even then.

The simple fact is that graphics programming is not a beginning programmer-level task. If you just learned how to compile and execute a program, OpenGL is a good 3 months of learning away from being a viable thing you can handle.

Oh okay, let me readdress that, I was much too vague. I’m new to OpenGL, but I’m not new to programming. I’ve been programming in C++ for a while now. But now I’m interested in learning OpenGL so I’m trying to work it with MSVS 2010. I’ve been studying out of “Beginning OpenGL: Game Programming”, and I’ve learned quite a bit about programming with the graphics library. I’ve just never been able to successfully compile and run even the simplest of OpenGL Win32 applications with MSVS 2010 since I’ve begun my endeavors, and it has left me quite vexed. I’ve been trying to use the simplest of OpenGL program samples I’ve located online and tried to simply run them in MSVS 2010, but I’ve yet to get anything to work. And each time I try to build a new simple OpenGL program, it seems to give me a different error. I thought I’d correctly placed all the necessary header files and libraries (in the C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib & C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include folders, yes?), but I’ve still not had a single successful build.

Could someone perhaps provide me with a simple Win32 OpenGL program that might work or show me what might be wrong? Is there something wrong with MSVS 2010?

So, have you been able to write, compile, and execute a simple ‘Hello World’ program (with no graphics) in VC++ 2010? If so, download NeHe Tutorial #1 and see how far you get.

I thought I’d correctly placed all the necessary header files and libraries (in the C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib & C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include folders, yes?)

I would strongly suggest never, ever touching anything in those directories at all. If you have extra headers, make a directory for them and tell Visual Studio where to look to find them. If you have some global libraries that you use for multiple projects, make a directory for them and tell Visual Studio where to look to find them.

Windows isn’t like Linux, where there’s some kind of global registry for every library you could ever want to use. You should put things in a particular place, but never in the Windows SDK directory.

Could someone perhaps provide me with a simple Win32 OpenGL program that might work or show me what might be wrong?

How could we show you what’s wrong? You’ve never said what the actual problem is. You say that you get errors, but you didn’t say what those errors are. You haven’t shown us code or the errors you get. We’re not telepathic; we can’t solve a problem unless you tell us what the problem is.

In any case, the tutorials in my signature have a download package of source code that works. Whether it works for you is another question, as your tampering in Windows directories may have damaged your install. But you can give them a try.

So, have you been able to write, compile, and execute a simple ‘Hello World’ program (with no graphics) in VC++ 2010?

This: “I’ve been programming in C++ for a while now,” would seem to indicate that he’s well past that.

Yes. But if he’s been programming in a Unix/Linux environment, his problem might simply be getting used to VC++. FWIW, I just compiled, linked, and executed a simple OGL program using VC++ 2010 Express. However, I used GLUT to do my windowing. So, another way to go, besides NeHe, is to Google Glut. There are many simple OpenGL programs are posted with source code.

Just done one using Win32 here, worked perfectly.

To the OP: you don’t actually need to get MSVC 2010 “set up with OpenGL”. Everything needed to write OpenGL programs is already right there in the install, already set up for you. All that you need to do is #include <gl/gl.h>, link to opengl32.lib, and start writing code.

[quote=“MaxH”]

Yes. But if he’s been programming in a Unix/Linux environment, his problem might simply be getting used to VC++. FWIW, I just compiled, linked, and executed a simple OGL program using VC++ 2010 Express. However, I used GLUT to do my windowing. So, another way to go, besides NeHe, is to Google Glut. There are many simple OpenGL programs are posted with source code. [/QUOTE]

Some of the NeHe examples use GLUT.
Each tutorial has multiple versions using different IDEs and different languages and different wrappers.

That.

How do I do that?

That’s about the only thing I haven’t gotten to work yet.

I’ve found an option for “Import Library” in view>Properties>General Properties>Linker>Advanced, but I’m not sure whether it needs a folder, a file, or a list of files, or how to format/delimit a list of files, and if experimenting with it could be fine, or bugger up my whole project, or my MSVS installation.

Right now, all my libraries are in C:\gl\lib. So, what would be the best way to link them?

I like using #pragma comment directive.
In the StdAfx.h (or some other proper place) add the following line:

#pragma comment(lib,“C:\GL\opengl32.lib”)

If there are more libraries you can add them the same way.

Go to the properties of the project, go to Linker / Input / Additional Dependencies.

Add the following to the beginning of what’s there:

opengl32.lib;

It’s a semicolon delimited list of lib files to link against.

You’ll have to update debug and release builds separately.

You don’t even need to go that far.

#pragma comment (lib, "opengl32.lib")

is sufficient; the correct path to it will already be set up as part of your install so you don’t need to worry about absolute or relative paths, where the library is located, setting up or installing anything yourself, etc. You can add that line to any C or C++ file in your project; it doesn’t matter, and you just need to add it once (i.e. to one file) for the library to be accessible to your entire project.

I strongly do not recommend NeHe tutorials.

They are old and deprecated, and you can not even learn computer graphics through NeHe’s tutorials.

They were good in the past and great, however it did not get well maintained.

I recommend you start directly from OpenGL 3.3+ coding without learning deprecated code, which is make you easier to catch up, even quicker than old OpenGL programmer.

a good tutorial is here

http://www.arcsynthesis.org/gltut/

this one is very new started from 2011.