]> git.saurik.com Git - wxWidgets.git/blob - src/x11/glcanvas.cpp
non-pch build fix
[wxWidgets.git] / src / x11 / glcanvas.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/glcanvas.cpp
3 // Purpose: wxGLCanvas, for using OpenGL with wxWidgets
4 // Uses the GLX extension.
5 // Author: Julian Smart and Wolfram Gloger
6 // Modified by: Vadim Zeitlin to update to new API
7 // Created: 1995, 1999
8 // RCS-ID: $Id$
9 // Copyright: (c) Julian Smart, Wolfram Gloger
10 // Licence: wxWindows licence
11 ///////////////////////////////////////////////////////////////////////////////
12
13 // TODO: merge this with wxGTK version in some src/unix/glcanvasx11.cpp
14
15 // ============================================================================
16 // declarations
17 // ============================================================================
18
19 // ----------------------------------------------------------------------------
20 // headers
21 // ----------------------------------------------------------------------------
22
23 // for compilers that support precompilation, includes "wx.h".
24 #include "wx/wxprec.h"
25
26 #if defined(__BORLANDC__)
27 #pragma hdrstop
28 #endif
29
30 #if wxUSE_GLCANVAS
31
32 #include "wx/glcanvas.h"
33
34 #ifndef WX_PRECOMP
35 #include "wx/app.h"
36 #include "wx/utils.h"
37 #endif
38
39 // ============================================================================
40 // implementation
41 // ============================================================================
42
43 IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
44
45 wxGLCanvas::wxGLCanvas(wxWindow *parent,
46 wxWindowID id,
47 const int *attribList,
48 const wxPoint& pos,
49 const wxSize& size,
50 long style,
51 const wxString& name,
52 const wxPalette& palette)
53 {
54 Create(parent, id, pos, size, style, name, attribList, palette);
55 }
56
57 bool wxGLCanvas::Create(wxWindow *parent,
58 wxWindowID id,
59 const wxPoint& pos,
60 const wxSize& size,
61 long style,
62 const wxString& name,
63 const int *attribList,
64 const wxPalette& WXUNUSED(palette))
65 {
66 if ( !wxWindow::Create(parent, id, pos, size, style, name) )
67 return false;
68
69 if ( !InitVisual(attribList) )
70 return false;
71
72 return true;
73 }
74
75 Window wxGLCanvas::GetXWindow() const
76 {
77 return (Window)
78 #ifdef __WXMOTIF__
79 GetClientXWindow();
80 #else
81 GetClientAreaWindow();
82 #endif
83 }
84
85 int wxGLCanvas::GetColourIndex(const wxColour& col_)
86 {
87 wxColour& col = const_cast<wxColour&>(col_);
88
89 #ifdef __WXMOTIF__
90 col.AllocColour(GetXDisplay());
91 #else
92 col.CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay()));
93 #endif
94
95 return col.GetPixel();
96 }
97
98 #endif // wxUSE_GLCANVAS