]>
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 //---------------------------------------------------------------------------
25 // Constants for attriblist
26 //---------------------------------------------------------------------------
30 WX_GL_RGBA
=1, /* use true color palette */
31 WX_GL_BUFFER_SIZE
, /* bits for buffer if not WX_GL_RGBA */
32 WX_GL_LEVEL
, /* 0 for main buffer, >0 for overlay, <0 for underlay */
33 WX_GL_DOUBLEBUFFER
, /* use doublebuffer */
34 WX_GL_STEREO
, /* use stereoscopic display */
35 WX_GL_AUX_BUFFERS
, /* number of auxiliary buffers */
36 WX_GL_MIN_RED
, /* use red buffer with most bits (> MIN_RED bits) */
37 WX_GL_MIN_GREEN
, /* use green buffer with most bits (> MIN_GREEN bits) */
38 WX_GL_MIN_BLUE
, /* use blue buffer with most bits (> MIN_BLUE bits) */
39 WX_GL_MIN_ALPHA
, /* use blue buffer with most bits (> MIN_ALPHA bits) */
40 WX_GL_DEPTH_SIZE
, /* bits for Z-buffer (0,16,32) */
41 WX_GL_STENCIL_SIZE
, /* bits for stencil buffer */
42 WX_GL_MIN_ACCUM_RED
, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
43 WX_GL_MIN_ACCUM_GREEN
, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
44 WX_GL_MIN_ACCUM_BLUE
, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
45 WX_GL_MIN_ACCUM_ALPHA
/* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
48 //---------------------------------------------------------------------------
50 //---------------------------------------------------------------------------
52 class WXDLLEXPORT wxGLContext
;
53 class WXDLLEXPORT wxGLCanvas
;
55 //---------------------------------------------------------------------------
57 //---------------------------------------------------------------------------
60 class WXDLLEXPORT wxGLContext
: public wxObject
63 wxGLContext( bool isRGB
, wxWindow
*win
, const wxPalette
& palette
= wxNullPalette
);
65 bool WXUNUSED(isRGB
), wxWindow
*win
,
66 const wxPalette
& WXUNUSED(palette
),
67 const wxGLContext
*other
/* for sharing display lists */
72 void SetColour(const wxChar
*colour
);
75 void SetupPixelFormat();
76 void SetupPalette(const wxPalette
& palette
);
77 wxPalette
CreateDefaultPalette();
79 inline wxPalette
* GetPalette() const { return (wxPalette
*) & m_palette
; }
80 inline wxWindow
* GetWindow() const { return m_window
; }
81 inline GtkWidget
* GetWidget() const { return m_widget
; }
82 inline GLXContext
GetContext() const { return m_glContext
; }
85 GLXContext m_glContext
;
92 DECLARE_CLASS(wxGLContext
)
95 //---------------------------------------------------------------------------
97 //---------------------------------------------------------------------------
99 class WXDLLEXPORT wxGLCanvas
: public wxWindow
102 inline wxGLCanvas() {
103 m_glContext
= (wxGLContext
*) NULL
;
104 m_sharedContext
= (wxGLContext
*) NULL
;
105 m_glWidget
= (GtkWidget
*) NULL
;
109 wxGLCanvas( wxWindow
*parent
, wxWindowID id
= -1,
110 const wxPoint
& pos
= wxDefaultPosition
,
111 const wxSize
& size
= wxDefaultSize
,
112 long style
= 0, const wxString
& name
= wxGLCanvasName
,
113 int *attribList
= (int*) NULL
,
114 const wxPalette
& palette
= wxNullPalette
);
115 wxGLCanvas( wxWindow
*parent
, const wxGLContext
*shared
,
117 const wxPoint
& pos
= wxDefaultPosition
,
118 const wxSize
& size
= wxDefaultSize
,
119 long style
= 0, const wxString
& name
= wxGLCanvasName
,
120 int *attribList
= (int*) NULL
,
121 const wxPalette
& palette
= wxNullPalette
);
122 wxGLCanvas( wxWindow
*parent
, const wxGLCanvas
*shared
,
124 const wxPoint
& pos
= wxDefaultPosition
,
125 const wxSize
& size
= wxDefaultSize
,
126 long style
= 0, const wxString
& name
= wxGLCanvasName
,
127 int *attribList
= (int*) NULL
,
128 const wxPalette
& palette
= wxNullPalette
);
130 bool Create( wxWindow
*parent
,
131 const wxGLContext
*shared
= (wxGLContext
*)NULL
,
132 const wxGLCanvas
*shared_context_of
= (wxGLCanvas
*)NULL
,
134 const wxPoint
& pos
= wxDefaultPosition
,
135 const wxSize
& size
= wxDefaultSize
,
137 const wxString
& name
= wxGLCanvasName
,
138 int *attribList
= (int*) NULL
,
139 const wxPalette
& palette
= wxNullPalette
);
144 void SetColour(const wxChar
*colour
);
147 void OnSize(wxSizeEvent
& event
);
149 void OnInternalIdle();
151 inline wxGLContext
* GetContext() const { return m_glContext
; }
155 wxGLContext
*m_glContext
,
157 wxGLCanvas
*m_sharedContextOf
;
158 void *m_vi
; // actually an XVisualInfo*
162 GtkWidget
*m_glWidget
;
165 // returns an XVisualInfo* based on desired GL attributes;
166 // returns NULL if an appropriate visual is not found. The
167 // caller is reponsible for using XFree() to deallocate
168 // the returned structure.
169 static void* ChooseGLVisual(int *attribList
);
170 static void* ChooseGLFBC(int *attribList
);
171 static void GetGLAttribListFromWX(int *wx_attribList
, int *gl_attribList
);
173 static void QueryGLXVersion();
174 static int GetGLXVersion();
175 static int m_glxVersion
;
177 DECLARE_EVENT_TABLE()
178 DECLARE_CLASS(wxGLCanvas
)