// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#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__
#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)
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)
lw_object_free(info.lwobject);
}
-void TestGLCanvas::OnPaint( wxPaintEvent& event )
+void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
/* must always be here */
wxPaintDC dc(this);
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
}
}
-void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
+void TestGLCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
{
/* Do nothing, to avoid flashing on MSW */
}
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));
/* 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();
}
}
+#endif