扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
|
//add in the header file of view class public: CClientDC* m_pDC; HGLRC m_hRC; //add in the init() function of view class m_hRC = wglCreateContext(m_pDC->GetSafeHdc()); |
//add in the OnDraw() function of view class //set current device wglMakeCurrent(m_pDC->GetSafeHdc(), m_hRC); |
//add in the header file of child view class //view ID, it will be assigned by parentframe when this program begin //[childviewA id = 1; childviewB id = 2] int m_ViewID |
//add in the OnCreate() function of CMainFrame class AssignViewID(); //the definition of AssignViewID() void CMainFrame::AssignViewID() { CEdit3DMDoc* pdoc = (CEdit3DMDoc*)m_pMainView->GetDocument(); if(pdoc) { POSITION pos = pdoc->GetFirstViewPosition(); CView* pview; int tempid = 1; while (pos != NULL) { pview = pdoc->GetNextView(pos); if (pview->IsKindOf(RUNTIME_CLASS(CChildOGLView))) { CChildOGLView* pchildview = (CChildOGLView*)pview; pchildview->m_ViewID = tempid; tempid += 1; } } } } |
//add in the OnCreate() function of child view class AddMetoDoc(); //the definition of AddMetoDoc() void CChildOGLView::AddMetoDoc() { CEdit3DMDoc* pdoc = (CEdit3DMDoc*)GetDocument(); if(pdoc != NULL) { pdoc->AddView(this); } } |
//in the DrawScene() function of main view //To get the current view type ViewType currentviewtype; CMainFrame* pframe = (CMainFrame*)GetParentFrame(); currentviewtype = pframe->m_ViewArrange.m_MainViewType; glViewport(0, 0, m_oldRect.right, m_oldRect.bottom); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); CEdit3DMDoc* pdoc = GetDocument(); if(pdoc != NULL) { pdoc->m_3DMani.SetProjection(currentviewtype, 0); pdoc->m_3DMani.DrawBound(currentviewtype); } glFinish(); SwapBuffers(wglGetCurrentDC()); //in the DrawScene() function of child view ViewType currentviewtype; CMainFrame* pframe = (CMainFrame*)AfxGetMainWnd(); if(m_ViewID == 1) { currentviewtype = pframe->m_ViewArrange.m_ChildViewAType; } else if(m_ViewID == 2) { currentviewtype = pframe->m_ViewArrange.m_ChildViewBType; } glViewport(0, 0, m_oldRect.right, m_oldRect.bottom); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); CEdit3DMDoc* pdoc = GetDocument(); if(pdoc != NULL) { pdoc->m_3DMani.SetProjection(currentviewtype, 0); pdoc->m_3DMani.DrawBound(currentviewtype); } glFinish(); SwapBuffers(wglGetCurrentDC()); |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者