Big wxGL classes refactoring/cleanup:
1. Provide the same API, especially, but not limited to, wxGLCanvas and wxCLContext ctors (which were completely different in all ports) 2. Extracted common parts into wxGLCanvas/ContextBase classes 3. Deprecate the old API using implicitly created wxGLContext git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45388 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -16,14 +16,20 @@
|
||||
|
||||
#if wxUSE_GLCANVAS
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Constants for attriblist
|
||||
//---------------------------------------------------------------------------
|
||||
#include "wx/app.h"
|
||||
#include "wx/palette.h"
|
||||
#include "wx/window.h"
|
||||
|
||||
// The generic GL implementation doesn't support most of these options,
|
||||
// such as stereo, auxiliary buffers, alpha channel, and accum buffer.
|
||||
class WXDLLIMPEXP_GL wxGLCanvas;
|
||||
class WXDLLIMPEXP_GL wxGLContext;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Constants for attributes list
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// The generic OpenGL implementation doesn't support most of these options,
|
||||
// such as stereo, auxiliary buffers, alpha channel, and accumulator buffer.
|
||||
// Other implementations may actually support them.
|
||||
|
||||
enum
|
||||
{
|
||||
WX_GL_RGBA=1, /* use true color palette */
|
||||
@@ -46,41 +52,139 @@ enum
|
||||
|
||||
#define wxGLCanvasName _T("GLCanvas")
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/glcanvas.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/x11/glcanvas.h"
|
||||
#elif defined(__WXGTK20__)
|
||||
#include "wx/gtk/glcanvas.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk1/glcanvas.h"
|
||||
#elif defined(__WXX11__)
|
||||
#include "wx/x11/glcanvas.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/glcanvas.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/cocoa/glcanvas.h"
|
||||
#else
|
||||
#error "wxGLCanvas not supported in this wxWidgets port"
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGLContextBase: OpenGL rendering context
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_GL wxGLContextBase : public wxObject
|
||||
{
|
||||
public:
|
||||
/*
|
||||
The derived class should provide a ctor with this signature:
|
||||
|
||||
wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
|
||||
*/
|
||||
|
||||
// set this context as the current one
|
||||
virtual void SetCurrent(const wxGLCanvas& win) const = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGLCanvasBase: window which can be used for OpenGL rendering
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_GL wxGLCanvasBase : public wxWindow
|
||||
{
|
||||
public:
|
||||
// default ctor doesn't initialize the window, use Create() later
|
||||
wxGLCanvasBase()
|
||||
{
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
m_glContext = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual ~wxGLCanvasBase();
|
||||
|
||||
|
||||
/*
|
||||
The derived class should provide a ctor with this signature:
|
||||
|
||||
wxGLCanvas(wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
int* attribList = 0,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxGLCanvasName,
|
||||
const wxPalette& palette = wxNullPalette);
|
||||
*/
|
||||
|
||||
// operations
|
||||
// ----------
|
||||
|
||||
// set the given context associated with this window as the current one
|
||||
void SetCurrent(const wxGLContext& context) const;
|
||||
|
||||
// flush the back buffer (if we have it)
|
||||
virtual void SwapBuffers() = 0;
|
||||
|
||||
|
||||
// accessors
|
||||
// ---------
|
||||
|
||||
const wxPalette *GetPalette() const { return &m_palette; }
|
||||
|
||||
// miscellaneous helper functions
|
||||
// ------------------------------
|
||||
|
||||
// call glcolor() for the colour with the given name, return false if
|
||||
// colour not found
|
||||
bool SetColour(const wxChar *colour);
|
||||
|
||||
|
||||
|
||||
// deprecated methods using the implicit wxGLContext
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
wxDEPRECATED( wxGLContext* GetContext() const );
|
||||
|
||||
wxDEPRECATED( void SetCurrent() );
|
||||
|
||||
wxDEPRECATED( void OnSize(wxSizeEvent& event) );
|
||||
#endif // WXWIN_COMPATIBILITY_2_8
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
// resolve the conflict with wxWindowUniv::SetCurrent()
|
||||
virtual bool SetCurrent(bool doit) { return wxWindow::SetCurrent(doit); };
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// override this to implement SetColour() in GL_INDEX_MODE
|
||||
// (currently only implemented in wxX11 and wxMotif ports)
|
||||
virtual int GetColourIndex(const wxColour& WXUNUSED(col)) { return -1; }
|
||||
|
||||
// create default palette if we're not using RGBA mode
|
||||
// (not supported in most ports)
|
||||
virtual wxPalette CreateDefaultPalette() { return wxNullPalette; }
|
||||
|
||||
|
||||
wxPalette m_palette;
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_8
|
||||
wxGLContext *m_glContext;
|
||||
#endif // WXWIN_COMPATIBILITY_2_8
|
||||
};
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/glcanvas.h"
|
||||
#elif defined(__WXMOTIF__) || defined(__WXX11__)
|
||||
#include "wx/x11/glcanvas.h"
|
||||
#elif defined(__WXGTK20__)
|
||||
#include "wx/gtk/glcanvas.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk1/glcanvas.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/glcanvas.h"
|
||||
#elif defined(__WXCOCOA__)
|
||||
#include "wx/cocoa/glcanvas.h"
|
||||
#else
|
||||
#error "wxGLCanvas not supported in this wxWidgets port"
|
||||
#endif
|
||||
|
||||
#include "wx/app.h"
|
||||
class WXDLLIMPEXP_GL wxGLApp : public wxApp
|
||||
{
|
||||
public:
|
||||
wxGLApp() : wxApp() { }
|
||||
virtual ~wxGLApp();
|
||||
|
||||
// use this in the constructor of the user-derived wxGLApp class to
|
||||
// determine if an OpenGL rendering context with these attributes
|
||||
// is available - returns true if so, false if not.
|
||||
bool InitGLVisual(int *attribList);
|
||||
bool InitGLVisual(const int *attribList);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxGLApp)
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_GLCANVAS
|
||||
#endif
|
||||
// _WX_GLCANVAS_H_BASE_
|
||||
#endif // wxUSE_GLCANVAS
|
||||
|
||||
#endif // _WX_GLCANVAS_H_BASE_
|
||||
|
Reference in New Issue
Block a user