2000-02-28 03:22:57 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2007-04-10 13:38:55 -04:00
|
|
|
// Name: glcanvas.h
|
2004-05-23 10:56:36 -04:00
|
|
|
// Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWidgets and GTK
|
2000-02-28 03:22:57 -05:00
|
|
|
// Author: Robert Roebling
|
|
|
|
// Modified by:
|
|
|
|
// Created: 17/8/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Robert Roebling
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2000-02-28 03:22:57 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2004-07-25 12:36:51 -04:00
|
|
|
#ifndef _WX_GLCANVAS_H_
|
|
|
|
#define _WX_GLCANVAS_H_
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glx.h>
|
|
|
|
#include <GL/glu.h>
|
2000-02-28 03:22:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// wxGLContext
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
class WXDLLEXPORT wxGLContext : public wxGLContextBase
|
2000-02-28 03:22:57 -05:00
|
|
|
{
|
|
|
|
public:
|
2007-04-10 13:38:55 -04:00
|
|
|
wxGLContext(wxWindow* win, const wxGLContext* other = NULL);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxGLContext();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
virtual void SetCurrent(const wxGLCanvas& win) const;
|
2002-12-04 09:11:26 -05:00
|
|
|
|
2000-02-28 03:22:57 -05:00
|
|
|
private:
|
2007-04-10 13:38:55 -04:00
|
|
|
GLXContext m_glContext;
|
|
|
|
|
|
|
|
DECLARE_CLASS(wxGLContext)
|
2000-02-28 03:22:57 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
2001-09-28 09:53:55 -04:00
|
|
|
// wxGLCanvas
|
2000-02-28 03:22:57 -05:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
class WXDLLEXPORT wxGLCanvas : public wxGLCanvasBase
|
2000-02-28 03:22:57 -05:00
|
|
|
{
|
|
|
|
public:
|
2007-04-10 13:38:55 -04:00
|
|
|
wxGLCanvas(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const wxPalette& palette = wxNullPalette);
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
2002-12-04 09:11:26 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
2007-04-10 13:38:55 -04:00
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette);
|
2002-12-04 09:11:26 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
virtual ~wxGLCanvas();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// implement wxGLCanvasBase methods
|
|
|
|
// --------------------------------
|
2002-12-04 09:11:26 -05:00
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
virtual void SwapBuffers();
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
// GTK-specific helpers
|
|
|
|
// --------------------
|
|
|
|
|
|
|
|
// return GLX version: 13 means 1.3
|
|
|
|
static int GetGLXVersion();
|
|
|
|
|
|
|
|
|
|
|
|
// deprecated methods
|
|
|
|
// ------------------
|
|
|
|
|
|
|
|
#if WXWIN_COMPATIBILITY_2_8
|
|
|
|
wxDEPRECATED(
|
|
|
|
wxGLCanvas(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette)
|
|
|
|
);
|
|
|
|
|
|
|
|
wxDEPRECATED(
|
|
|
|
wxGLCanvas(wxWindow *parent,
|
|
|
|
const wxGLContext *shared,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette)
|
|
|
|
);
|
|
|
|
|
|
|
|
wxDEPRECATED(
|
|
|
|
wxGLCanvas(wxWindow *parent,
|
|
|
|
const wxGLCanvas *shared,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxGLCanvasName,
|
|
|
|
const int *attribList = NULL,
|
|
|
|
const wxPalette& palette = wxNullPalette)
|
|
|
|
);
|
|
|
|
|
|
|
|
// called from "realized" callback to create the implicit context if needed
|
|
|
|
void GTKInitImplicitContext();
|
|
|
|
#endif // WXWIN_COMPATIBILITY_2_8
|
|
|
|
|
|
|
|
// implementation from now on
|
|
|
|
virtual void OnInternalIdle();
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
|
2001-09-28 09:53:55 -04:00
|
|
|
void *m_vi; // actually an XVisualInfo*
|
2005-03-27 13:06:43 -05:00
|
|
|
GLXFBConfig *m_fbc;
|
2001-09-28 09:53:55 -04:00
|
|
|
bool m_canFreeVi;
|
2005-03-27 13:06:43 -05:00
|
|
|
bool m_canFreeFBC;
|
2000-02-28 03:22:57 -05:00
|
|
|
GtkWidget *m_glWidget;
|
2007-04-10 13:38:55 -04:00
|
|
|
|
|
|
|
#if WXWIN_COMPATIBILITY_2_8
|
|
|
|
wxGLContext *m_sharedContext;
|
|
|
|
wxGLCanvas *m_sharedContextOf;
|
|
|
|
const bool m_createImplicitContext;
|
|
|
|
#endif // WXWIN_COMPATIBILITY_2_8
|
2002-12-04 09:11:26 -05:00
|
|
|
|
2001-09-28 09:53:55 -04:00
|
|
|
// returns an XVisualInfo* based on desired GL attributes;
|
|
|
|
// returns NULL if an appropriate visual is not found. The
|
2002-12-04 09:11:26 -05:00
|
|
|
// caller is reponsible for using XFree() to deallocate
|
2001-09-28 09:53:55 -04:00
|
|
|
// the returned structure.
|
2007-04-10 13:38:55 -04:00
|
|
|
static void* ChooseGLVisual(const int *attribList);
|
|
|
|
static void* ChooseGLFBC(const int *attribList);
|
|
|
|
static void GetGLAttribListFromWX(const int *wx_attribList, int *gl_attribList );
|
2000-02-28 03:22:57 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_CLASS(wxGLCanvas)
|
|
|
|
};
|
|
|
|
|
2007-04-10 13:38:55 -04:00
|
|
|
#endif // _WX_GLCANVAS_H_
|
2000-02-28 03:22:57 -05:00
|
|
|
|