]>
git.saurik.com Git - wxWidgets.git/blob - src/common/glcmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/glcmn.cpp
3 // Purpose: wxGLCanvasBase implementation
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
32 #include "wx/glcanvas.h"
34 // DLL options compatibility check:
36 WX_CHECK_BUILD_OPTIONS("wxGL")
38 IMPLEMENT_CLASS(wxGLApp
, wxApp
)
40 // ============================================================================
42 // ============================================================================
44 wxGLCanvasBase::wxGLCanvasBase()
46 #if WXWIN_COMPATIBILITY_2_8
50 // we always paint background entirely ourselves so prevent wx from erasing
51 // it to avoid flicker
52 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
55 void wxGLCanvasBase::SetCurrent(const wxGLContext
& context
) const
57 // although on MSW it works even if the window is still hidden, it doesn't
58 // work in other ports (notably X11-based ones) and documentation mentions
59 // that SetCurrent() can only be called for a shown window, so check for it
60 wxASSERT_MSG( IsShownOnScreen(), _T("can't make hidden GL canvas current") );
62 context
.SetCurrent(*wx_static_cast(const wxGLCanvas
*, this));
65 bool wxGLCanvasBase::SetColour(const wxString
& colour
)
67 wxColour col
= wxTheColourDatabase
->Find(colour
);
72 glGetBooleanv(GL_RGBA_MODE
, &isRGBA
);
75 glColor3f(col
.Red() / 256., col
.Green() / 256., col
.Blue() / 256.);
77 else // indexed colour
79 GLint pix
= GetColourIndex(col
);
82 wxLogError(_("Failed to allocate colour for OpenGL"));
92 wxGLCanvasBase::~wxGLCanvasBase()
94 #if WXWIN_COMPATIBILITY_2_8
96 #endif // WXWIN_COMPATIBILITY_2_8
99 #if WXWIN_COMPATIBILITY_2_8
101 wxGLContext
*wxGLCanvasBase::GetContext() const
106 void wxGLCanvasBase::SetCurrent()
109 SetCurrent(*m_glContext
);
112 void wxGLCanvasBase::OnSize(wxSizeEvent
& WXUNUSED(event
))
116 #endif // WXWIN_COMPATIBILITY_2_8
118 #endif // wxUSE_GLCANVAS