X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9d705dfa81cd65de8fe900a45b80494fa201ef0a..a67c56641d3a1a22764570f9d487ba916e4ade3c:/samples/opengl/penguin/penguin.cpp diff --git a/samples/opengl/penguin/penguin.cpp b/samples/opengl/penguin/penguin.cpp index 1b09d9530c..b1e573bd9b 100644 --- a/samples/opengl/penguin/penguin.cpp +++ b/samples/opengl/penguin/penguin.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -25,10 +25,6 @@ #include "wx/wx.h" #endif -#if !wxUSE_GLCANVAS -#error Please set wxUSE_GLCANVAS to 1 in setup.h. -#endif - #include "penguin.h" #ifdef __WXMAC__ # ifdef __DARWIN__ @@ -43,29 +39,37 @@ #define VIEW_ASPECT 1.3 /* `Main program' equivalent, creating windows and returning main app frame */ -bool MyApp::OnInit(void) +bool MyApp::OnInit() { /* Create the main frame window */ - MyFrame *frame = new MyFrame(NULL, "wxWindows OpenGL Demo", wxPoint(50, 50), wxSize(400, 300)); + MyFrame *frame = new MyFrame(NULL, wxT("wxWindows OpenGL Demo"), wxPoint(50, 50), wxSize(400, 300)); /* Make a menubar */ wxMenu *fileMenu = new wxMenu; - fileMenu->Append(wxID_EXIT, "E&xit"); + fileMenu->Append(wxID_EXIT, wxT("E&xit")); wxMenuBar *menuBar = new wxMenuBar; - menuBar->Append(fileMenu, "&File"); + menuBar->Append(fileMenu, wxT("&File")); frame->SetMenuBar(menuBar); - frame->m_canvas = new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200), wxSUNKEN_BORDER); +#if wxUSE_GLCANVAS + frame->SetCanvas( new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200), wxSUNKEN_BORDER) ); /* Load file wiht mesh data */ - frame->m_canvas->LoadLWO( "penguin.lwo" ); + frame->GetCanvas()->LoadLWO( wxT("penguin.lwo") ); /* Show the frame */ frame->Show(TRUE); return TRUE; +#else + + wxMessageBox( _T("This sample has to be compiled with wxUSE_GLCANVAS"), _T("Building error"), wxOK); + + return FALSE; + +#endif } IMPLEMENT_APP(MyApp) @@ -79,15 +83,19 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, long style): wxFrame(frame, -1, title, pos, size, style) { +#if wxUSE_GLCANVAS m_canvas = NULL; +#endif } /* Intercept menu commands */ -void MyFrame::OnExit(wxCommandEvent& event) +void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event)) { Destroy(); } +#if wxUSE_GLCANVAS + BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas) EVT_SIZE(TestGLCanvas::OnSize) EVT_PAINT(TestGLCanvas::OnPaint) @@ -108,7 +116,7 @@ TestGLCanvas::~TestGLCanvas(void) lw_object_free(info.lwobject); } -void TestGLCanvas::OnPaint( wxPaintEvent& event ) +void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) ) { /* must always be here */ wxPaintDC dc(this); @@ -159,8 +167,8 @@ void TestGLCanvas::OnSize(wxSizeEvent& event) wxGLCanvas::OnSize(event); // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) - int w, h; - GetClientSize(&w, &h); + int w, h; + GetClientSize(&w, &h); #ifndef __WXMOTIF__ if (GetContext()) #endif @@ -170,7 +178,7 @@ void TestGLCanvas::OnSize(wxSizeEvent& event) } } -void TestGLCanvas::OnEraseBackground(wxEraseEvent& event) +void TestGLCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) { /* Do nothing, to avoid flashing on MSW */ } @@ -178,10 +186,10 @@ void TestGLCanvas::OnEraseBackground(wxEraseEvent& event) void TestGLCanvas::LoadLWO(const wxString &filename) { /* test if lightwave object */ - if (!lw_is_lwobject(filename)) return; + if (!lw_is_lwobject(filename.mb_str())) return; /* read lightwave object */ - lwObject *lwobject = lw_object_read(filename); + lwObject *lwobject = lw_object_read(filename.mb_str()); /* scale */ lw_object_scale(lwobject, 10.0 / lw_object_radius(lwobject)); @@ -203,17 +211,17 @@ void TestGLCanvas::OnMouse( wxMouseEvent& event ) /* drag in progress, simulate trackball */ float spin_quat[4]; trackball(spin_quat, - (2.0*info.beginx - sz.x) / sz.x, - ( sz.y - 2.0*info.beginy) / sz.y, - ( 2.0*event.GetX() - sz.x) / sz.x, - ( sz.y - 2.0*event.GetY()) / sz.y); - + (2.0*info.beginx - sz.x) / sz.x, + ( sz.y - 2.0*info.beginy) / sz.y, + ( 2.0*event.GetX() - sz.x) / sz.x, + ( sz.y - 2.0*event.GetY()) / sz.y); + add_quats( spin_quat, info.quat, info.quat ); - + /* orientation has changed, redraw mesh */ - Refresh(FALSE); + Refresh(FALSE); } - + info.beginx = event.GetX(); info.beginy = event.GetY(); } @@ -249,3 +257,4 @@ void TestGLCanvas::InitGL(void) } +#endif