Bonjour
J'utilise OSG sur un logiciel de modélisation physique.
Je créer d'abord une fenêtre en MFC non modal avec le code suivant :
Et j'y applique ma scène 3D avec le code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 CDialog * m_pSimpleDlg = new CDialog(); BOOL ret = m_pSimpleDlg->Create(IDD_DIALOG8); m_pSimpleDlg->ShowWindow(TRUE); HWND hWnd = m_pSimpleDlg->GetSafeHwnd();
Mon problème est que lorsque je créer la fenêtre MFC sans y appliquer ma scène 3D la fenêtre reste non modal mais s'y j'y applique la scène 3D la fenêtre devient modal et il met impossible d'utiliser le logiciel par la suite.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 RECT rect; // Create the viewer for this window singleViewer = new osgViewer::Viewer(); // Add a stats Handler to the viewer singleViewer->addEventHandler(new osgViewer::StatsHandler); // Get the current window size ::GetWindowRect(hWnd, &rect); // Init the GraphicsContext Traits osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; // Init the Windata Variable that holds the handle for the Window to display OSG in. osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(hWnd); // Setup the traits parameters traits->x = 0; traits->y = 0; traits->width = rect.right - rect.left; traits->height = rect.bottom - rect.top; traits->windowDecoration = false; traits->doubleBuffer = true; traits->sharedContext = 0; traits->setInheritedWindowPixelFormat = true; traits->inheritedWindowData = windata; // Create the Graphics Context osg::GraphicsContext* gc = osg::GraphicsContext::createGraphicsContext(traits.get()); // Init Master Camera for this View osg::ref_ptr<osg::Camera> camera = singleViewer->getCamera(); // Assign Graphics Context to the Camera camera->setGraphicsContext(gc); // Set the viewport for the Camera camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height)); // set the draw and read buffers up for a double buffered window with rendering going to back buffer camera->setDrawBuffer(GL_BACK); camera->setReadBuffer(GL_BACK); // Set projection matrix and camera attribtues camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); camera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f)); camera->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width) / static_cast<double>(traits->height), 1.0, 1000.0); singleViewer->setCamera(camera.get()); view = singleViewer; view->setSceneData(root.get());
Commet faire en sorte que la fenêtre MFC reste non modal après que j'y applique la scène 3D ?
Merci d'avance
Partager