]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/glcanvas.mm
compilation fix for old SDKs (VC6...) which don't define HDM_SETBITMAPMARGIN/Header_S...
[wxWidgets.git] / src / osx / cocoa / glcanvas.mm
index fa9a2e5f0400034d8676daa6efd3520664d35b59..e088ede061fa7e95f27632a927dfcf52364b93d6 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "wx/osx/private.h"
 
 
 #include "wx/osx/private.h"
 
-
 WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext )
 {
     WXGLContext context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: shareContext];
 WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext )
 {
     WXGLContext context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: shareContext];
@@ -78,9 +77,9 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
     {
         NSOpenGLPFADoubleBuffer,
         NSOpenGLPFAMinimumPolicy,
     {
         NSOpenGLPFADoubleBuffer,
         NSOpenGLPFAMinimumPolicy,
-        NSOpenGLPFAColorSize,8,
-        NSOpenGLPFAAlphaSize,0,
-        NSOpenGLPFADepthSize,8,
+        NSOpenGLPFAColorSize,(NSOpenGLPixelFormatAttribute)8,
+        NSOpenGLPFAAlphaSize,(NSOpenGLPixelFormatAttribute)0,
+        NSOpenGLPFADepthSize,(NSOpenGLPixelFormatAttribute)8,
         (NSOpenGLPixelFormatAttribute)nil
     };
 
         (NSOpenGLPixelFormatAttribute)nil
     };
 
@@ -122,12 +121,12 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
 
                 case WX_GL_AUX_BUFFERS:
                     data[p++] = NSOpenGLPFAAuxBuffers;
 
                 case WX_GL_AUX_BUFFERS:
                     data[p++] = NSOpenGLPFAAuxBuffers;
-                    data[p++] = attribList[arg++];
+                    data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++];
                     break;
 
                 case WX_GL_MIN_RED:
                     data[p++] = NSOpenGLPFAColorSize;
                     break;
 
                 case WX_GL_MIN_RED:
                     data[p++] = NSOpenGLPFAColorSize;
-                    data[p++] = attribList[arg++];
+                    data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++];
                     break;
 
                 case WX_GL_MIN_GREEN:
                     break;
 
                 case WX_GL_MIN_GREEN:
@@ -142,22 +141,22 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
 
                 case WX_GL_MIN_ALPHA:
                     data[p++] = NSOpenGLPFAAlphaSize;
 
                 case WX_GL_MIN_ALPHA:
                     data[p++] = NSOpenGLPFAAlphaSize;
-                    data[p++] = attribList[arg++];
+                    data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++];
                     break;
 
                 case WX_GL_DEPTH_SIZE:
                     data[p++] = NSOpenGLPFADepthSize;
                     break;
 
                 case WX_GL_DEPTH_SIZE:
                     data[p++] = NSOpenGLPFADepthSize;
-                    data[p++] = attribList[arg++];
+                    data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++];
                     break;
 
                 case WX_GL_STENCIL_SIZE:
                     data[p++] = NSOpenGLPFAStencilSize;
                     break;
 
                 case WX_GL_STENCIL_SIZE:
                     data[p++] = NSOpenGLPFAStencilSize;
-                    data[p++] = attribList[arg++];
+                    data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++];
                     break;
 
                 case WX_GL_MIN_ACCUM_RED:
                     data[p++] = NSOpenGLPFAAccumSize;
                     break;
 
                 case WX_GL_MIN_ACCUM_RED:
                     data[p++] = NSOpenGLPFAAccumSize;
-                    data[p++] = attribList[arg++];
+                    data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++];
                     break;
 
                 case WX_GL_MIN_ACCUM_GREEN:
                     break;
 
                 case WX_GL_MIN_ACCUM_GREEN:
@@ -185,7 +184,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
                     }
 
                     data[p++] = NSOpenGLPFASampleBuffers;
                     }
 
                     data[p++] = NSOpenGLPFASampleBuffers;
