git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50900
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
\membersection{wxGLCanvas::SetCurrent}\label{wxglcanvassetcurrent}
\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.
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.
in particular it can't usually be called from the constructor as the window
isn't yet shown at this moment.
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}
\membersection{wxGLCanvas::SetColour}\label{wxglcanvassetcolour}
\membersection{wxGLCanvas::SwapBuffers}\label{wxglcanvasswapbuffers}
\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.
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.
+
*/
// set this context as the current one
*/
// set this context as the current one
- virtual void SetCurrent(const wxGLCanvas& win) const = 0;
+ virtual bool SetCurrent(const wxGLCanvas& win) const = 0;
};
// ----------------------------------------------------------------------------
};
// ----------------------------------------------------------------------------
// ----------
// set the given context associated with this window as the current one
// ----------
// 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)
// flush the back buffer (if we have it)
- virtual void SwapBuffers() = 0;
+ virtual bool SwapBuffers() = 0;
wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL);
virtual ~wxGLContext();
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; }
HGLRC GetGLRC() const { return m_glContext; }
virtual ~wxGLCanvas();
// implement wxGLCanvasBase methods
virtual ~wxGLCanvas();
// implement wxGLCanvasBase methods
- virtual void SwapBuffers();
+ virtual bool SwapBuffers();
wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
virtual ~wxGLContext();
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)
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);
// implement wxGLCanvasBase methods
// --------------------------------
// implement wxGLCanvasBase methods
// --------------------------------
- virtual void SwapBuffers();
+ virtual bool SwapBuffers();
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
}
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") );
{
// 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)
}
bool wxGLCanvasBase::SetColour(const wxString& colour)
wglDeleteContext(m_glContext);
}
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"));
{
if ( !wglMakeCurrent(win.GetHDC(), m_glContext) )
{
wxLogLastError(_T("wglMakeCurrent"));
}
// ============================================================================
}
// ============================================================================
// operations
// ----------------------------------------------------------------------------
// operations
// ----------------------------------------------------------------------------
-void wxGLCanvas::SwapBuffers()
+bool wxGLCanvas::SwapBuffers()
{
if ( !::SwapBuffers(m_hDC) )
{
if ( !::SwapBuffers(m_hDC) )
wxLogLastError(_T("SwapBuffers"));
wxLogLastError(_T("SwapBuffers"));
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
glXDestroyContext( wxGetX11Display(), m_glContext );
}
glXDestroyContext( wxGetX11Display(), m_glContext );
}
-void wxGLContext::SetCurrent(const wxGLCanvas& win) const
+bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
const Window xid = win.GetXWindow();
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 */
}
// 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)
{
if (wxGLCanvas::GetGLXVersion() >= 13)
- glXMakeContextCurrent( wxGetX11Display(), drawable, drawable, context);
+ return glXMakeContextCurrent( wxGetX11Display(), drawable, drawable, context);
else // GLX <= 1.2 doesn't have glXMakeContextCurrent()
else // GLX <= 1.2 doesn't have glXMakeContextCurrent()
- glXMakeCurrent( wxGetX11Display(), drawable, context);
+ return glXMakeCurrent( wxGetX11Display(), drawable, context);
}
// ============================================================================
}
// ============================================================================
-void wxGLCanvasX11::SwapBuffers()
+bool wxGLCanvasX11::SwapBuffers()
{
const Window xid = GetXWindow();
{
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);
glXSwapBuffers(wxGetX11Display(), xid);
}
bool wxGLCanvasX11::IsShownOnScreen() const
}
bool wxGLCanvasX11::IsShownOnScreen() const