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