]> git.saurik.com Git - wxWidgets.git/commitdiff
made SetCurrent() and SwapBuffers() return boolean status indicator instead of void...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 22 Dec 2007 15:48:03 +0000 (15:48 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 22 Dec 2007 15:48:03 +0000 (15:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50900 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/glcanvas.tex
include/wx/glcanvas.h
include/wx/msw/glcanvas.h
include/wx/unix/glx11.h
src/common/glcmn.cpp
src/msw/glcanvas.cpp
src/unix/glx11.cpp

index c6e293d7ded69ca6a0e20875bdd6f2e71eef025a..771e056542ee98ebf9dbb69de2702366cbff574d 100644 (file)
@@ -127,7 +127,7 @@ Ignored under most platforms.}
 
 \membersection{wxGLCanvas::SetCurrent}\label{wxglcanvassetcurrent}
 
-\func{void}{SetCurrent}{ \param{const wxGLContext&}{ context} }
+\func{bool}{SetCurrent}{ \param{const wxGLContext&}{ context} }
 
 Makes the OpenGL state that is represented by the OpenGL rendering context
 \arg{context} current, i.e. it will be used by all subsequent OpenGL calls.
@@ -139,6 +139,8 @@ Note that this function may only be called when the window is shown on screen,
 in particular it can't usually be called from the constructor as the window
 isn't yet shown at this moment.
 
+Returns \false if an error occurred.
+
 
 \membersection{wxGLCanvas::SetColour}\label{wxglcanvassetcolour}
 
@@ -150,8 +152,10 @@ wxWidgets colour database to find a named colour.
 
 \membersection{wxGLCanvas::SwapBuffers}\label{wxglcanvasswapbuffers}
 
-\func{void}{SwapBuffers}{\void}
+\func{bool}{SwapBuffers}{\void}
 
 Swaps the double-buffer of this window, making the back-buffer the front-buffer and vice versa,
 so that the output of the previous OpenGL commands is displayed on the window.
 
+Returns \false if an error occurred.
+
index bb4ffa498a3a102f68b864c957cb5f8a127a6955..3ac73811c30d48180abc0caafae3a18349ad6dcd 100644 (file)
@@ -66,7 +66,7 @@ public:
      */
 
     // set this context as the current one
-    virtual void SetCurrent(const wxGLCanvas& win) const = 0;
+    virtual bool SetCurrent(const wxGLCanvas& win) const = 0;
 };
 
 // ----------------------------------------------------------------------------
@@ -99,10 +99,10 @@ public:
     // ----------
 
     // set the given context associated with this window as the current one
-    void SetCurrent(const wxGLContext& context) const;
+    bool SetCurrent(const wxGLContext& context) const;
 
     // flush the back buffer (if we have it)
-    virtual void SwapBuffers() = 0;
+    virtual bool SwapBuffers() = 0;
 
 
     // accessors
index 83362b016709f53e2a6c1dc17ae7c7f1e4ad9a8c..203816b4ea115f4b3951bce1724388475a0a8495 100644 (file)
@@ -28,7 +28,7 @@ public:
     wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL);
     virtual ~wxGLContext();
 
-    virtual void SetCurrent(const wxGLCanvas& win) const;
+    virtual bool SetCurrent(const wxGLCanvas& win) const;
 
     HGLRC GetGLRC() const { return m_glContext; }
 
@@ -67,7 +67,7 @@ public:
     virtual ~wxGLCanvas();
 
     // implement wxGLCanvasBase methods
-    virtual void SwapBuffers();
+    virtual bool SwapBuffers();
 
 
     // MSW-specific helpers
index b29462b7c6ab01376eeb7ceb74e5a443d2124c34..7f48e9189147713c464c3ff3c3b6818c31a7f6fb 100644 (file)
@@ -23,11 +23,11 @@ public:
     wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
     virtual ~wxGLContext();
 
-    virtual void SetCurrent(const wxGLCanvas& win) const;
+    virtual bool SetCurrent(const wxGLCanvas& win) const;
 
 private:
     // attach context to the drawable or unset it (if NULL)
-    static void MakeCurrent(GLXDrawable drawable, GLXContext context);
+    static bool MakeCurrent(GLXDrawable drawable, GLXContext context);
 
     GLXContext m_glContext;
 
@@ -57,7 +57,7 @@ public:
     // implement wxGLCanvasBase methods
     // --------------------------------
 
