made SetCurrent() and SwapBuffers() return boolean status indicator instead of void (slightly modified patch 1844090)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50900 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
242019eef3
commit
5ec69e9666
@ -127,7 +127,7 @@ Ignored under most platforms.}
|
|||||||
|
|
||||||
\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
|
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.
|
\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
|
in particular it can't usually be called from the constructor as the window
|
||||||
isn't yet shown at this moment.
|
isn't yet shown at this moment.
|
||||||
|
|
||||||
|
Returns \false if an error occurred.
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxGLCanvas::SetColour}\label{wxglcanvassetcolour}
|
\membersection{wxGLCanvas::SetColour}\label{wxglcanvassetcolour}
|
||||||
|
|
||||||
@ -150,8 +152,10 @@ wxWidgets colour database to find a named colour.
|
|||||||
|
|
||||||
\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,
|
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.
|
so that the output of the previous OpenGL commands is displayed on the window.
|
||||||
|
|
||||||
|
Returns \false if an error occurred.
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -99,10 +99,10 @@ public:
|
|||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL);
|
wxGLContext(wxGLCanvas *win, const wxGLContext* other = NULL);
|
||||||
virtual ~wxGLContext();
|
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; }
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
virtual ~wxGLCanvas();
|
virtual ~wxGLCanvas();
|
||||||
|
|
||||||
// implement wxGLCanvasBase methods
|
// implement wxGLCanvasBase methods
|
||||||
virtual void SwapBuffers();
|
virtual bool SwapBuffers();
|
||||||
|
|
||||||
|
|
||||||
// MSW-specific helpers
|
// MSW-specific helpers
|
||||||
|
@ -23,11 +23,11 @@ public:
|
|||||||
wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
|
wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
|
||||||
virtual ~wxGLContext();
|
virtual ~wxGLContext();
|
||||||
|
|
||||||
virtual void SetCurrent(const wxGLCanvas& win) const;
|
virtual bool SetCurrent(const wxGLCanvas& win) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// attach context to the drawable or unset it (if NULL)
|
// 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;
|
GLXContext m_glContext;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
// implement wxGLCanvasBase methods
|
// implement wxGLCanvasBase methods
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
virtual void SwapBuffers();
|
virtual bool SwapBuffers();
|
||||||
|
|
||||||
|
|
||||||
// X11-specific methods
|
// X11-specific methods
|
||||||
|
@ -52,14 +52,14 @@ wxGLCanvasBase::wxGLCanvasBase()
|
|||||||
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
|
// 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
|
// 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
|
// 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") );
|
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)
|
||||||
|
@ -200,12 +200,14 @@ wxGLContext::~wxGLContext()
|
|||||||
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) )
|
if ( !wglMakeCurrent(win.GetHDC(), m_glContext) )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("wglMakeCurrent"));
|
wxLogLastError(_T("wglMakeCurrent"));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@ -313,10 +315,14 @@ bool wxGLCanvas::Create(wxWindow *parent,
|
|||||||
// operations
|
// operations
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxGLCanvas::SwapBuffers()
|
bool wxGLCanvas::SwapBuffers()
|
||||||
{
|
{
|
||||||
if ( !::SwapBuffers(m_hDC) )
|
if ( !::SwapBuffers(m_hDC) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
wxLogLastError(_T("SwapBuffers"));
|
wxLogLastError(_T("SwapBuffers"));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -68,26 +68,26 @@ wxGLContext::~wxGLContext()
|
|||||||
glXDestroyContext( wxGetX11Display(), m_glContext );
|
glXDestroyContext( wxGetX11Display(), m_glContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGLContext::SetCurrent(const wxGLCanvas& win) const
|
bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
|
||||||
{
|
{
|
||||||
if ( !m_glContext )
|
if ( !m_glContext )
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
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
|
// wrapper around glXMakeContextCurrent/glXMakeCurrent depending on GLX
|
||||||
// version
|
// version
|
||||||
/* static */
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@ -351,12 +351,13 @@ int wxGLCanvasX11::GetGLXVersion()
|
|||||||
return s_glxVersion;
|
return s_glxVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGLCanvasX11::IsShownOnScreen() const
|
bool wxGLCanvasX11::IsShownOnScreen() const
|
||||||
|
Loading…
Reference in New Issue
Block a user