@COND_TOOLKIT_WINCE@BASE_WINCE_HDR = wx/msw/wince/time.h
@COND_TOOLKIT_WINCE@NET_WINCE_SRC = src/msw/wince/net.cpp
@COND_TOOLKIT_WINCE@NET_WINCE_HDR = wx/msw/wince/net.h
+@COND_TOOLKIT_COCOA@OPENGL_HDR = wx/cocoa/glcanvas.h
@COND_TOOLKIT_GTK@OPENGL_HDR = wx/gtk/glcanvas.h
@COND_TOOLKIT_MAC@OPENGL_HDR = wx/mac/carbon/glcanvas.h
@COND_TOOLKIT_MOTIF@OPENGL_HDR = wx/x11/glcanvas.h
$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf2) \
$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX)
@COND_USE_SOSYMLINKS_1@__gldll___so_symlinks_inst_cmd = $(COND_USE_SOSYMLINKS_1___gldll___so_symlinks_inst_cmd)
+@COND_TOOLKIT_COCOA@__OPENGL_SRC_OBJECTS = gldll_glcanvas.o
@COND_TOOLKIT_GTK@__OPENGL_SRC_OBJECTS = gldll_glcanvas.o
@COND_TOOLKIT_MAC@__OPENGL_SRC_OBJECTS = gldll_glcanvas.o
@COND_TOOLKIT_MOTIF@__OPENGL_SRC_OBJECTS = gldll_glcanvas.o
@COND_GCC_PCH_1@__gllib_PCH_INC = -I.pch/wxprec_gllib
@COND_GCC_PCH_1@___pch_wxprec_gllib_wx_wxprec_h_gch___depname \
@COND_GCC_PCH_1@ = .pch/wxprec_gllib/wx/wxprec.h.gch
+@COND_TOOLKIT_COCOA@__OPENGL_SRC_OBJECTS_1 = gllib_glcanvas.o
@COND_TOOLKIT_GTK@__OPENGL_SRC_OBJECTS_1 = gllib_glcanvas.o
@COND_TOOLKIT_MAC@__OPENGL_SRC_OBJECTS_1 = gllib_glcanvas.o
@COND_TOOLKIT_MOTIF@__OPENGL_SRC_OBJECTS_1 = gllib_glcanvas.o
@COND_TOOLKIT_MAC@gldll_glcanvas.o: $(srcdir)/src/mac/carbon/glcanvas.cpp $(GLDLL_ODEP)
@COND_TOOLKIT_MAC@ $(CXXC) -c -o $@ $(GLDLL_CXXFLAGS) $<
+@COND_TOOLKIT_COCOA@gldll_glcanvas.o: $(srcdir)/src/cocoa/glcanvas.mm $(GLDLL_ODEP)
+@COND_TOOLKIT_COCOA@ $(CXXC) -c -o $@ $(GLDLL_CXXFLAGS) $<
+
@COND_TOOLKIT_GTK@gldll_glcanvas.o: $(srcdir)/src/gtk/glcanvas.cpp $(GLDLL_ODEP)
@COND_TOOLKIT_GTK@ $(CXXC) -c -o $@ $(GLDLL_CXXFLAGS) $<
@COND_TOOLKIT_MAC@gllib_glcanvas.o: $(srcdir)/src/mac/carbon/glcanvas.cpp $(GLLIB_ODEP)
@COND_TOOLKIT_MAC@ $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $<
+@COND_TOOLKIT_COCOA@gllib_glcanvas.o: $(srcdir)/src/cocoa/glcanvas.mm $(GLLIB_ODEP)
+@COND_TOOLKIT_COCOA@ $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $<
+
@COND_TOOLKIT_GTK@gllib_glcanvas.o: $(srcdir)/src/gtk/glcanvas.cpp $(GLLIB_ODEP)
@COND_TOOLKIT_GTK@ $(CXXC) -c -o $@ $(GLLIB_CXXFLAGS) $<
<set var="OPENGL_SRC" hints="files">
<if cond="TOOLKIT=='MAC'">src/mac/carbon/glcanvas.cpp</if>
+ <if cond="TOOLKIT=='COCOA'">src/cocoa/glcanvas.mm</if>
<if cond="TOOLKIT=='GTK'">src/gtk/glcanvas.cpp</if>
<if cond="TOOLKIT=='MSW'">src/msw/glcanvas.cpp</if>
<if cond="TOOLKIT=='WINCE'">src/msw/glcanvas.cpp</if>
<set var="OPENGL_HDR" hints="files">
<if cond="TOOLKIT=='MAC'">wx/mac/carbon/glcanvas.h</if>
+ <if cond="TOOLKIT=='COCOA'">wx/cocoa/glcanvas.h</if>
<if cond="TOOLKIT=='GTK'">wx/gtk/glcanvas.h</if>
<if cond="TOOLKIT=='MSW'">wx/msw/glcanvas.h</if>
<if cond="TOOLKIT=='WINCE'">wx/msw/glcanvas.h</if>
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: wx/cocoa/glcanvas.h
+// Purpose: wxGLCanvas class
+// Author: David Elliott
+// Modified by:
+// Created: 2004/09/29
+// RCS-ID: $Id$
+// Copyright: (c) 2004 David Elliott
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_COCOA_GLCANVAS_H__
+#define _WX_COCOA_GLCANVAS_H__
+
+// #include "wx/cocoa/NSOpenGLView.h"
+// Include gl.h from the OpenGL framework
+#include <OpenGL/gl.h>
+
+class WXDLLIMPEXP_GL wxGLCanvas;
+DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLContext);
+//DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLView);
+
+// ========================================================================
+// wxGLContext
+// ========================================================================
+class WXDLLIMPEXP_GL wxGLContext: public wxObject
+{
+public:
+ wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette = wxNullPalette);
+
+ wxGLContext( bool isRGB, wxGLCanvas *win,
+ const wxPalette& WXUNUSED(palette),
+ const wxGLContext *other /* for sharing display lists */ );
+
+ ~wxGLContext();
+
+
+ void SetCurrent();
+
+ void SetColour(const wxChar *colour);
+
+ void SwapBuffers();
+
+
+ inline wxWindow* GetWindow() const
+ { return m_window; }
+
+ inline WX_NSOpenGLContext GetNSOpenGLContext() const
+ { return m_cocoaNSOpenGLContext; }
+
+public:
+ WX_NSOpenGLContext m_cocoaNSOpenGLContext;
+ wxWindow* m_window;
+};
+
+
+
+// ========================================================================
+// wxGLCanvas
+// ========================================================================
+class WXDLLIMPEXP_GL wxGLCanvas: public wxWindow// , protected wxCocoaNSOpenGLView
+{
+ DECLARE_DYNAMIC_CLASS(wxGLCanvas)
+ DECLARE_EVENT_TABLE()
+// WX_DECLARE_COCOA_OWNER(NSOpenGLView,NSView,NSView)
+// ------------------------------------------------------------------------
+// initialization
+// ------------------------------------------------------------------------
+public:
+ wxGLCanvas()
+ : m_glContext(NULL)
+ { }
+ wxGLCanvas(wxWindow *parent, wxWindowID winid = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0, const wxString& name = wxGLCanvasName,
+ int *attribList = NULL, const wxPalette& palette = wxNullPalette);
+
+ wxGLCanvas(wxWindow *parent,
+ const wxGLContext *shared = NULL,
+ wxWindowID winid = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0, const wxString& name = wxGLCanvasName,
+ int *attribList = NULL, const wxPalette& palette = wxNullPalette);
+
+ wxGLCanvas(wxWindow *parent,
+ const wxGLCanvas *shared = NULL,
+ wxWindowID winid = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0, const wxString& name = wxGLCanvasName,
+ int *attribList = NULL, const wxPalette& palette = wxNullPalette);
+
+ bool Create(wxWindow *parent, wxWindowID winid,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0, const wxString& name = wxGLCanvasName);
+ virtual ~wxGLCanvas();
+
+// ------------------------------------------------------------------------
+// Cocoa callbacks
+// ------------------------------------------------------------------------
+protected:
+ // NSOpenGLView cannot be enabled/disabled
+ virtual void CocoaSetEnabled(bool enable) { }
+// ------------------------------------------------------------------------
+// Implementation
+// ------------------------------------------------------------------------
+public:
+ void SetCurrent();
+ void SwapBuffers();
+
+ void OnSize(wxSizeEvent& event)
+ {}
+ inline wxGLContext* GetContext() const
+ { return m_glContext; }
+protected:
+ wxGLContext *m_glContext;
+ wxPalette m_palette;
+};
+
+#endif //ndef _WX_COCOA_GLCANVAS_H__
#include "wx/x11/glcanvas.h"
#elif defined(__WXMAC__)
#include "wx/mac/glcanvas.h"
+#elif defined(__WXCOCOA__)
+#include "wx/cocoa/glcanvas.h"
#elif defined(__WXPM__)
#include "wx/os2/glcanvas.h"
#endif
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: cocoa/glcanvas.mm
+// Purpose: wxGLContext, wxGLCanvas
+// Author: David Elliott
+// Modified by:
+// Created: 2004/09/29
+// RCS-ID: $Id$
+// Copyright: (c) 2004 David Elliott
+// Licence: wxWidgets licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "wx/wxprec.h"
+
+#if wxUSE_GLCANVAS
+
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+#endif //WX_PRECOMP
+#include "wx/glcanvas.h"
+
+#include "wx/cocoa/autorelease.h"
+
+#import <AppKit/NSOpenGL.h>
+#import <AppKit/NSOpenGLView.h>
+
+IMPLEMENT_DYNAMIC_CLASS(wxGLCanvas, wxWindow)
+BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow)
+END_EVENT_TABLE()
+// WX_IMPLEMENT_COCOA_OWNER(wxGLCanvas,NSOpenGLView,NSView,NSView)
+
+wxGLCanvas::wxGLCanvas(wxWindow *parent,
+ const wxGLContext *shared,
+ wxWindowID winid, const wxPoint& pos, const wxSize& size,
+ long style, const wxString& name,
+ int *attribList, const wxPalette& palette)
+{
+ Create(parent,winid,pos,size,style,name);
+}
+
+wxGLCanvas::wxGLCanvas(wxWindow *parent,
+ const wxGLCanvas *shared,
+ wxWindowID winid, const wxPoint& pos, const wxSize& size,
+ long style, const wxString& name,
+ int *attribList, const wxPalette& palette)
+{
+ Create(parent,winid,pos,size,style,name);
+}
+
+bool wxGLCanvas::Create(wxWindow *parent, wxWindowID winid,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ wxAutoNSAutoreleasePool pool;
+ if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
+ return false;
+ SetNSView([[NSOpenGLView alloc] initWithFrame: MakeDefaultNSRect(size)
+ pixelFormat:[NSOpenGLView defaultPixelFormat]]);
+ [m_cocoaNSView release];
+ if(m_parent)
+ m_parent->CocoaAddChild(this);
+ SetInitialFrameRect(pos,size);
+
+ return true;
+}
+
+wxGLCanvas::~wxGLCanvas()
+{
+}
+
+void wxGLCanvas::SetCurrent()
+{
+ [[(NSOpenGLView*)m_cocoaNSView openGLContext] makeCurrentContext];
+}
+
+void wxGLCanvas::SwapBuffers()
+{
+ [[(NSOpenGLView*)m_cocoaNSView openGLContext] flushBuffer];
+}
+
+#endif // wxUSE_GLCANVAS