Hi Everyone:
When i use below Canvas calss with osg and wxWidget2.8.8
I found my viewer can not addEventHandler(new PickHandler());
Why?
Best regards.
#ifndef _CANVAS_H
#define _CANVAS_H
#include <wx/glcanvas.h>
#include <osgViewer/CompositeViewer>
class Canvas : public wxGLCanvas
{
public:
Canvas(osgViewer::CompositeViewer* viewer, wxWindow* parent, wxWindowID id =
wxID_ANY,
int* attribList = 0, const wxPoint& pos = wxDefaultPosition, const wxSize&
size = wxDefaultSize,
long style=0, const wxString& name=L"GLCanvas", const wxPalette& palette =
wxNullPalette);
~Canvas();
class View : public osgViewer::View
{
public:
View();
void requestRedraw();
void requestContinuousUpdate(bool needed=true);
void requestWarpPointer(float x,float y);
private:
void setCanvas(Canvas* _canvas);
friend class Canvas;
Canvas* _canvas;
};
void setView(View* view);
void updateWhenIdle(bool update);
void setUpdateWhenIdleOverride(bool status);
void OnPaint(wxPaintEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void OnIdle(wxIdleEvent& event);
void OnSize(wxSizeEvent& event);
void OnMouse(wxMouseEvent &event);
void OnMouseCaptureLost(wxMouseCaptureLostEvent& event);
void OnKey(wxKeyEvent& event);
void OnShow(wxShowEvent& event);
private:
osg::ref_ptr<osgViewer::CompositeViewer> _viewer;
osg::ref_ptr<View> _view;
class GraphicsContext : public osgViewer::GraphicsWindow
{
protected:
virtual ~GraphicsContext();
public:
GraphicsContext(Canvas* canvas);
void detachFromCanvas();
bool valid() const;
bool realizeImplementation();
bool isRealizedImplementation() const;
void closeImplementation();
bool makeCurrentImplementation();
bool makeContextCurrentImplementation(osg::GraphicsContext *context);
bool releaseContextImplementation();
void bindPBufferToTextureImplementation(GLenum buffer);
void swapBuffersImplementation();
wxGLContext* getWxContext();
unsigned int getGlContext();
private:
wxGLContext* _wxContext;
Canvas* _canvas;
static unsigned int _s_glContexts;
unsigned int _glContext;
};
osg::ref_ptr<GraphicsContext> _context;
bool _renderingActive;
int _mouseButtonCaptured;
bool _updateWhenIdle;
bool _updateWhenIdleOverride;
DECLARE_EVENT_TABLE();
};
#endif //_CANVAS_H
---------------------------------
雅虎邮箱,您的终生邮箱!
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org