glcanvas.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/glcanvas.h
  3. // Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 1998-01-01
  7. // Copyright: (c) Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GLCANVAS_H_
  11. #define _WX_GLCANVAS_H_
  12. #ifdef __WXOSX_IPHONE__
  13. #import <OpenGLES/ES1/gl.h>
  14. #import <OpenGLES/ES1/glext.h>
  15. #define wxUSE_OPENGL_EMULATION 1
  16. #else
  17. #include <OpenGL/gl.h>
  18. #endif
  19. #include "wx/vector.h"
  20. // low level calls
  21. WXDLLIMPEXP_GL WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext );
  22. WXDLLIMPEXP_GL void WXGLDestroyContext( WXGLContext context );
  23. WXDLLIMPEXP_GL WXGLContext WXGLGetCurrentContext();
  24. WXDLLIMPEXP_GL bool WXGLSetCurrentContext(WXGLContext context);
  25. WXDLLIMPEXP_GL WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList);
  26. WXDLLIMPEXP_GL void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat );
  27. class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
  28. {
  29. public:
  30. wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
  31. virtual ~wxGLContext();
  32. virtual bool SetCurrent(const wxGLCanvas& win) const;
  33. // Mac-specific
  34. WXGLContext GetWXGLContext() const { return m_glContext; }
  35. private:
  36. WXGLContext m_glContext;
  37. wxDECLARE_NO_COPY_CLASS(wxGLContext);
  38. };
  39. class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
  40. {
  41. public:
  42. wxGLCanvas(wxWindow *parent,
  43. wxWindowID id = wxID_ANY,
  44. const int *attribList = NULL,
  45. const wxPoint& pos = wxDefaultPosition,
  46. const wxSize& size = wxDefaultSize,
  47. long style = 0,
  48. const wxString& name = wxGLCanvasName,
  49. const wxPalette& palette = wxNullPalette);
  50. bool Create(wxWindow *parent,
  51. wxWindowID id = wxID_ANY,
  52. const wxPoint& pos = wxDefaultPosition,
  53. const wxSize& size = wxDefaultSize,
  54. long style = 0,
  55. const wxString& name = wxGLCanvasName,
  56. const int *attribList = NULL,
  57. const wxPalette& palette = wxNullPalette);
  58. virtual ~wxGLCanvas();
  59. // implement wxGLCanvasBase methods
  60. virtual bool SwapBuffers();
  61. // Mac-specific functions
  62. // ----------------------
  63. // return true if multisample extension is supported
  64. static bool IsAGLMultiSampleAvailable();
  65. // return the pixel format used by this window
  66. WXGLPixelFormat GetWXGLPixelFormat() const { return m_glFormat; }
  67. // update the view port of the current context to match this window
  68. void SetViewport();
  69. // deprecated methods
  70. // ------------------
  71. #if WXWIN_COMPATIBILITY_2_8
  72. wxDEPRECATED(
  73. wxGLCanvas(wxWindow *parent,
  74. wxWindowID id = wxID_ANY,
  75. const wxPoint& pos = wxDefaultPosition,
  76. const wxSize& size = wxDefaultSize,
  77. long style = 0,
  78. const wxString& name = wxGLCanvasName,
  79. const int *attribList = NULL,
  80. const wxPalette& palette = wxNullPalette)
  81. );
  82. wxDEPRECATED(
  83. wxGLCanvas(wxWindow *parent,
  84. const wxGLContext *shared,
  85. wxWindowID id = wxID_ANY,
  86. const wxPoint& pos = wxDefaultPosition,
  87. const wxSize& size = wxDefaultSize,
  88. long style = 0,
  89. const wxString& name = wxGLCanvasName,
  90. const int *attribList = NULL,
  91. const wxPalette& palette = wxNullPalette)
  92. );
  93. wxDEPRECATED(
  94. wxGLCanvas(wxWindow *parent,
  95. const wxGLCanvas *shared,
  96. wxWindowID id = wxID_ANY,
  97. const wxPoint& pos = wxDefaultPosition,
  98. const wxSize& size = wxDefaultSize,
  99. long style = 0,
  100. const wxString& name = wxGLCanvasName,
  101. const int *attribList = NULL,
  102. const wxPalette& palette = wxNullPalette)
  103. );
  104. #endif // WXWIN_COMPATIBILITY_2_8
  105. // implementation-only from now on
  106. #if wxOSX_USE_CARBON
  107. // Unlike some other platforms, this must get called if you override it,
  108. // i.e. don't forget "event.Skip()" in your EVT_SIZE handler
  109. void OnSize(wxSizeEvent& event);
  110. virtual void MacSuperChangedPosition();
  111. virtual void MacTopLevelWindowChangedPosition();
  112. virtual void MacVisibilityChanged();
  113. void MacUpdateView();
  114. GLint GetAglBufferName() const { return m_bufferName; }
  115. #endif
  116. protected:
  117. WXGLPixelFormat m_glFormat;
  118. #if wxOSX_USE_CARBON
  119. bool m_macCanvasIsShown,
  120. m_needsUpdate;
  121. WXGLContext m_dummyContext;
  122. GLint m_bufferName;
  123. #endif
  124. DECLARE_EVENT_TABLE()
  125. DECLARE_CLASS(wxGLCanvas)
  126. };
  127. #endif // _WX_GLCANVAS_H_