1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: pyramid.h 3 // Purpose: OpenGL version >= 3.2 sample 4 // Author: Manuel Martin 5 // Created: 2015/11/05 6 // Copyright: (c) 2015 Manuel Martin 7 // Licence: wxWindows licence 8 ///////////////////////////////////////////////////////////////////////////// 9 10 #ifndef PYRSAMLE_H 11 #define PYRSAMLE_H 12 13 // Define a new application 14 class MyApp: public wxApp 15 { 16 public: MyApp()17 MyApp(){} 18 bool OnInit() wxOVERRIDE; 19 }; 20 21 22 class MyGLCanvas; 23 24 // The main frame class 25 class MyFrame : public wxFrame 26 { 27 public: 28 MyFrame(const wxString& title); 29 30 void OnAbout(wxCommandEvent& event); 31 void OnQuit(wxCommandEvent& event); 32 #if wxUSE_LOGWINDOW 33 void OnLogWindow(wxCommandEvent& event); 34 #endif // wxUSE_LOGWINDOW SetOGLString(const wxString & ogls)35 void SetOGLString(const wxString& ogls) 36 { m_OGLString = ogls; } 37 bool OGLAvailable(); 38 39 private: 40 #if wxUSE_LOGWINDOW 41 wxLogWindow* m_LogWin; 42 #endif // wxUSE_LOGWINDOW 43 wxString m_OGLString; 44 MyGLCanvas* m_mycanvas; 45 46 wxDECLARE_EVENT_TABLE(); 47 }; 48 49 50 // The canvas window 51 class MyGLCanvas : public wxGLCanvas 52 { 53 public: 54 MyGLCanvas(MyFrame* parent, const wxGLAttributes& canvasAttrs); 55 ~MyGLCanvas(); 56 57 //Used just to know if we must end now because OGL 3.2 isn't available OglCtxAvailable()58 bool OglCtxAvailable() 59 {return m_oglContext != NULL;} 60 61 //Init the OpenGL stuff 62 bool oglInit(); 63 64 void OnPaint(wxPaintEvent& event); 65 void OnSize(wxSizeEvent& event); 66 void OnMouse(wxMouseEvent& event); 67 68 private: 69 // Members 70 MyFrame* m_parent; 71 wxGLContext* m_oglContext; 72 myOGLManager* m_oglManager; 73 int m_winHeight; // We use this var to know if we have been sized 74 75 wxDECLARE_EVENT_TABLE(); 76 }; 77 78 79 // IDs for the controls and the menu commands 80 enum 81 { 82 Pyramid_Quit = wxID_EXIT, 83 Pyramid_About = wxID_ABOUT, 84 Pyramid_LogW = wxID_HIGHEST + 10 85 }; 86 87 #endif // PYRSAMLE_H 88 89