-    virtual void SwapBuffers();
+    virtual bool SwapBuffers();
 
 
     // X11-specific methods
index 0d85eab14c8cbacac696edb84566d2e3d9f7a60c..07db44d4c8073d436470bd07bf9681323c13475c 100644 (file)
@@ -52,14 +52,14 @@ wxGLCanvasBase::wxGLCanvasBase()
     SetBackgroundStyle(wxBG_STYLE_CUSTOM);
 }
 
-void wxGLCanvasBase::SetCurrent(const wxGLContext& context) const
+bool wxGLCanvasBase::SetCurrent(const wxGLContext& context) const
 {
     // although on MSW it works even if the window is still hidden, it doesn't
     // work in other ports (notably X11-based ones) and documentation mentions
     // that SetCurrent() can only be called for a shown window, so check for it
     wxASSERT_MSG( IsShownOnScreen(), _T("can't make hidden GL canvas current") );
 
-    context.SetCurrent(*wx_static_cast(const wxGLCanvas *, this));
+    return context.SetCurrent(*wx_static_cast(const wxGLCanvas *, this));
 }
 
 bool wxGLCanvasBase::SetColour(const wxString& colour)
index a95e48a54be6981ccbb149ff1fab0368433f4acb..2c5406e2fda528c42daf3e15da63f49626543884 100644 (file)
@@ -200,12 +200,14 @@ wxGLContext::~wxGLContext()
     wglDeleteContext(m_glContext);
 }
 
-void wxGLContext::SetCurrent(const wxGLCanvas& win) const
+bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
 {
     if ( !wglMakeCurrent(win.GetHDC(), m_glContext) )
     {
         wxLogLastError(_T("wglMakeCurrent"));
+        return false;
     }
+    return true;
 }
 
 // ============================================================================
@@ -313,10 +315,14 @@ bool wxGLCanvas::Create(wxWindow *parent,
 // operations
 // ----------------------------------------------------------------------------
 
-void wxGLCanvas::SwapBuffers()
+bool wxGLCanvas::SwapBuffers()
 {
     if ( !::SwapBuffers(m_hDC) )
+    {
+        return false;
         wxLogLastError(_T("SwapBuffers"));
+    }
+    return true;
 }
 
 // ----------------------------------------------------------------------------
index b4a8b2d147c0f4add908ec1cb97ebe37d60233a5..b0da747670380a5b69fe5da1225f9499c1792926 100644 (file)
@@ -68,26 +68,26 @@ wxGLContext::~wxGLContext()
     glXDestroyContext( wxGetX11Display(), m_glContext );
 }
 
-void wxGLContext::SetCurrent(const wxGLCanvas& win) const
+bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
 {
     if ( !m_glContext )
-        return;
+        return false;
 
     const Window xid = win.GetXWindow();
-    wxCHECK_RET( xid, _T("window must be shown") );
+    wxCHECK2_MSG( xid, return false, _T("window must be shown") );
 
-    MakeCurrent(xid, m_glContext);
+    return MakeCurrent(xid, m_glContext);
 }
 
 // wrapper around glXMakeContextCurrent/glXMakeCurrent depending on GLX
 // version
 /* static */
-void wxGLContext::MakeCurrent(GLXDrawable drawable, GLXContext context)
+bool wxGLContext::MakeCurrent(GLXDrawable drawable, GLXContext context)
 {
     if (wxGLCanvas::GetGLXVersion() >= 13)
-        glXMakeContextCurrent( wxGetX11Display(), drawable, drawable, context);
+        return glXMakeContextCurrent( wxGetX11Display(), drawable, drawable, context);
     else // GLX <= 1.2 doesn't have glXMakeContextCurrent()
-        glXMakeCurrent( wxGetX11Display(), drawable, context);
+        return glXMakeCurrent( wxGetX11Display(), drawable, context);
 }
 
 // ============================================================================
@@ -351,12 +351,13 @@ int wxGLCanvasX11::GetGLXVersion()
     return s_glxVersion;
 }
 
-void wxGLCanvasX11::SwapBuffers()
+bool wxGLCanvasX11::SwapBuffers()
 {
     const Window xid = GetXWindow();
-    wxCHECK_RET( xid, _T("window must be shown") );
+    wxCHECK2_MSG( xid, return false, _T("window must be shown") );
 
     glXSwapBuffers(wxGetX11Display(), xid);
+    return true;
 }
 
 bool wxGLCanvasX11::IsShownOnScreen() const