Sign in to follow this  
guyver23

OpenGL and Windows Forms

Recommended Posts

Hi. My Computer Science I class is built around the study of the Windows forms technology, and we are learning C++ through this. I am familiar with standard C++, and I was wondering if I could somehow use this environment to learn OpenGL? I don't really have a firm grasp of Win32 programming anymore, which is why I ask. Also, will my Visual C++ .NET Express Edition rebel if I try using standard C++ code? Is there any way to do this? Thanks!

Share this post


Link to post
Share on other sites
Iam using VC++ 2005 Expres and it dont rebel when i use standard win32 functions and OpenGL. You have probably some strange project settings. And for win32 functions .. it is only few lines of code, for which you can Copy&Paste from somewhere else.

Share this post


Link to post
Share on other sites
Quote:
Original post by guyver23
Also, will my Visual C++ .NET Express Edition rebel if I try using standard C++ code? Is there any way to do this?


What language do you expect it to want you to use?

Share this post


Link to post
Share on other sites
I am sure there was a better way of expressing that thought. For instance, instead of using the standard string.h stuff, we use System::String. And to convert numbers we use variable.toString. I know none of that is standard C++ code, but our instructor won't explain what this stuff is called or how it interacts with standard C++, because he considers this to be be the new way everyone is going to program, and that standard C++ is outdated.

Hence my own confusion. =(

Share this post


Link to post
Share on other sites
Quote:
Original post by guyver23
I am sure there was a better way of expressing that thought. For instance, instead of using the standard string.h stuff, we use System::String. And to convert numbers we use variable.toString. I know none of that is standard C++ code, but our instructor won't explain what this stuff is called or how it interacts with standard C++, because he considers this to be be the new way everyone is going to program, and that standard C++ is outdated.

Hence my own confusion. =(



If your instructor is teaching you to use System::String over the standards compliant and cross-platform std::string, then he/she is not the best person for teaching C++ IMO.

In windows as long as you can get the handle of a form or control you can pretty much always create an OpenGL context with it. IIRC creating a rendering context from a handle is something like:

hDC = GetDC(hWnd)
hRC = wglCreateContext(hDC)
wglMakeCurrent(hDC,hRC)

Where hWnd is the window handle. You'll have to set a pixel format somewhere as well, and handle OnPaint/OnSize events too.

Take a look at tutorial 1 of NeHe and use chunks from the windows creation code but instead of getting a window handle from CreateWindow, just use the one from the control.

I hope that makes sense.

Luke.

P.S. If you just want to create a standalone window and not OpenGL on one of those forms, just use tutorial 1 in its entirety.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this