]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/glcanvas.h
Don't use wstring for MinGW versions that don't support it
[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:
b7ea712c 63 wxGLContext(wxWindow* win, const wxGLContext* other=NULL /* for sharing display lists */);
d3c7fc99 64 virtual ~wxGLContext();
8b089c5e 65
8b089c5e 66public:
b7ea712c
RR
67 // The win wxGLCanvas needs not necessarily be the same as the wxGLCanvas with which this context was created!
68 void SetCurrent(const wxGLCanvas& win) const;
8b089c5e 69
2b5f62a0 70
8b089c5e 71private:
b7ea712c
RR
72 GLXContext m_glContext;
73
74private:
75 DECLARE_CLASS(wxGLContext)
8b089c5e
JS
76};
77
78//---------------------------------------------------------------------------
a6f5aa49 79// wxGLCanvas
8b089c5e
JS
80//---------------------------------------------------------------------------
81
4660d7e5 82class WXDLLEXPORT wxGLCanvas: public wxWindow
8b089c5e
JS
83{
84public:
b7ea712c
RR
85 // This ctor is identical to the next, except for the fact that it
86 // doesn't create an implicit wxGLContext.
87 // The attribList parameter has been moved to avoid overload clashes.
88 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
89 int *attribList = (int*) NULL,
90 const wxPoint& pos = wxDefaultPosition,
91 const wxSize& size = wxDefaultSize,
92 long style = 0, const wxString& name = wxGLCanvasName,
93 const wxPalette& palette = wxNullPalette );
94
2b5f62a0 95 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
8b089c5e 96 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
97 const wxSize& size = wxDefaultSize,
98 long style = 0, const wxString& name = wxGLCanvasName,
99 int *attribList = (int*) NULL,
8b089c5e 100 const wxPalette& palette = wxNullPalette );
b7ea712c 101
a0573e8e 102 wxGLCanvas( wxWindow *parent, const wxGLContext *shared,
2b5f62a0 103 wxWindowID id = -1,
8b089c5e 104 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
105 const wxSize& size = wxDefaultSize,
106 long style = 0, const wxString& name = wxGLCanvasName,
107 int *attribList = (int*) NULL,
8b089c5e 108 const wxPalette& palette = wxNullPalette );
b7ea712c 109
a0573e8e 110 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared,
2b5f62a0 111 wxWindowID id = -1,
8b089c5e 112 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
113 const wxSize& size = wxDefaultSize,
114 long style = 0, const wxString& name = wxGLCanvasName,
115 int *attribList = (int*) NULL,
8b089c5e
JS
116 const wxPalette& palette = wxNullPalette );
117
2b5f62a0
VZ
118 bool Create( wxWindow *parent,
119 const wxGLContext *shared = (wxGLContext*)NULL,
120 const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
121 wxWindowID id = -1,
122 const wxPoint& pos = wxDefaultPosition,
123 const wxSize& size = wxDefaultSize,
124 long style = 0,
125 const wxString& name = wxGLCanvasName,
126 int *attribList = (int*) NULL,
127 const wxPalette& palette = wxNullPalette );
128
d3c7fc99 129 virtual ~wxGLCanvas();
8b089c5e 130
b7ea712c 131 void SetCurrent(const wxGLContext& RC) const;
8b089c5e 132 void SetCurrent();
2b5f62a0 133 void SetColour(const wxChar *colour);
8b089c5e
JS
134 void SwapBuffers();
135
136 void OnSize(wxSizeEvent& event);
2b5f62a0 137
8b089c5e
JS
138 void OnInternalIdle();
139
2b5f62a0 140 inline wxGLContext* GetContext() const { return m_glContext; }
8b089c5e
JS
141
142 // implementation
2b5f62a0 143
8b089c5e
JS
144 wxGLContext *m_glContext,
145 *m_sharedContext;
146 wxGLCanvas *m_sharedContextOf;
b7ea712c 147 const bool m_createImplicitContext;
a6f5aa49 148 void *m_vi; // actually an XVisualInfo*
34a34b02 149 GLXFBConfig *m_fbc;
a6f5aa49 150 bool m_canFreeVi;
34a34b02 151 bool m_canFreeFBC;
8b089c5e
JS
152 GtkWidget *m_glWidget;
153 bool m_exposed;
2b5f62a0 154
a6f5aa49
VZ
155 // returns an XVisualInfo* based on desired GL attributes;
156 // returns NULL if an appropriate visual is not found. The
2b5f62a0 157 // caller is reponsible for using XFree() to deallocate
a6f5aa49
VZ
158 // the returned structure.
159 static void* ChooseGLVisual(int *attribList);
34a34b02
VZ
160 static void* ChooseGLFBC(int *attribList);
161 static void GetGLAttribListFromWX(int *wx_attribList, int *gl_attribList );
8b089c5e 162
34a34b02
VZ
163 static void QueryGLXVersion();
164 static int GetGLXVersion();
165 static int m_glxVersion;
b7ea712c 166
8b089c5e
JS
167private:
168 DECLARE_EVENT_TABLE()
169 DECLARE_CLASS(wxGLCanvas)
170};
171
8b089c5e
JS
172#endif
173 // _WX_GLCANVAS_H_
174