glcanvas.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/glcanvas.h
  3. // Purpose: wxGLCanvas class
  4. // Author: David Elliott
  5. // Modified by:
  6. // Created: 2004/09/29
  7. // Copyright: (c) 2004 David Elliott
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_COCOA_GLCANVAS_H__
  11. #define _WX_COCOA_GLCANVAS_H__
  12. #include "wx/window.h"
  13. // #include "wx/cocoa/NSOpenGLView.h"
  14. // Include gl.h from the OpenGL framework
  15. #include <OpenGL/gl.h>
  16. class WXDLLIMPEXP_FWD_GL wxGLCanvas;
  17. DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLContext);
  18. DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLView);
  19. // ========================================================================
  20. // wxGLContext
  21. // ========================================================================
  22. class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
  23. {
  24. public:
  25. wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
  26. virtual ~wxGLContext();
  27. virtual void SetCurrent(const wxGLCanvas& win) const;
  28. WX_NSOpenGLContext GetNSOpenGLContext() const
  29. { return m_cocoaNSOpenGLContext; }
  30. private:
  31. WX_NSOpenGLContext m_cocoaNSOpenGLContext;
  32. };
  33. // ========================================================================
  34. // wxGLCanvas
  35. // ========================================================================
  36. class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
  37. // , protected wxCocoaNSOpenGLView
  38. {
  39. DECLARE_DYNAMIC_CLASS(wxGLCanvas)
  40. // WX_DECLARE_COCOA_OWNER(NSOpenGLView,NSView,NSView)
  41. // ------------------------------------------------------------------------
  42. // initialization
  43. // ------------------------------------------------------------------------
  44. public:
  45. wxGLCanvas(wxWindow *parent,
  46. wxWindowID id = wxID_ANY,
  47. const int *attribList = NULL,
  48. const wxPoint& pos = wxDefaultPosition,
  49. const wxSize& size = wxDefaultSize,
  50. long style = 0,
  51. const wxString& name = wxGLCanvasName,
  52. const wxPalette& palette = wxNullPalette)
  53. {
  54. Create(parent, id, pos, size, style, name, attribList, palette);
  55. }
  56. bool Create(wxWindow *parent,
  57. wxWindowID id = wxID_ANY,
  58. const wxPoint& pos = wxDefaultPosition,
  59. const wxSize& size = wxDefaultSize,
  60. long style = 0,
  61. const wxString& name = wxGLCanvasName,
  62. const int *attribList = NULL,
  63. const wxPalette& palette = wxNullPalette);
  64. virtual ~wxGLCanvas();
  65. // ------------------------------------------------------------------------
  66. // Cocoa callbacks
  67. // ------------------------------------------------------------------------
  68. protected:
  69. // NSOpenGLView cannot be enabled/disabled
  70. virtual void CocoaSetEnabled(bool enable) { }
  71. // ------------------------------------------------------------------------
  72. // Implementation
  73. // ------------------------------------------------------------------------
  74. public:
  75. virtual void SwapBuffers();
  76. NSOpenGLView *GetNSOpenGLView() const
  77. { return (NSOpenGLView *)m_cocoaNSView; }
  78. };
  79. #endif //ndef _WX_COCOA_GLCANVAS_H__