]> git.saurik.com Git - wxWidgets.git/blob - samples/opengl/penguin/penguin.h
forwarding mouse moved events to the view under the mouse, not the firstResponder
[wxWidgets.git] / samples / opengl / penguin / penguin.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: penguin.h
3 // Purpose: wxGLCanvas demo program
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PENGUIN_H_
13 #define _WX_PENGUIN_H_
14
15
16 #include "wx/defs.h"
17 #include "wx/app.h"
18 #include "wx/menu.h"
19 #include "wx/dcclient.h"
20 #include "wx/wfstream.h"
21 #if wxUSE_ZLIB
22 #include "wx/zstream.h"
23 #endif
24
25 #include "wx/glcanvas.h"
26
27 extern "C"
28 {
29 #include "trackball.h"
30 }
31
32 #include "dxfrenderer.h"
33
34
35 // OpenGL view data
36 struct GLData
37 {
38 bool initialized; // have OpenGL been initialized?
39 float beginx, beginy; // position of mouse
40 float quat[4]; // orientation of object
41 float zoom; // field of view in degrees
42 };
43
44
45 // Define a new application type
46 class MyApp : public wxApp
47 {
48 public:
49 virtual bool OnInit();
50 };
51
52
53 // Define a new frame type
54 class TestGLCanvas;
55
56
57 class MyFrame : public wxFrame
58 {
59 public:
60 MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
61 const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
62
63 void OnMenuFileOpen(wxCommandEvent& event);
64 void OnMenuFileExit(wxCommandEvent& event);
65 void OnMenuHelpAbout(wxCommandEvent& event);
66
67 void SetCanvas(TestGLCanvas *canvas) { m_canvas = canvas; }
68 TestGLCanvas *GetCanvas() { return m_canvas; }
69
70 private:
71 TestGLCanvas *m_canvas;
72
73 DECLARE_EVENT_TABLE()
74 };
75
76
77 class TestGLCanvas : public wxGLCanvas
78 {
79 public:
80 TestGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& size = wxDefaultSize, long style = 0,
83 const wxString& name = wxT("TestGLCanvas"));
84
85 virtual ~TestGLCanvas();
86
87 void LoadDXF(const wxString& filename);
88
89 protected:
90 void OnPaint(wxPaintEvent& event);
91 void OnSize(wxSizeEvent& event);
92 void OnEraseBackground(wxEraseEvent& event);
93 void OnMouse(wxMouseEvent& event);
94
95 private:
96 void InitGL();
97 void ResetProjectionMode();
98
99 wxGLContext* m_glRC;
100 GLData m_gldata;
101 DXFRenderer m_renderer;
102
103 wxDECLARE_NO_COPY_CLASS(TestGLCanvas);
104 DECLARE_EVENT_TABLE()
105 };
106
107 #endif // #ifndef _WX_PENGUIN_H_