Sign in to follow this  
JPSelter

OpenGL Simple MFC/OpenGL Tutorial needed

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
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

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