]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk1/glcanvas.h
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( bool isRGB
, wxWindow
*win
, const wxPalette
& palette
= wxNullPalette
);
41 bool WXUNUSED(isRGB
), wxWindow
*win
,
42 const wxPalette
& WXUNUSED(palette
),
43 const wxGLContext
*other
/* for sharing display lists */
45 virtual ~wxGLContext();
48 void SetColour(const wxChar
*colour
);
51 void SetupPixelFormat();
52 void SetupPalette(const wxPalette
& palette
);
53 wxPalette
CreateDefaultPalette();
55 inline wxPalette
* GetPalette() const { return (wxPalette
*) & m_palette
; }
56 inline wxWindow
* GetWindow() const { return m_window
; }
57 inline GtkWidget
* GetWidget() const { return m_widget
; }
58 inline GLXContext
GetContext() const { return m_glContext
; }
61 GLXContext m_glContext
;
68 DECLARE_CLASS(wxGLContext
)
71 //---------------------------------------------------------------------------
73 //---------------------------------------------------------------------------
75 class WXDLLEXPORT wxGLCanvas
: public wxWindow
79 m_glContext
= (wxGLContext
*) NULL
;
80 m_sharedContext
= (wxGLContext
*) NULL
;
81 m_glWidget
= (GtkWidget
*) NULL
;
85 wxGLCanvas( wxWindow
*parent
, wxWindowID id
= -1,
86 const wxPoint
& pos
= wxDefaultPosition
,
87 const wxSize
& size
= wxDefaultSize
,
88 long style
= 0, const wxString
& name
= wxGLCanvasName
,
89 int *attribList
= (int*) NULL
,
90 const wxPalette
& palette
= wxNullPalette
);
91 wxGLCanvas( wxWindow
*parent
, const wxGLContext
*shared
,
93 const wxPoint
& pos
= wxDefaultPosition
,
94 const wxSize
& size
= wxDefaultSize
,
95 long style
= 0, const wxString
& name
= wxGLCanvasName
,
96 int *attribList
= (int*) NULL
,
97 const wxPalette
& palette
= wxNullPalette
);
98 wxGLCanvas( wxWindow
*parent
, const wxGLCanvas
*shared
,
100 const wxPoint
& pos
= wxDefaultPosition
,
101 const wxSize
& size
= wxDefaultSize
,
102 long style
= 0, const wxString
& name
= wxGLCanvasName
,
103 int *attribList
= (int*) NULL
,
104 const wxPalette
& palette
= wxNullPalette
);
106 bool Create( wxWindow
*parent
,
107 const wxGLContext
*shared
= (wxGLContext
*)NULL
,
108 const wxGLCanvas
*shared_context_of
= (wxGLCanvas
*)NULL
,
110 const wxPoint
& pos
= wxDefaultPosition
,
111 const wxSize
& size
= wxDefaultSize
,
113 const wxString
& name
= wxGLCanvasName
,
114 int *attribList
= (int*) NULL
,
115 const wxPalette
& palette
= wxNullPalette
);
117 virtual ~wxGLCanvas();
120 void SetColour(const wxChar
*colour
);
123 void OnSize(wxSizeEvent
& event
);
125 void OnInternalIdle();
127 inline wxGLContext
* GetContext() const { return m_glContext
; }
131 wxGLContext
*m_glContext
,
133 wxGLCanvas
*m_sharedContextOf
;
134 void *m_vi
; // actually an XVisualInfo*
138 GtkWidget
*m_glWidget
;
141 // returns an XVisualInfo* based on desired GL attributes;
142 // returns NULL if an appropriate visual is not found. The
143 // caller is reponsible for using XFree() to deallocate
144 // the returned structure.
145 static void* ChooseGLVisual(int *attribList
);
146 static void* ChooseGLFBC(int *attribList
);
147 static void GetGLAttribListFromWX(int *wx_attribList
, int *gl_attribList
);
149 static void QueryGLXVersion();
150 static int GetGLXVersion();
151 static int m_glxVersion
;
153 DECLARE_EVENT_TABLE()
154 DECLARE_CLASS(wxGLCanvas
)