added wxGLCanvas::IsDisplaySupported() (patch 1879906)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -278,6 +278,7 @@ All (GUI):
|
||||
- Made wxSizer::Fit() set the client size of the target window
|
||||
- Add support for wxDatePickerCtrl in wxGenericValidator (Herry Ayen Yang)
|
||||
- Added wxWindow::HasFocus().
|
||||
- Added wxGLCanvas::IsDisplaySupported()
|
||||
|
||||
wxGTK:
|
||||
|
||||
|
@@ -125,6 +125,17 @@ and so on.
|
||||
Ignored under most platforms.}
|
||||
|
||||
|
||||
\membersection{wxGLCanvas::IsDisplaySupported}\label{wxglcanvasisdisplaysupported}
|
||||
|
||||
\func{static bool}{IsDisplaySupported}{ \param{const int *}{ attribList = \NULL} }
|
||||
|
||||
Determines if a canvas having the specified attributes is available.
|
||||
|
||||
\docparam{attribList}{See \arg{attribList} for \helpref{wxGLCanvas::wxGLCanvas}{wxglcanvasconstr}.}
|
||||
|
||||
Returns \true if attributes are supported.
|
||||
|
||||
|
||||
\membersection{wxGLCanvas::SetCurrent}\label{wxglcanvassetcurrent}
|
||||
|
||||
\func{bool}{SetCurrent}{ \param{const wxGLContext&}{ context} }
|
||||
|
@@ -108,6 +108,9 @@ public:
|
||||
// accessors
|
||||
// ---------
|
||||
|
||||
// check if the given attributes are supported without creating a canvas
|
||||
static bool IsDisplaySupported(const int *attribList);
|
||||
|
||||
const wxPalette *GetPalette() const { return &m_palette; }
|
||||
|
||||
// miscellaneous helper functions
|
||||
|
@@ -95,6 +95,13 @@ public:
|
||||
// free the global GL visual, called by wxGLApp
|
||||
static void FreeDefaultVisualInfo();
|
||||
|
||||
// initializes XVisualInfo (in any case) and, if supported, GLXFBConfig
|
||||
//
|
||||
// returns false if XVisualInfo couldn't be initialized, otherwise caller
|
||||
// is responsible for freeing the pointers
|
||||
static bool InitXVisualInfo(const int *attribList,
|
||||
GLXFBConfig **pFBC, XVisualInfo **pXVisual);
|
||||
|
||||
private:
|
||||
// fills in glattrs with attributes defined by wxattrs which must be
|
||||
// 0-terminated if it is non-NULL
|
||||
@@ -103,13 +110,6 @@ private:
|
||||
// should be at least 16 to accommodate the default attributes
|
||||
static bool ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n);
|
||||
|
||||
// initializes XVisualInfo (in any case) and, if supported, GLXFBConfig
|
||||
//
|
||||
// returns false if XVisualInfo couldn't be initialized, otherwise caller
|
||||
// is responsible for freeing the pointers
|
||||
static bool InitXVisualInfo(const int *attribList,
|
||||
GLXFBConfig **pFBC, XVisualInfo **pXVisual);
|
||||
|
||||
|
||||
// this is only used if it's supported i.e. if GL >= 1.3
|
||||
GLXFBConfig *m_fbc;
|
||||
|
@@ -385,6 +385,11 @@ MyFrame::MyFrame()
|
||||
|
||||
SetClientSize(400, 400);
|
||||
Show();
|
||||
|
||||
// test IsDisplaySupported() function:
|
||||
static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
|
||||
wxLogStatus("Double-buffered display %s supported",
|
||||
wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not");
|
||||
}
|
||||
|
||||
void MyFrame::OnClose(wxCommandEvent& WXUNUSED(event))
|
||||
|
@@ -312,6 +312,19 @@ wxGLCanvas::~wxGLCanvas()
|
||||
aglDestroyPixelFormat(m_aglFormat);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool wxGLCanvasBase::IsDisplaySupported(const int *attribList)
|
||||
{
|
||||
AGLPixelFormat aglFormat = ChoosePixelFormat(attribList);
|
||||
|
||||
if ( !aglFormat )
|
||||
return false;
|
||||
|
||||
aglDestroyPixelFormat(aglFormat);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxGLCanvas::SwapBuffers()
|
||||
{
|
||||
AGLContext context = aglGetCurrentContext();
|
||||
|
@@ -450,6 +450,14 @@ wxGLCanvas::ChooseMatchingPixelFormat(HDC hdc,
|
||||
return ::ChoosePixelFormat(hdc, ppfd);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool wxGLCanvasBase::IsDisplaySupported(const int *attribList)
|
||||
{
|
||||
// We need a device context to test the pixel format, so get one
|
||||
// for the root window.
|
||||
return wxGLCanvas::ChooseMatchingPixelFormat(ScreenHDC(), attribList) > 0;
|
||||
}
|
||||
|
||||
bool wxGLCanvas::DoSetup(const int *attribList)
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
@@ -297,6 +297,24 @@ wxGLCanvasX11::InitXVisualInfo(const int *attribList,
|
||||
return *pXVisual != NULL;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
wxGLCanvasBase::IsDisplaySupported(const int *attribList)
|
||||
{
|
||||
GLXFBConfig *fbc = NULL;
|
||||
XVisualInfo *vi = NULL;
|
||||
|
||||
const bool
|
||||
isSupported = wxGLCanvasX11::InitXVisualInfo(attribList, &fbc, &vi);
|
||||
|
||||
if ( fbc )
|
||||
XFree(fbc);
|
||||
if ( vi )
|
||||
XFree(vi);
|
||||
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// default visual management
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user