]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/glcanvas.h
rename the menu to avoid conflict with a standard Mac menu
[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
8b089c5e
JS
24//---------------------------------------------------------------------------
25// classes
26//---------------------------------------------------------------------------
27
28class WXDLLEXPORT wxGLContext;
29class WXDLLEXPORT wxGLCanvas;
30
31//---------------------------------------------------------------------------
32// wxGLContext
33//---------------------------------------------------------------------------
34
35
36class WXDLLEXPORT wxGLContext: public wxObject
37{
38public:
b7ea712c 39 wxGLContext(wxWindow* win, const wxGLContext* other=NULL /* for sharing display lists */);
d3c7fc99 40 virtual ~wxGLContext();
8b089c5e 41
8b089c5e 42public:
b7ea712c
RR
43 // The win wxGLCanvas needs not necessarily be the same as the wxGLCanvas with which this context was created!
44 void SetCurrent(const wxGLCanvas& win) const;
8b089c5e 45
2b5f62a0 46
8b089c5e 47private:
b7ea712c
RR
48 GLXContext m_glContext;
49
50private:
51 DECLARE_CLASS(wxGLContext)
8b089c5e
JS
52};
53
54//---------------------------------------------------------------------------
a6f5aa49 55// wxGLCanvas
8b089c5e
JS
56//---------------------------------------------------------------------------
57
4660d7e5 58class WXDLLEXPORT wxGLCanvas: public wxWindow
8b089c5e
JS
59{
60public:
b7ea712c
RR
61 // This ctor is identical to the next, except for the fact that it
62 // doesn't create an implicit wxGLContext.
63 // The attribList parameter has been moved to avoid overload clashes.
64 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
65 int *attribList = (int*) NULL,
66 const wxPoint& pos = wxDefaultPosition,
67 const wxSize& size = wxDefaultSize,
68 long style = 0, const wxString& name = wxGLCanvasName,
69 const wxPalette& palette = wxNullPalette );
70
2b5f62a0 71 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
8b089c5e 72 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
73 const wxSize& size = wxDefaultSize,
74 long style = 0, const wxString& name = wxGLCanvasName,
75 int *attribList = (int*) NULL,
8b089c5e 76 const wxPalette& palette = wxNullPalette );
b7ea712c 77
a0573e8e 78 wxGLCanvas( wxWindow *parent, const wxGLContext *shared,
2b5f62a0 79 wxWindowID id = -1,
8b089c5e 80 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
81 const wxSize& size = wxDefaultSize,
82 long style = 0, const wxString& name = wxGLCanvasName,
83 int *attribList = (int*) NULL,
8b089c5e 84 const wxPalette& palette = wxNullPalette );
b7ea712c 85
a0573e8e 86 wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared,
2b5f62a0 87 wxWindowID id = -1,
8b089c5e 88 const wxPoint& pos = wxDefaultPosition,
2b5f62a0
VZ
89 const wxSize& size = wxDefaultSize,
90 long style = 0, const wxString& name = wxGLCanvasName,
91 int *attribList = (int*) NULL,
8b089c5e
JS
92 const wxPalette& palette = wxNullPalette );
93
2b5f62a0
VZ
94 bool Create( wxWindow *parent,
95 const wxGLContext *shared = (wxGLContext*)NULL,
96 const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
97 wxWindowID id = -1,
98 const wxPoint& pos = wxDefaultPosition,
99 const wxSize& size = wxDefaultSize,
100 long style = 0,
101 const wxString& name = wxGLCanvasName,
102 int *attribList = (int*) NULL,
103 const wxPalette& palette = wxNullPalette );
104
d3c7fc99 105 virtual ~wxGLCanvas();
8b089c5e 106
b7ea712c 107 void SetCurrent(const wxGLContext& RC) const;
8b089c5e 108 void SetCurrent();
2b5f62a0 109 void SetColour(const wxChar *colour);
8b089c5e
JS
110 void SwapBuffers();
111
112 void OnSize(wxSizeEvent& event);
2b5f62a0 113
8b089c5e
JS
114 void OnInternalIdle();
115
2b5f62a0 116 inline wxGLContext* GetContext() const { return m_glContext; }
8b089c5e
JS
117
118 // implementation
2b5f62a0 119
8b089c5e
JS
120 wxGLContext *m_glContext,
121 *m_sharedContext;
122 wxGLCanvas *m_sharedContextOf;
b7ea712c 123 const bool m_createImplicitContext;
a6f5aa49 124 void *m_vi; // actually an XVisualInfo*
34a34b02 125 GLXFBConfig *m_fbc;
a6f5aa49 126 bool m_canFreeVi;
34a34b02 127 bool m_canFreeFBC;
8b089c5e
JS
128 GtkWidget *m_glWidget;
129 bool m_exposed;
2b5f62a0 130
a6f5aa49
VZ
131 // returns an XVisualInfo* based on desired GL attributes;
132 // returns NULL if an appropriate visual is not found. The
2b5f62a0 133 // caller is reponsible for using XFree() to deallocate
a6f5aa49
VZ
134 // the returned structure.
135 static void* ChooseGLVisual(int *attribList);
34a34b02
VZ
136 static void* ChooseGLFBC(int *attribList);
137 static void GetGLAttribListFromWX(int *wx_attribList, int *gl_attribList );
8b089c5e 138
34a34b02
VZ
139 static void QueryGLXVersion();
140 static int GetGLXVersion();
141 static int m_glxVersion;
b7ea712c 142
8b089c5e
JS
143private:
144 DECLARE_EVENT_TABLE()
145 DECLARE_CLASS(wxGLCanvas)
146};
147
8b089c5e
JS
148#endif
149 // _WX_GLCANVAS_H_
150