X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dc3065a56f1febf3de3b3bbf0904cf8fdc7f7c50..d730bd8a68c9e19fc3e2be13777ae267408a3833:/src/common/glcmn.cpp diff --git a/src/common/glcmn.cpp b/src/common/glcmn.cpp index ffcb45a603..4f5f9c6025 100644 --- a/src/common/glcmn.cpp +++ b/src/common/glcmn.cpp @@ -41,17 +41,28 @@ IMPLEMENT_CLASS(wxGLApp, wxApp) // implementation // ============================================================================ -void wxGLCanvasBase::SetCurrent(const wxGLContext& context) const +wxGLCanvasBase::wxGLCanvasBase() +{ +#if WXWIN_COMPATIBILITY_2_8 + m_glContext = NULL; +#endif + + // we always paint background entirely ourselves so prevent wx from erasing + // it to avoid flicker + SetBackgroundStyle(wxBG_STYLE_CUSTOM); +} + +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(*static_cast(this)); } -bool wxGLCanvasBase::SetColour(const wxChar *colour) +bool wxGLCanvasBase::SetColour(const wxString& colour) { wxColour col = wxTheColourDatabase->Find(colour); if ( !col.Ok() ) @@ -104,5 +115,32 @@ void wxGLCanvasBase::OnSize(wxSizeEvent& WXUNUSED(event)) #endif // WXWIN_COMPATIBILITY_2_8 +/* static */ +bool wxGLCanvasBase::IsExtensionInList(const char *list, const char *extension) +{ + if ( !list ) + return false; + + for ( const char *p = list; *p; p++ ) + { + // advance up to the next possible match + p = wxStrstr(p, extension); + if ( !p ) + break; + + // check that the extension appears at the beginning/ending of the list + // or is preceded/followed by a space to avoid mistakenly finding + // "glExtension" in a list containing some "glFunkyglExtension" + if ( (p == list || p[-1] == ' ') ) + { + char c = p[strlen(extension)]; + if ( c == '\0' || c == ' ' ) + return true; + } + } + + return false; +} + #endif // wxUSE_GLCANVAS