Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
GraphicsWindowWX.h
1 #pragma once
2 
3 #include <osgViewer/Viewer>
4 #include <osgViewer/GraphicsWindow>
5 #include "wx/glcanvas.h"
6 
7 class LocalGLContext;
8 class wxGLCanvas;
9 
10 #ifndef __WXMAC__
11 class LocalGLContext : public wxGLContext
12 {
13 public:
14  LocalGLContext(wxGLCanvas *win, const wxGLContext* other=NULL /* for sharing display lists */ )
15  : wxGLContext(win, other)
16  {
17  }
18 
19  void ReleaseContext(const wxGLCanvas& win)
20  {
21 #if defined(__WXMSW__)
22  wglMakeCurrent((HDC) win.GetHDC(), NULL);
23 #endif
24  }
25 };
26 #endif
27 
28 class GraphicsWindowWX : public osgViewer::GraphicsWindow
29 {
30 public:
31  GraphicsWindowWX(wxGLCanvas *pCanvas);
33 
34  void SetCanvas(wxGLCanvas *pCanvas)
35  {
36  m_pCanvas = pCanvas;
37  }
38  void CloseOsgContext();
39  bool makeCurrentImplementation();
40  void swapBuffersImplementation();
41 
42  virtual bool releaseContextImplementation();
43  virtual void closeImplementation();
44  virtual bool realizeImplementation();
45 
46  virtual bool valid() const
47  {
48  return m_bValid;
49  }
50  virtual bool isRealizedImplementation() const
51  {
52  return m_bIsRealized;
53  }
54 
55 private:
56  wxGLCanvas* m_pCanvas;
57 #ifndef __WXMAC__
58  LocalGLContext *m_pGLContext;
59 #endif
60  bool m_bIsRealized;
61  bool m_bValid;
62 };