]>
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 void wxGLCanvasBase::SetCurrent(const wxGLContext
& context
) const
46 // although on MSW it works even if the window is still hidden, it doesn't
47 // work in other ports (notably X11-based ones) and documentation mentions
48 // that SetCurrent() can only be called for a shown window, so check for it
49 wxASSERT_MSG( IsShownOnScreen(), _T("can't make hidden GL canvas current") );
51 context
.SetCurrent(*wx_static_cast(const wxGLCanvas
*, this));
54 bool wxGLCanvasBase::SetColour(const wxChar
*colour
)
56 wxColour col
= wxTheColourDatabase
->Find(colour
);
61 glGetBooleanv(GL_RGBA_MODE
, &isRGBA
);
64 glColor3f(col
.Red() / 256., col
.Green() / 256., col
.Blue() / 256.);
66 else // indexed colour
68 GLint pix
= GetColourIndex(col
);
71 wxLogError(_("Failed to allocate colour for OpenGL"));
81 wxGLCanvasBase::~wxGLCanvasBase()
83 #if WXWIN_COMPATIBILITY_2_8
85 #endif // WXWIN_COMPATIBILITY_2_8
88 #if WXWIN_COMPATIBILITY_2_8
90 wxGLContext
*wxGLCanvasBase::GetContext() const
95 void wxGLCanvasBase::SetCurrent()
98 SetCurrent(*m_glContext
);
101 void wxGLCanvasBase::OnSize(wxSizeEvent
& WXUNUSED(event
))
105 #endif // WXWIN_COMPATIBILITY_2_8
107 #endif // wxUSE_GLCANVAS