]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/glcanvas.h
f4c812ffa893d761b416e5b888b9d0c704bc204d
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "glcanvas.h"
19 #include "wx/scrolwin.h"
28 //---------------------------------------------------------------------------
29 // Constants for attriblist
30 //---------------------------------------------------------------------------
34 WX_GL_RGBA
=1, /* use true color palette */
35 WX_GL_BUFFER_SIZE
, /* bits for buffer if not WX_GL_RGBA */
36 WX_GL_LEVEL
, /* 0 for main buffer, >0 for overlay, <0 for underlay */
37 WX_GL_DOUBLEBUFFER
, /* use doublebuffer */
38 WX_GL_STEREO
, /* use stereoscopic display */
39 WX_GL_AUX_BUFFERS
, /* number of auxiliary buffers */
40 WX_GL_MIN_RED
, /* use red buffer with most bits (> MIN_RED bits) */
41 WX_GL_MIN_GREEN
, /* use green buffer with most bits (> MIN_GREEN bits) */
42 WX_GL_MIN_BLUE
, /* use blue buffer with most bits (> MIN_BLUE bits) */
43 WX_GL_MIN_ALPHA
, /* use blue buffer with most bits (> MIN_ALPHA bits) */
44 WX_GL_DEPTH_SIZE
, /* bits for Z-buffer (0,16,32) */
45 WX_GL_STENCIL_SIZE
, /* bits for stencil buffer */
46 WX_GL_MIN_ACCUM_RED
, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
47 WX_GL_MIN_ACCUM_GREEN
, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
48 WX_GL_MIN_ACCUM_BLUE
, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
49 WX_GL_MIN_ACCUM_ALPHA
/* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
52 //---------------------------------------------------------------------------
54 //---------------------------------------------------------------------------
56 class WXDLLEXPORT wxGLContext
;
57 class WXDLLEXPORT wxGLCanvas
;
59 //---------------------------------------------------------------------------
61 //---------------------------------------------------------------------------
64 class WXDLLEXPORT wxGLContext
: public wxObject
67 wxGLContext( bool isRGB
, wxWindow
*win
, const wxPalette
& palette
= wxNullPalette
);
69 bool WXUNUSED(isRGB
), wxWindow
*win
,
70 const wxPalette
& WXUNUSED(palette
),
71 const wxGLContext
*other
/* for sharing display lists */
76 void SetColour(const wxChar
*colour
);
79 void SetupPixelFormat();
80 void SetupPalette(const wxPalette
& palette
);
81 wxPalette
CreateDefaultPalette();
83 inline wxPalette
* GetPalette() const { return (wxPalette
*) & m_palette
; }
84 inline wxWindow
* GetWindow() const { return m_window
; }
85 inline GtkWidget
* GetWidget() const { return m_widget
; }
86 inline GLXContext
GetContext() const { return m_glContext
; }
89 GLXContext m_glContext
;
96 DECLARE_CLASS(wxGLContext
)
99 //---------------------------------------------------------------------------
101 //---------------------------------------------------------------------------
103 class WXDLLEXPORT wxGLCanvas
: public wxWindow
106 inline wxGLCanvas() {
107 m_glContext
= (wxGLContext
*) NULL
;
108 m_sharedContext
= (wxGLContext
*) NULL
;
109 m_glWidget
= (GtkWidget
*) NULL
;
113 wxGLCanvas( wxWindow
*parent
, wxWindowID id
= -1,
114 const wxPoint
& pos
= wxDefaultPosition
,
115 const wxSize
& size
= wxDefaultSize
,
116 long style
= 0, const wxString
& name
= wxGLCanvasName
,
117 int *attribList
= (int*) NULL
,
118 const wxPalette
& palette
= wxNullPalette
);
119 wxGLCanvas( wxWindow
*parent
, const wxGLContext
*shared
= (wxGLContext
*)NULL
,
121 const wxPoint
& pos
= wxDefaultPosition
,
122 const wxSize
& size
= wxDefaultSize
,
123 long style
= 0, const wxString
& name
= wxGLCanvasName
,
124 int *attribList
= (int*) NULL
,
125 const wxPalette
& palette
= wxNullPalette
);
126 wxGLCanvas( wxWindow
*parent
, const wxGLCanvas
*shared
= (wxGLCanvas
*)NULL
,
128 const wxPoint
& pos
= wxDefaultPosition
,
129 const wxSize
& size
= wxDefaultSize
,
130 long style
= 0, const wxString
& name
= wxGLCanvasName
,
131 int *attribList
= (int*) NULL
,
132 const wxPalette
& palette
= wxNullPalette
);
134 bool Create( wxWindow
*parent
,
135 const wxGLContext
*shared
= (wxGLContext
*)NULL
,
136 const wxGLCanvas
*shared_context_of
= (wxGLCanvas
*)NULL
,
138 const wxPoint
& pos
= wxDefaultPosition
,
139 const wxSize
& size
= wxDefaultSize
,
141 const wxString
& name
= wxGLCanvasName
,
142 int *attribList
= (int*) NULL
,
143 const wxPalette
& palette
= wxNullPalette
);
148 void SetColour(const wxChar
*colour
);
151 void OnSize(wxSizeEvent
& event
);
153 void OnInternalIdle();
155 inline wxGLContext
* GetContext() const { return m_glContext
; }
159 wxGLContext
*m_glContext
,
161 wxGLCanvas
*m_sharedContextOf
;
162 void *m_vi
; // actually an XVisualInfo*
164 GtkWidget
*m_glWidget
;
167 // returns an XVisualInfo* based on desired GL attributes;
168 // returns NULL if an appropriate visual is not found. The
169 // caller is reponsible for using XFree() to deallocate
170 // the returned structure.
171 static void* ChooseGLVisual(int *attribList
);
174 DECLARE_EVENT_TABLE()
175 DECLARE_CLASS(wxGLCanvas
)