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
|
2019-04-22 08:12:05 -04:00
|
|
|
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
|
2007-04-15 19:06:45 -04:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_UNIX_GLX11_H_
|
|
|
|
#define _WX_UNIX_GLX11_H_
|
|
|
|
|
2019-08-28 12:37:49 -04:00
|
|
|
#include <GL/gl.h>
|
2007-04-15 19:06:45 -04:00
|
|
|
|
2019-08-28 12:37:49 -04:00
|
|
|
typedef struct __GLXcontextRec* GLXContext;
|
|
|
|
typedef struct __GLXFBConfigRec* GLXFBConfig;
|
2016-02-22 18:30:49 -05:00
|
|
|
|
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:
|
|
|
|
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
|
2019-08-28 12:37:49 -04:00
|
|
|
virtual unsigned long GetXWindow() const = 0;
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
|
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; }
|
2019-08-28 12:37:49 -04:00
|
|
|
void* GetXVisualInfo() const { return m_vi; }
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
// initialize the global default GL visual, return false if matching visual
|
|
|
|
// not found
|
|
|
|
static bool InitDefaultVisualInfo(const int *attribList);
|
|
|
|
|
|
|
|
private:
|
|
|
|
GLXFBConfig *m_fbc;
|
2019-08-28 12:37:49 -04:00
|
|
|
void* m_vi;
|
2007-04-15 19:06:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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:
|
2019-08-28 12:37:49 -04:00
|
|
|
virtual bool InitGLVisual(const int *attribList) wxOVERRIDE;
|
2007-04-15 19:06:45 -04:00
|
|
|
|
2017-04-26 08:41:08 -04:00
|
|
|
// This method is not currently used by the library itself, but remains for
|
|
|
|
// backwards compatibility and also because wxGTK has it we could start
|
|
|
|
// using it for the same purpose in wxX11 too some day.
|
2019-08-28 12:37:49 -04:00
|
|
|
virtual void* GetXVisualInfo() wxOVERRIDE;
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
// and override this wxApp method to clean up
|
2019-08-28 12:37:49 -04:00
|
|
|
virtual int OnExit() wxOVERRIDE;
|
2007-04-15 19:06:45 -04:00
|
|
|
|
|
|
|
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_
|
|
|
|
|