cube.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: cube.h
  3. // Purpose: wxGLCanvas demo program
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 04/01/98
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CUBE_H_
  11. #define _WX_CUBE_H_
  12. #include "wx/glcanvas.h"
  13. // the rendering context used by all GL canvases
  14. class TestGLContext : public wxGLContext
  15. {
  16. public:
  17. TestGLContext(wxGLCanvas *canvas);
  18. // render the cube showing it at given angles
  19. void DrawRotatedCube(float xangle, float yangle);
  20. private:
  21. // textures for the cube faces
  22. GLuint m_textures[6];
  23. };
  24. // Define a new application type
  25. class MyApp : public wxApp
  26. {
  27. public:
  28. MyApp() { m_glContext = NULL; m_glStereoContext = NULL; }
  29. // Returns the shared context used by all frames and sets it as current for
  30. // the given canvas.
  31. TestGLContext& GetContext(wxGLCanvas *canvas, bool useStereo);
  32. // virtual wxApp methods
  33. virtual bool OnInit();
  34. virtual int OnExit();
  35. private:
  36. // the GL context we use for all our mono rendering windows
  37. TestGLContext *m_glContext;
  38. // the GL context we use for all our stereo rendering windows
  39. TestGLContext *m_glStereoContext;
  40. };
  41. // Define a new frame type
  42. class MyFrame : public wxFrame
  43. {
  44. public:
  45. MyFrame(bool stereoWindow = false);
  46. private:
  47. void OnClose(wxCommandEvent& event);
  48. void OnNewWindow(wxCommandEvent& event);
  49. void OnNewStereoWindow(wxCommandEvent& event);
  50. wxDECLARE_EVENT_TABLE();
  51. };
  52. class TestGLCanvas : public wxGLCanvas
  53. {
  54. public:
  55. TestGLCanvas(wxWindow *parent, int *attribList = NULL);
  56. private:
  57. void OnPaint(wxPaintEvent& event);
  58. void Spin(float xSpin, float ySpin);
  59. void OnKeyDown(wxKeyEvent& event);
  60. void OnSpinTimer(wxTimerEvent& WXUNUSED(event));
  61. // angles of rotation around x- and y- axis
  62. float m_xangle,
  63. m_yangle;
  64. wxTimer m_spinTimer;
  65. bool m_useStereo,
  66. m_stereoWarningAlreadyDisplayed;
  67. wxDECLARE_EVENT_TABLE();
  68. };
  69. enum
  70. {
  71. NEW_STEREO_WINDOW = wxID_HIGHEST + 1
  72. };
  73. #endif // _WX_CUBE_H_