]> git.saurik.com Git - wxWidgets.git/blame - src/x11/glcanvas.cpp
Make info bar buttons smaller.
[wxWidgets.git] / src / x11 / glcanvas.cpp
CommitLineData
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
JS
7// Created: 1995, 1999
8// RCS-ID: $Id$
9// Copyright: (c) Julian Smart, Wolfram Gloger
521bf4ff 10// Licence: wxWindows licence
dc3065a5
VZ
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// ----------------------------------------------------------------------------
83df96d6 22
521bf4ff
WS
23// for compilers that support precompilation, includes "wx.h".
24#include "wx/wxprec.h"
25
26#if defined(__BORLANDC__)
670f9935 27 #pragma hdrstop
521bf4ff 28#endif
83df96d6
JS
29
30#if wxUSE_GLCANVAS
31
32#include "wx/glcanvas.h"
e4db172a
WS
33
34#ifndef WX_PRECOMP
670f9935 35 #include "wx/app.h"
de6185e2 36 #include "wx/utils.h"
e4db172a
WS
37#endif
38
dc3065a5
VZ
39// ============================================================================
40// implementation
41// ============================================================================
83df96d6 42
dc3065a5 43IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
83df96d6 44
dc3065a5
VZ
45wxGLCanvas::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)
83df96d6 53{
dc3065a5 54 Create(parent, id, pos, size, style, name, attribList, palette);
83df96d6
JS
55}
56
dc3065a5 57bool wxGLCanvas::Create(wxWindow *parent,
83df96d6 58 wxWindowID id,
dc3065a5
VZ
59 const wxPoint& pos,
60 const wxSize& size,
61 long style,
62 const wxString& name,
63 const int *attribList,
64 const wxPalette& palette)
521bf4ff 65{
dc3065a5
VZ
66 if ( !wxWindow::Create(parent, id, pos, size, style, name) )
67 return false;
83df96d6 68
498ace9e 69 if ( !InitVisual(attribList) )
521bf4ff 70 return false;
83df96d6 71
521bf4ff 72 return true;
83df96d6
JS
73}
74
498ace9e 75Window wxGLCanvas::GetXWindow() const
83df96d6 76{
498ace9e
VZ
77 return (Window)
78#ifdef __WXMOTIF__
79 GetClientXWindow();
80#else
81 GetClientAreaWindow();
82#endif
83df96d6
JS
83}
84
dc3065a5 85int wxGLCanvas::GetColourIndex(const wxColour& col_)
83df96d6 86{
5c33522f 87 wxColour& col = const_cast<wxColour&>(col_);
83df96d6 88
dc3065a5
VZ
89#ifdef __WXMOTIF__
90 col.AllocColour(GetXDisplay());
91#else
92 col.CalcPixel(wxTheApp->GetMainColormap(wxGetDisplay()));
93#endif
83df96d6 94
dc3065a5 95 return col.GetPixel();
83df96d6
JS
96}
97
dc3065a5 98#endif // wxUSE_GLCANVAS