]> git.saurik.com Git - wxWidgets.git/blob - utils/glcanvas/gtk/glcanvas.h
Chnaged wxGLCanvas::SetSize() to DoSetSize()
[wxWidgets.git] / utils / glcanvas / gtk / glcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: glcanvas.h
3 // Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 17/8/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma interface "glcanvas.h"
14 #endif
15
16 #ifndef _WX_GLCANVAS_H_
17 #define _WX_GLCANVAS_H_
18
19 #include "wx/defs.h"
20 #include "wx/scrolwin.h"
21
22 extern "C" {
23 #include "GL/gl.h"
24 #include "GL/glx.h"
25 #include "GL/glu.h"
26 }
27
28 //---------------------------------------------------------------------------
29 // classes
30 //---------------------------------------------------------------------------
31
32 class wxGLContext;
33 class wxGLCanvas;
34
35 //---------------------------------------------------------------------------
36 // wxGLContext
37 //---------------------------------------------------------------------------
38
39
40 class wxGLContext: public wxObject
41 {
42 DECLARE_CLASS(wxGLContext)
43
44 public:
45
46 wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
47 ~wxGLContext();
48
49 void SetCurrent();
50 void SetColour(const char *colour);
51 void SwapBuffers();
52
53 void SetupPixelFormat();
54 void SetupPalette(const wxPalette& palette);
55 wxPalette CreateDefaultPalette();
56
57 inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
58 inline wxWindow* GetWindow() const { return m_window; }
59 inline GtkWidget* GetWidget() const { return m_widget; }
60 inline GLXContext GetContext() const { return m_glContext; }
61
62 public:
63
64 GLXContext m_glContext;
65
66 GtkWidget *m_widget;
67 wxPalette m_palette;
68 wxWindow* m_window;
69 };
70
71 //---------------------------------------------------------------------------
72 // wxGLContext
73 //---------------------------------------------------------------------------
74
75 class wxGLCanvas: public wxScrolledWindow
76 {
77 DECLARE_CLASS(wxGLCanvas)
78
79 public:
80 wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& size = wxDefaultSize,
83 long style = 0, const wxString& name = "GLCanvas",
84 int *attribList = (int*) NULL,
85 const wxPalette& palette = wxNullPalette );
86
87 bool Create( wxWindow *parent, wxWindowID id = -1,
88 const wxPoint& pos = wxDefaultPosition,
89 const wxSize& size = wxDefaultSize,
90 long style = 0, const wxString& name = "GLCanvas",
91 int *attribList = (int*) NULL,
92 const wxPalette& palette = wxNullPalette );
93
94 ~wxGLCanvas();
95
96 void SetCurrent();
97 void SetColour(const char *colour);
98 void SwapBuffers();
99
100 void OnSize(wxSizeEvent& event);
101
102 inline wxGLContext* GetContext() const { return m_glContext; }
103
104 // implementation
105
106 virtual void DoSetSize( int x, int y, int width, int height,
107 int sizeFlags = wxSIZE_AUTO );
108
109 virtual GtkWidget *GetConnectWidget();
110 bool IsOwnGtkWindow( GdkWindow *window );
111
112 wxGLContext *m_glContext;
113 GtkWidget *m_glWidget;
114
115 DECLARE_EVENT_TABLE()
116 };
117
118 #endif