主要的使用順序就是這樣
1.SetupPixelFormat
2.wglCreateContext
3.wglMakeCurrent
4.InitGL
詳細的程式碼要參考 Ref 的連結說明
void CFunction005Dlg::OnBnClickedBtnDipBoneSrch()
{
m_ShowHDC = GetDlgItem(IDC_Show_Bone)->GetDC()->GetSafeHdc();
if(!SetupPixelFormat(m_ShowHDC))
{
AfxMessageBox("Error01");
}
if(!(m_HGLRC = wglCreateContext(m_ShowHDC)))
{
AfxMessageBox("Error02");
}
if(!wglMakeCurrent(m_ShowHDC, m_HGLRC)) // Try To Activate The Rendering Context
{
AfxMessageBox("Can't Activate The GL Rendering Context.");
}
ReSizeGLScene(320, 240); // Set Up Our Perspective GL Screen
if (!InitGL()) // Initialize Our Newly Created GL Window
{
MessageBox("Initialization Failed.","ERROR");
}
DrawGLScene();
SwapBuffers(m_ShowHDC);
}
example code
http://min.us/l5clRLosX7crD
[Ref.]
http://johnniebooks.blogspot.com/2009/07/mfcopengl.html (good/detail)
http://johnniebooks.blogspot.com/2009/07/windowsopengl.html (good/detail)
http://www.nullterminator.net/opengl32.html
http://www.cnblogs.com/phinecos/archive/2008/11/05/1327011.html