00001 #ifndef _VCanvas_
00002 #define _VCanvas_
00003
00004 #include "VLighting.h"
00005
00006 #include "wx/wxprec.h"
00007 #include "wx/textctrl.h"
00008 #include "wx/dcclient.h"
00009 #include "wx/glcanvas.h"
00010 #if !wxUSE_GLCANVAS
00011 #error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
00012 #endif
00013
00014 class wxXmlNode;
00015 class VWorld;
00016
00027 class VCanvas: public wxGLCanvas
00028 {
00029 public:
00036 VCanvas(VWorld *world, wxWindow *parent, wxWindowID id = wxID_ANY,
00037 const wxPoint& pos = wxDefaultPosition,
00038 const wxSize& size = wxDefaultSize, long style = 0,
00039 const wxString& name = wxT("VCanvas"));
00040
00041 ~VCanvas();
00042
00047 bool initFromXML(const wxXmlNode &node);
00048
00059 void setCameraPosition(const double distance, const double elevation,
00060 const double azimuth, const double twist);
00061 void getCameraPosition(double &distance, double &elevation,
00062 double &azimuth, double &twist) const;
00063
00067 void onPaint(wxPaintEvent& event);
00070 void onSize(wxSizeEvent& event);
00072 void onEraseBackground(wxEraseEvent& event);
00074 void onMouse(wxMouseEvent& event);
00077 void onKey(wxKeyEvent &event);
00080 void onEnterWindow(wxMouseEvent &event);
00081
00083 VLighting* lighting() { return &myLights; }
00084 protected:
00088 void InitGL();
00095 void setViewProjection();
00096
00097 protected:
00099 VWorld *myModel;
00100 bool myNeedInit;
00101
00102
00103 float myDistance;
00104 float myElevation;
00105 float myAzimuth;
00106 float myTwist;
00107
00108 VLighting myLights;
00109
00110 DECLARE_EVENT_TABLE()
00111 };
00112
00113 #endif