]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/glcanvas.h
3eec4ab6ada4fd4d674ac632d2b2ffcc60d0800a
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma interface "glcanvas.h"
16 #ifndef _WX_GLCANVAS_H_
17 #define _WX_GLCANVAS_H_
23 #include "wx/scrolwin.h"
32 //---------------------------------------------------------------------------
33 // Constants for attriblist
34 //---------------------------------------------------------------------------
38 WX_GL_RGBA
=1, /* use true color palette */
39 WX_GL_BUFFER_SIZE
, /* bits for buffer if not WX_GL_RGBA */
40 WX_GL_LEVEL
, /* 0 for main buffer, >0 for overlay, <0 for underlay */
41 WX_GL_DOUBLEBUFFER
, /* use doublebuffer */
42 WX_GL_STEREO
, /* use stereoscopic display */
43 WX_GL_AUX_BUFFERS
, /* number of auxiliary buffers */
44 WX_GL_MIN_RED
, /* use red buffer with most bits (> MIN_RED bits) */
45 WX_GL_MIN_GREEN
, /* use green buffer with most bits (> MIN_GREEN bits) */
46 WX_GL_MIN_BLUE
, /* use blue buffer with most bits (> MIN_BLUE bits) */
47 WX_GL_MIN_ALPHA
, /* use blue buffer with most bits (> MIN_ALPHA bits) */
48 WX_GL_DEPTH_SIZE
, /* bits for Z-buffer (0,16,32) */
49 WX_GL_STENCIL_SIZE
, /* bits for stencil buffer */
50 WX_GL_MIN_ACCUM_RED
, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
51 WX_GL_MIN_ACCUM_GREEN
, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
52 WX_GL_MIN_ACCUM_BLUE
, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
53 WX_GL_MIN_ACCUM_ALPHA
/* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
56 //---------------------------------------------------------------------------
58 //---------------------------------------------------------------------------
60 class WXDLLEXPORT wxGLContext
;
61 class WXDLLEXPORT wxGLCanvas
;
63 //---------------------------------------------------------------------------
65 //---------------------------------------------------------------------------
68 class WXDLLEXPORT wxGLContext
: public wxObject
71 wxGLContext( bool isRGB
, wxWindow
*win
, const wxPalette
& palette
= wxNullPalette
);
73 bool WXUNUSED(isRGB
), wxWindow
*win
,
74 const wxPalette
& WXUNUSED(palette
),
75 const wxGLContext
*other
/* for sharing display lists */
80 void SetColour(const char *colour
);
83 void SetupPixelFormat();
84 void SetupPalette(const wxPalette
& palette
);
85 wxPalette
CreateDefaultPalette();
87 inline wxPalette
* GetPalette() const { return (wxPalette
*) & m_palette
; }
88 inline wxWindow
* GetWindow() const { return m_window
; }
89 inline GtkWidget
* GetWidget() const { return m_widget
; }
90 inline GLXContext
GetContext() const { return m_glContext
; }
93 GLXContext m_glContext
;
100 DECLARE_CLASS(wxGLContext
)
103 //---------------------------------------------------------------------------
105 //---------------------------------------------------------------------------
107 class WXDLLEXPORT wxGLCanvas
: public wxScrolledWindow
110 inline wxGLCanvas() {
111 m_glContext
= (wxGLContext
*) NULL
;
112 m_sharedContext
= (wxGLContext
*) NULL
;
113 m_glWidget
= (GtkWidget
*) NULL
;
117 wxGLCanvas( wxWindow
*parent
, wxWindowID id
= -1,
118 const wxPoint
& pos
= wxDefaultPosition
,
119 const wxSize
& size
= wxDefaultSize
,
120 long style
= 0, const wxString
& name
= "GLCanvas",
121 int *attribList
= (int*) NULL
,
122 const wxPalette
& palette
= wxNullPalette
);
123 wxGLCanvas( wxWindow
*parent
, const wxGLContext
*shared
= (wxGLContext
*)NULL
,
125 const wxPoint
& pos
= wxDefaultPosition
,
126 const wxSize
& size
= wxDefaultSize
,
127 long style
= 0, const wxString
& name
= "GLCanvas",
128 int *attribList
= (int*) NULL
,
129 const wxPalette
& palette
= wxNullPalette
);
130 wxGLCanvas( wxWindow
*parent
, const wxGLCanvas
*shared
= (wxGLCanvas
*)NULL
,
132 const wxPoint
& pos
= wxDefaultPosition
,
133 const wxSize
& size
= wxDefaultSize
,
134 long style
= 0, const wxString
& name
= "GLCanvas",
135 int *attribList
= (int*) NULL
,
136 const wxPalette
& palette
= wxNullPalette
);
138 bool Create( wxWindow
*parent
,
139 const wxGLContext
*shared
= (wxGLContext
*)NULL
,
140 const wxGLCanvas
*shared_context_of
= (wxGLCanvas
*)NULL
,
142 const wxPoint
& pos
= wxDefaultPosition
,
143 const wxSize
& size
= wxDefaultSize
,
144 long style
= 0, const wxString
& name
= "GLCanvas",
145 int *attribList
= (int*) NULL
,
146 const wxPalette
& palette
= wxNullPalette
);
151 void SetColour(const char *colour
);
154 void OnSize(wxSizeEvent
& event
);
156 void OnInternalIdle();
158 inline wxGLContext
* GetContext() const { return m_glContext
; }
162 wxGLContext
*m_glContext
,
164 wxGLCanvas
*m_sharedContextOf
;
165 void *m_vi
; // actually an XVisualInfo*
167 GtkWidget
*m_glWidget
;
170 // returns an XVisualInfo* based on desired GL attributes;
171 // returns NULL if an appropriate visual is not found. The
172 // caller is reponsible for using XFree() to deallocate
173 // the returned structure.
174 static void* ChooseGLVisual(int *attribList
);
177 DECLARE_EVENT_TABLE()
178 DECLARE_CLASS(wxGLCanvas
)
182 //---------------------------------------------------------------------------
184 //---------------------------------------------------------------------------
186 class WXDLLEXPORT wxGLApp
: public wxApp
189 wxGLApp() : wxApp() { }
192 // use this in the constructor of the user-derived wxGLApp class to select
193 // an appropriate X visual for GL. Returns TRUE if an appropriate visual
194 // is found - and sets m_glVisualInfo; FALSE otherwise.
195 bool InitGLVisual(int *attribList
);
198 DECLARE_DYNAMIC_CLASS(wxGLApp
)