]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/glcanvas.h
Fixed typos in comments (patch #1515724)
[wxWidgets.git] / include / wx / gtk / glcanvas.h
CommitLineData
8b089c5e
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: glcanvas.h
77ffb593 3// Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWidgets and GTK
8b089c5e
JS
4// Author: Robert Roebling
5// Modified by:
6// Created: 17/8/98
7// RCS-ID: $Id$
8// Copyright: (c) Robert Roebling
65571936 9// Licence: wxWindows licence
8b089c5e
JS
10/////////////////////////////////////////////////////////////////////////////
11
db4c39a9
VZ
12#ifndef _WX_GLCANVAS_H_
13#define _WX_GLCANVAS_H_
14
a6f5aa49
VZ
15#include "wx/scrolwin.h"
16#include "wx/app.h"
8b089c5e
JS
17
18extern "C" {
a6f5aa49
VZ
19#include <GL/gl.h>
20#include <GL/glx.h>
21#include <GL/glu.h>
8b089c5e
JS
22}
23
24//---------------------------------------------------------------------------
25// Constants for attriblist
26//---------------------------------------------------------------------------
27
28enum
29{
30 WX_GL_RGBA=1, /* use true color palette */
f48d169c
UN
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 */
8b089c5e 33 WX_GL_DOUBLEBUFFER, /* use doublebuffer */
f48d169c
UN
34 WX_GL_STEREO, /* use stereoscopic display */
35 WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
8b089c5e
JS
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) */
f48d169c
UN
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) */
8b089c5e
JS
46};
47
48//---------------------------------------------------------------------------
49// classes
50//---------------------------------------------------------------------------
51
52class WXDLLEXPORT wxGLContext;
53class WXDLLEXPORT wxGLCanvas;
54
55//---------------------------------------------------------------------------
56// wxGLContext
57//---------------------------------------------------------------------------
58
59
60class WXDLLEXPORT wxGLContext: public wxObject
61{
62public:
63 wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
2b5f62a0
VZ
64 wxGLContext(
65 bool WXUNUSED(isRGB), wxWindow *win,
8b089c5e
JS
66 const wxPalette& WXUNUSED(palette),
67 const wxGLContext *other /* for sharing display lists */
68 );
69 ~wxGLContext();
70
71 void SetCurrent();
2b5f62a0 72 void SetColour(const wxChar *colour);
8b089c5e
JS
73 void SwapBuffers();
74
75 void SetupPixelFormat();
76 void SetupPalette(const wxPalette& palette);
77 wxPalette CreateDefaultPalette();
78
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; }
83
84public:
85 GLXContext m_glContext;
86
87 GtkWidget *m_widget;
88 wxPalette m_palette;
89 wxWindow* m_window;
2b5f62a0 90
8b089c5e
JS
91private:
92 DECLARE_CLASS(wxGLContext)
93};
94
95//---------------------------------------------------------------------------
a6f5aa49 96// wxGLCanvas
8b089c5e
JS
97//---------------------------------------------------------------------------
98
4660d7e5 99class WXDLLEXPORT wxGLCanvas: public wxWindow
8b089c5e
JS
100{
101public:
102 inline wxGLCanvas() {
103 m_glContext = (wxGLContext*) NULL;
104 m_sharedContext = (wxGLContext*) NULL;
105 m_glWidget = (GtkWidget*) NULL;
106 m_vi = (void*) NULL;
107 m_exposed = FALSE;
108 }
2b5f62a0 109 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
8b089c5e 110 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
111 const wxSize& size = wxDefaultSize,
112 long style = 0, const wxString& name = wxGLCanvasName,
113 int *attribList = (int*) NULL,
8b089c5e 114 const wxPalette& palette = wxNullPalette );
a0573e8e 115 wxGLCanvas( wxWindow *parent, const wxGLContext *shared,
2b5f62a0 116 wxWindowID id = -1,
8b089c5e 117 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
118 const wxSize& size = wxDefaultSize,
119 long style = 0, const wxString& name = wxGLCanvasName,
120 int *attribList = (int*) NULL,
8b089c5e 121 const wxPalette& palette = wxNullPalette );
a0573e8e 122 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared,
2b5f62a0 123 wxWindowID id = -1,
8b089c5e 124 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
125 const wxSize& size = wxDefaultSize,
126 long style = 0, const wxString& name = wxGLCanvasName,
127 int *attribList = (int*) NULL,
8b089c5e
JS
128 const wxPalette& palette = wxNullPalette );
129
2b5f62a0
VZ
130 bool Create( wxWindow *parent,
131 const wxGLContext *shared = (wxGLContext*)NULL,
132 const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
133 wxWindowID id = -1,
134 const wxPoint& pos = wxDefaultPosition,
135 const wxSize& size = wxDefaultSize,
136 long style = 0,
137 const wxString& name = wxGLCanvasName,
138 int *attribList = (int*) NULL,
139 const wxPalette& palette = wxNullPalette );
140
8b089c5e
JS
141 ~wxGLCanvas();
142
143 void SetCurrent();
2b5f62a0 144 void SetColour(const wxChar *colour);
8b089c5e
JS
145 void SwapBuffers();
146
147 void OnSize(wxSizeEvent& event);
2b5f62a0 148
8b089c5e
JS
149 void OnInternalIdle();
150
2b5f62a0 151 inline wxGLContext* GetContext() const { return m_glContext; }
8b089c5e
JS
152
153 // implementation
2b5f62a0 154
8b089c5e
JS
155 wxGLContext *m_glContext,
156 *m_sharedContext;
157 wxGLCanvas *m_sharedContextOf;
a6f5aa49 158 void *m_vi; // actually an XVisualInfo*
34a34b02 159 GLXFBConfig *m_fbc;
a6f5aa49 160 bool m_canFreeVi;
34a34b02 161 bool m_canFreeFBC;
8b089c5e
JS
162 GtkWidget *m_glWidget;
163 bool m_exposed;
2b5f62a0 164
a6f5aa49
VZ
165 // returns an XVisualInfo* based on desired GL attributes;
166 // returns NULL if an appropriate visual is not found. The
2b5f62a0 167 // caller is reponsible for using XFree() to deallocate
a6f5aa49
VZ
168 // the returned structure.
169 static void* ChooseGLVisual(int *attribList);
34a34b02
VZ
170 static void* ChooseGLFBC(int *attribList);
171 static void GetGLAttribListFromWX(int *wx_attribList, int *gl_attribList );
8b089c5e 172
34a34b02
VZ
173 static void QueryGLXVersion();
174 static int GetGLXVersion();
175 static int m_glxVersion;
8b089c5e
JS
176private:
177 DECLARE_EVENT_TABLE()
178 DECLARE_CLASS(wxGLCanvas)
179};
180
8b089c5e
JS
181#endif
182 // _WX_GLCANVAS_H_
183