penguin.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #ifndef _WX_PENGUIN_H_
  11. #define _WX_PENGUIN_H_
  12. #include "wx/defs.h"
  13. #include "wx/app.h"
  14. #include "wx/menu.h"
  15. #include "wx/dcclient.h"
  16. #include "wx/wfstream.h"
  17. #if wxUSE_ZLIB
  18. #include "wx/zstream.h"
  19. #endif
  20. #include "wx/glcanvas.h"
  21. extern "C"
  22. {
  23. #include "trackball.h"
  24. }
  25. #include "dxfrenderer.h"
  26. // OpenGL view data
  27. struct GLData
  28. {
  29. bool initialized; // have OpenGL been initialized?
  30. float beginx, beginy; // position of mouse
  31. float quat[4]; // orientation of object
  32. float zoom; // field of view in degrees
  33. };
  34. // Define a new application type
  35. class MyApp : public wxApp
  36. {
  37. public:
  38. virtual bool OnInit();
  39. };
  40. // Define a new frame type
  41. class TestGLCanvas;
  42. class MyFrame : public wxFrame
  43. {
  44. public:
  45. MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
  46. const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
  47. void OnMenuFileOpen(wxCommandEvent& event);
  48. void OnMenuFileExit(wxCommandEvent& event);
  49. void OnMenuHelpAbout(wxCommandEvent& event);
  50. void SetCanvas(TestGLCanvas *canvas) { m_canvas = canvas; }
  51. TestGLCanvas *GetCanvas() { return m_canvas; }
  52. private:
  53. TestGLCanvas *m_canvas;
  54. wxDECLARE_EVENT_TABLE();
  55. };
  56. class TestGLCanvas : public wxGLCanvas
  57. {
  58. public:
  59. TestGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
  60. const wxPoint& pos = wxDefaultPosition,
  61. const wxSize& size = wxDefaultSize, long style = 0,
  62. const wxString& name = wxT("TestGLCanvas"));
  63. virtual ~TestGLCanvas();
  64. void LoadDXF(const wxString& filename);
  65. protected:
  66. void OnPaint(wxPaintEvent& event);
  67. void OnSize(wxSizeEvent& event);
  68. void OnEraseBackground(wxEraseEvent& event);
  69. void OnMouse(wxMouseEvent& event);
  70. private:
  71. void InitGL();
  72. void ResetProjectionMode();
  73. wxGLContext* m_glRC;
  74. GLData m_gldata;
  75. DXFRenderer m_renderer;
  76. wxDECLARE_NO_COPY_CLASS(TestGLCanvas);
  77. wxDECLARE_EVENT_TABLE();
  78. };
  79. #endif // #ifndef _WX_PENGUIN_H_