]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/glcanvas/win/glcanvas.cpp
Added comments explaining my recent changes
[wxWidgets.git] / utils / glcanvas / win / glcanvas.cpp
index fd1e1ef44baeb9b2e15c3e106d5f98fee5769b9d..aee52f2f2a03b67ddcb26503eb9450945ad03453 100644 (file)
@@ -29,7 +29,7 @@
 
 wxChar wxGLCanvasClassName[]        = wxT("wxGLCanvasClass");
 
-LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
+LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
                                    WPARAM wParam, LPARAM lParam);
 
 /*
@@ -48,8 +48,8 @@ wxGLContext::wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette)
   wglMakeCurrent((HDC) m_hDC, m_glContext);
 }
 
-wxGLContext::wxGLContext( 
-               bool isRGB, wxGLCanvas *win, 
+wxGLContext::wxGLContext(
+               bool isRGB, wxGLCanvas *win,
                const wxPalette& palette,
                const wxGLContext *other        /* for sharing display lists */
 )
@@ -129,24 +129,35 @@ END_EVENT_TABLE()
 wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id,
     const wxPoint& pos, const wxSize& size, long style, const wxString& name,
     int *attribList /* not used yet! */, const wxPalette& palette):
-  wxScrolledWindow(parent, id, pos, size, style, name)
+  wxScrolledWindow()
 {
-  m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
+    m_glContext = (wxGLContext*) NULL;
 
-  SetupPixelFormat();
-  SetupPalette(palette);
+    bool ret = Create(parent, id, pos, size, style, name);
+
+    if ( ret )
+    {
+        SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+        SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+    }
+
+       m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
 
-  m_glContext = new wxGLContext(TRUE, this, palette);
+    SetupPixelFormat();
+    SetupPalette(palette);
+
+    m_glContext = new wxGLContext(TRUE, this, palette);
 }
 
-wxGLCanvas::wxGLCanvas( wxWindow *parent, 
+wxGLCanvas::wxGLCanvas( wxWindow *parent,
               const wxGLContext *shared, wxWindowID id,
               const wxPoint& pos, const wxSize& size, long style, const wxString& name,
               int *attribList, const wxPalette& palette )
   : wxScrolledWindow()
-//  : wxScrolledWindow(parent, id, pos, size, style, name)
-{                      
-    bool ret = Create(parent, id, pos, size, style, name);
+{
+   m_glContext = (wxGLContext*) NULL;
+
+   bool ret = Create(parent, id, pos, size, style, name);
 
     if ( ret )
     {
@@ -162,6 +173,33 @@ wxGLCanvas::wxGLCanvas( wxWindow *parent,
     m_glContext = new wxGLContext(TRUE, this, palette, shared );
 }
 
+// Not very usefull for wxMSW, but this is to be wxGTK compliant
+
+wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id,
+                        const wxPoint& pos, const wxSize& size, long style, const wxString& name,
+                        int *attribList, const wxPalette& palette ):
+  wxScrolledWindow()
+{
+    m_glContext = (wxGLContext*) NULL;
+
+    bool ret = Create(parent, id, pos, size, style, name);
+
+    if ( ret )
+    {
+        SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+        SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+    }
+
+       m_hDC = (WXHDC) ::GetDC((HWND) GetHWND());
+
+    SetupPixelFormat();
+    SetupPalette(palette);
+
+    wxGLContext *sharedContext=0;
+    if (shared) sharedContext=shared->GetContext();
+    m_glContext = new wxGLContext(TRUE, this, palette, sharedContext );
+}
+
 wxGLCanvas::~wxGLCanvas()
 {
   if (m_glContext)
@@ -180,6 +218,8 @@ bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
     // the CS_OWNDC style for GLCanvas.
 
 /*
+    From Angel Popov <jumpo@bitex.com>
+
     Here are two snips from a dicussion in the OpenGL Gamedev list that explains
     how this problem can be fixed:
 
@@ -220,6 +260,7 @@ bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
 
             return FALSE;
         }
+        registeredGLCanvasClass = TRUE;
     }
 
     wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") );