-                    if ( (data[p++] = attribList[arg++]) == true )
+                    if ( (data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++]) == true )
                     {
                         // don't use software fallback
                         data[p++] = NSOpenGLPFANoRecovery;
                     {
                         // don't use software fallback
                         data[p++] = NSOpenGLPFANoRecovery;
@@ -202,7 +201,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
                     }
 
                     data[p++] = NSOpenGLPFASamples;
                     }
 
                     data[p++] = NSOpenGLPFASamples;
-                    data[p++] = attribList[arg++];
+                    data[p++] = (NSOpenGLPixelFormatAttribute) attribList[arg++];
                     break;
             }
         }
                     break;
             }
         }
@@ -212,7 +211,7 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
         attribs = data;
     }
 
         attribs = data;
     }
 
-    return [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
+    return [[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*) attribs];
 }
 
 bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
 }
 
 bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
@@ -230,14 +229,13 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
 
 @interface wxNSCustomOpenGLView : NSView
 {
 
 @interface wxNSCustomOpenGLView : NSView
 {
-    wxWidgetImpl* impl;
+    WXCOCOAIMPL_COMMON_MEMBERS
     NSOpenGLContext* context;
 }
 
 - (id)initWithFrame:(NSRect)frame;
     NSOpenGLContext* context;
 }
 
 - (id)initWithFrame:(NSRect)frame;
-- (void)setImplementation: (wxWidgetImpl *) theImplementation;
-- (wxWidgetImpl*) implementation;
-- (BOOL) isFlipped;
+
+WXCOCOAIMPL_COMMON_INTERFACE
 
 @end
 
 
 @end
 
@@ -250,20 +248,7 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
     return self;
 }
 
     return self;
 }
 
-- (void)setImplementation: (wxWidgetImpl *) theImplementation
-{
-    impl = theImplementation;
-}
-
-- (wxWidgetImpl*) implementation
-{
-    return impl;
-}
-
-- (BOOL) isFlipped
-{
-    return YES;
-}
+WXCOCOAIMPL_COMMON_IMPLEMENTATION
 
 - (BOOL)isOpaque
 {
 
 - (BOOL)isOpaque
 {
@@ -291,11 +276,8 @@ bool wxGLCanvas::Create(wxWindow *parent,
         return false;
 
 /*
         return false;
 
 /*
-    NSView* sv = (parent->GetHandle() );
-    
     NSRect r = wxOSXGetFrameForControl( this, pos , size ) ;
     wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r];
     NSRect r = wxOSXGetFrameForControl( this, pos , size ) ;
     wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r];
-    [sv addSubview:v];
     m_peer = new wxWidgetCocoaImpl( this, v );
     [v setImplementation:m_peer];
 
     m_peer = new wxWidgetCocoaImpl( this, v );
     [v setImplementation:m_peer];
 
@@ -304,39 +286,6 @@ bool wxGLCanvas::Create(wxWindow *parent,
     return true;
 }
 
     return true;
 }
 
-bool wxGLCanvas::Create(wxWindow *parent,
-                        wxWindowID id,
-                        const wxPoint& pos,
-                        const wxSize& size,
-                        long style,
-                        const wxString& name,
-                        const int *attribList,
-                        const wxPalette& WXUNUSED(palette))
-{
-    m_needsUpdate = false;
-    m_macCanvasIsShown = false;
-
-    m_glFormat = WXGLChoosePixelFormat(attribList);
-    if ( !m_glFormat )
-        return false;
-
-    if ( !wxWindow::Create(parent, id, pos, size, style, name) )
-        return false;
-
-    m_dummyContext = WXGLCreateContext(m_glFormat, NULL);
-
-    static GLint gCurrentBufferName = 1;
-    m_bufferName = gCurrentBufferName++;
-    aglSetInteger (m_dummyContext, AGL_BUFFER_NAME, &m_bufferName); 
-    
-    AGLDrawable drawable = (AGLDrawable)GetWindowPort(MAC_WXHWND(MacGetTopLevelWindowRef()));
-    aglSetDrawable(m_dummyContext, drawable);
-
-    m_macCanvasIsShown = true;
-
-    return true;
-}
-
 wxGLCanvas::~wxGLCanvas()
 {
     if ( m_glFormat )
 wxGLCanvas::~wxGLCanvas()
 {
     if ( m_glFormat )