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