Jump to content
  • Advertisement
Sign in to follow this  
JPSelter

OpenGL Simple MFC/OpenGL Tutorial needed

This topic is 4438 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I´m new to MFC and I have found some tutorials for creating a window-based OpenGL application. But how do I do OpenGL inside a MFC control? I found this tutorial here: http://www.3dsource.de/faq/mswindows.htm#mswi0160 but the link to the example code is dead. Can someone help on on how I can create an OpenGL window inside a GroupBox (or Static, doesn´t matter). Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Try these:

http://www.gamedev.net/reference/articles/article1802.asp

http://www.gamedev.net/reference/articles/article1358.asp

-JT


Share this post


Link to post
Share on other sites
Thanks, looks good so far. I will work through them...

Another question: How difficult is it to use two OpenGL windows at a time? What shall I do when always only one window is visible at a time? I´m using a TabControl ...

Share this post


Link to post
Share on other sites
http://www.gamedev.net/reference/articles/article1358.asp

This article shows 4 OpenGL views simultaneously. That would be a good place to start. You can just make various numbers of OpenGL rendering contexts. This article is definitely what you are looking for.

-JT

Share this post


Link to post
Share on other sites
The latter article seems a bit too heavy for me. What I have in my OpenGLInit-Class so far:

void COpenGLInit::InitOpenGL()
{
static PIXELFORMATDESCRIPTOR pfd=
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW|
PFD_SUPPORT_OPENGL|
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24, //24-bit color
0,0,0,0,0,0,
0,0,0,0,0,0,0,
32, //32 bit depth buffer
0,0,
PFD_MAIN_PLANE, //Main layer type
0,
0,0,0
};
HWND wnd= GetDlgItem(hWnd, IDC_OPENGL);
HDC hDC = GetDC(wnd);
GLuint PixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC,PixelFormat,&pfd);
HGLRC hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);

glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}


Right now I don´t see anything inside my control IDC_OPENGL, but I know I need to create a draw-function inside OnDraw or OnPaint (btw what is the difference?). Somehow I need a "next step".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!