2007-04-15 19:06:45 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/unix/glx11.h
|
|
|
|
// Purpose: class common for all X11-based wxGLCanvas implementations
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 2007-04-15
|
|
|
|
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_UNIX_GLX11_H_
|
|
|
|
#define _WX_UNIX_GLX11_H_
|
|
|
|
|
|
|
|
#include <GL/glx.h>
|
|
|
|
|
2016-02-22 18:30:49 -05:00
|
|
|
class wxGLContextAttrs;
|
|
|
|
class wxGLAttributes;
|
|
|
|
|
2007-04-15 19:06:45 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGLContext
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 11:40:45 -04:00
|
|
|
class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
|
2007-04-15 19:06:45 -04:00
|
|
|
{
|
|
|
|
public:
|
2016-02-22 18:30:49 -05:00
|
|
|
wxGLContext(wxGLCanvas *win,
|
|
|
|
const wxGLContext *other = NULL,
|
|
|
|
const wxGLContextAttrs *ctxAttrs = NULL);
|
2007-04-15 19:06:45 -04:00
|
|
|
virtual ~wxGLContext();
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SetCurrent(const wxGLCanvas& win) const wxOVERRIDE;
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
// attach context to the drawable or unset it (if NULL)
|
2007-12-22 10:48:03 -05:00
|
|
|
static bool MakeCurrent(GLXDrawable drawable, GLXContext context);
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
GLXContext m_glContext;
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_CLASS(wxGLContext);
|
2007-04-15 19:06:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGLCanvasX11
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-07-06 11:40:45 -04:00
|
|
|
class WXDLLIMPEXP_GL wxGLCanvasX11 : public wxGLCanvasBase
|
2007-04-15 19:06:45 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// initialization and dtor
|
|
|
|
// -----------------------
|
|
|
|
|
|
|
|
// default ctor doesn't do anything, InitVisual() must be called
|
|
|
|
wxGLCanvasX11();
|
|
|
|
|
2016-02-22 18:30:49 -05:00
|
|
|
// initializes GLXFBConfig and XVisualInfo corresponding to the given attributes
|
|
|
|
bool InitVisual(const wxGLAttributes& dispAttrs);
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
// frees XVisualInfo info
|
|
|
|
virtual ~wxGLCanvasX11();
|
|
|
|
|
|
|
|
|
|
|
|
// implement wxGLCanvasBase methods
|
|
|
|
// --------------------------------
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool SwapBuffers() wxOVERRIDE;
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
|
|
|
|
// X11-specific methods
|
|
|
|
// --------------------
|
|
|
|
|
|
|
|
// return GLX version: 13 means 1.3 &c
|
|
|
|
static int GetGLXVersion();
|
|
|
|
|
2008-06-07 20:12:12 -04:00
|
|
|
// return true if multisample extension is available
|
|
|
|
static bool IsGLXMultiSampleAvailable();
|
|
|
|
|
2007-04-15 19:06:45 -04:00
|
|
|
// get the X11 handle of this window
|
|
|
|
virtual Window GetXWindow() const = 0;
|
|
|
|
|
|
|
|
|
2014-08-15 08:14:11 -04:00
|
|
|
// GLX-specific methods
|
|
|
|
// --------------------
|
|
|
|
|
2007-04-15 19:06:45 -04:00
|
|
|
// override some wxWindow methods
|
|
|
|
// ------------------------------
|
|
|
|
|
|
|
|
// return true only if the window is realized: OpenGL context can't be
|
|
|
|
// created until we are
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsShownOnScreen() const wxOVERRIDE;
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
|
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
|
|
|
// get the GLXFBConfig/XVisualInfo we use
|
|
|
|
GLXFBConfig *GetGLXFBConfig() const { return m_fbc; }
|
|
|
|
XVisualInfo *GetXVisualInfo() const { return m_vi; }
|
|
|
|
|
|
|
|
// initialize the global default GL visual, return false if matching visual
|
|
|
|
// not found
|
|
|
|
static bool InitDefaultVisualInfo(const int *attribList);
|
|
|
|
|
|
|
|
// get the default GL X11 visual (may be NULL, shouldn't be freed by caller)
|
|
|
|
static XVisualInfo *GetDefaultXVisualInfo() { return ms_glVisualInfo; }
|
|
|
|
|
|
|
|
// free the global GL visual, called by wxGLApp
|
|
|
|
static void FreeDefaultVisualInfo();
|
|
|
|
|
2008-02-03 09:55:05 -05:00
|
|
|
// 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
|
2016-02-22 18:30:49 -05:00
|
|
|
static bool InitXVisualInfo(const wxGLAttributes& dispAttrs,
|
2008-02-03 09:55:05 -05:00
|
|
|
GLXFBConfig **pFBC, XVisualInfo **pXVisual);
|
|
|
|
|
2007-04-15 19:06:45 -04:00
|
|
|
private:
|
|
|
|
|
|
|
|
// this is only used if it's supported i.e. if GL >= 1.3
|
|
|
|
GLXFBConfig *m_fbc;
|
|
|
|
|
|
|
|
// used for all GL versions, obtained from GLXFBConfig for GL >= 1.3
|
|
|
|
XVisualInfo *m_vi;
|
|
|
|
|
|
|
|
// the global/default versions of the above
|
|
|
|
static GLXFBConfig *ms_glFBCInfo;
|
|
|
|
static XVisualInfo *ms_glVisualInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGLApp
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// this is used in wx/glcanvas.h, prevent it from defining a generic wxGLApp
|
|
|
|
#define wxGL_APP_DEFINED
|
|
|
|
|
2007-07-06 11:40:45 -04:00
|
|
|
class WXDLLIMPEXP_GL wxGLApp : public wxGLAppBase
|
2007-04-15 19:06:45 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-02-05 19:25:43 -05:00
|
|
|
wxGLApp() : wxGLAppBase() { }
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
// implement wxGLAppBase method
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool InitGLVisual(const int *attribList) wxOVERRIDE
|
2007-04-15 19:06:45 -04:00
|
|
|
{
|
|
|
|
return wxGLCanvasX11::InitDefaultVisualInfo(attribList);
|
|
|
|
}
|
|
|
|
|
|
|
|
// and implement this wxGTK::wxApp method too
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void *GetXVisualInfo() wxOVERRIDE
|
2007-04-15 19:06:45 -04:00
|
|
|
{
|
|
|
|
return wxGLCanvasX11::GetDefaultXVisualInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
// and override this wxApp method to clean up
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual int OnExit() wxOVERRIDE
|
2007-04-15 19:06:45 -04:00
|
|
|
{
|
|
|
|
wxGLCanvasX11::FreeDefaultVisualInfo();
|
|
|
|
|
|
|
|
return wxGLAppBase::OnExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxGLApp);
|
2007-04-15 19:06:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_UNIX_GLX11_H_
|
|
|
|
|