]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWidgets and GTK
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GLCANVAS_H_
13 #define _WX_GLCANVAS_H_
15 #include "wx/scrolwin.h"
24 //---------------------------------------------------------------------------
26 //---------------------------------------------------------------------------
28 class WXDLLEXPORT wxGLContext
;
29 class WXDLLEXPORT wxGLCanvas
;
31 //---------------------------------------------------------------------------
33 //---------------------------------------------------------------------------
36 class WXDLLEXPORT wxGLContext
: public wxObject
39 wxGLContext(wxWindow
* win
, const wxGLContext
* other
=NULL
/* for sharing display lists */);
40 virtual ~wxGLContext();
43 // The win wxGLCanvas needs not necessarily be the same as the wxGLCanvas with which this context was created!
44 void SetCurrent(const wxGLCanvas
& win
) const;
48 GLXContext m_glContext
;
51 DECLARE_CLASS(wxGLContext
)
54 //---------------------------------------------------------------------------
56 //---------------------------------------------------------------------------
58 class WXDLLEXPORT wxGLCanvas
: public wxWindow
61 // This ctor is identical to the next, except for the fact that it
62 // doesn't create an implicit wxGLContext.
63 // The attribList parameter has been moved to avoid overload clashes.
64 wxGLCanvas( wxWindow
*parent
, wxWindowID id
= -1,
65 int *attribList
= (int*) NULL
,
66 const wxPoint
& pos
= wxDefaultPosition
,
67 const wxSize
& size
= wxDefaultSize
,
68 long style
= 0, const wxString
& name
= wxGLCanvasName
,
69 const wxPalette
& palette
= wxNullPalette
);
71 wxGLCanvas( wxWindow
*parent
, wxWindowID id
= -1,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& size
= wxDefaultSize
,
74 long style
= 0, const wxString
& name
= wxGLCanvasName
,
75 int *attribList
= (int*) NULL
,
76 const wxPalette
& palette
= wxNullPalette
);
78 wxGLCanvas( wxWindow
*parent
, const wxGLContext
*shared
,
80 const wxPoint
& pos
= wxDefaultPosition
,
81 const wxSize
& size
= wxDefaultSize
,
82 long style
= 0, const wxString
& name
= wxGLCanvasName
,
83 int *attribList
= (int*) NULL
,
84 const wxPalette
& palette
= wxNullPalette
);
86 wxGLCanvas( wxWindow
*parent
, const wxGLCanvas
*shared
,
88 const wxPoint
& pos
= wxDefaultPosition
,
89 const wxSize
& size
= wxDefaultSize
,
90 long style
= 0, const wxString
& name
= wxGLCanvasName
,
91 int *attribList
= (int*) NULL
,
92 const wxPalette
& palette
= wxNullPalette
);
94 bool Create( wxWindow
*parent
,
95 const wxGLContext
*shared
= (wxGLContext
*)NULL
,
96 const wxGLCanvas
*shared_context_of
= (wxGLCanvas
*)NULL
,
98 const wxPoint
& pos
= wxDefaultPosition
,
99 const wxSize
& size
= wxDefaultSize
,
101 const wxString
& name
= wxGLCanvasName
,
102 int *attribList
= (int*) NULL
,
103 const wxPalette
& palette
= wxNullPalette
);
105 virtual ~wxGLCanvas();
107 void SetCurrent(const wxGLContext
& RC
) const;
109 void SetColour(const wxChar
*colour
);
112 void OnSize(wxSizeEvent
& event
);
114 void OnInternalIdle();
116 inline wxGLContext
* GetContext() const { return m_glContext
; }
120 wxGLContext
*m_glContext
,
122 wxGLCanvas
*m_sharedContextOf
;
123 const bool m_createImplicitContext
;
124 void *m_vi
; // actually an XVisualInfo*
128 GtkWidget
*m_glWidget
;
131 // returns an XVisualInfo* based on desired GL attributes;
132 // returns NULL if an appropriate visual is not found. The
133 // caller is reponsible for using XFree() to deallocate
134 // the returned structure.
135 static void* ChooseGLVisual(int *attribList
);
136 static void* ChooseGLFBC(int *attribList
);
137 static void GetGLAttribListFromWX(int *wx_attribList
, int *gl_attribList
);
139 static void QueryGLXVersion();
140 static int GetGLXVersion();
141 static int m_glxVersion
;
144 DECLARE_EVENT_TABLE()
145 DECLARE_CLASS(wxGLCanvas
)