X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5fa399c9e241e99132733b09673cbcb76c9f77e1..b2644cc3ccb41de07e2160857f1cc0c2a2069d79:/samples/opengl/penguin/penguin.cpp diff --git a/samples/opengl/penguin/penguin.cpp b/samples/opengl/penguin/penguin.cpp index 077fc90bca..0c68641835 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__ @@ -30,29 +30,37 @@ #endif #include "penguin.h" -#include +#ifdef __WXMAC__ +# ifdef __DARWIN__ +# include +# else +# include +# endif +#else +# include +#endif #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)); + 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); @@ -147,15 +155,18 @@ void TestGLCanvas::OnPaint( wxPaintEvent& event ) void TestGLCanvas::OnSize(wxSizeEvent& event) { - int width, height; - GetClientSize(& width, & height); + // this is also necessary to update the context on some platforms + wxGLCanvas::OnSize(event); + // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) + int w, h; + GetClientSize(&w, &h); #ifndef __WXMOTIF__ if (GetContext()) #endif { SetCurrent(); - glViewport(0, 0, width, height); + glViewport(0, 0, (GLint) w, (GLint) h); } } @@ -167,10 +178,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)); @@ -192,17 +203,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(); }