Пример #1
0
        public CglContext()
        {
            var attributes = new [] {
                CGLPixelFormatAttribute.kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute)CGLOpenGLProfile.kCGLOGLPVersion_3_2_Core,
                CGLPixelFormatAttribute.kCGLPFADoubleBuffer,
                CGLPixelFormatAttribute.kCGLPFANone
            };

            IntPtr pixFormat;
            int    npix;

            Cgl.CGLChoosePixelFormat(attributes, out pixFormat, out npix);

            if (pixFormat == IntPtr.Zero)
            {
                throw new Exception("CGLChoosePixelFormat failed.");
            }

            Cgl.CGLCreateContext(pixFormat, IntPtr.Zero, out fContext);
            Cgl.CGLReleasePixelFormat(pixFormat);

            if (fContext == IntPtr.Zero)
            {
                throw new Exception("CGLCreateContext failed.");
            }
        }
Пример #2
0
 public override void Destroy()
 {
     if (fContext != IntPtr.Zero)
     {
         Cgl.CGLReleaseContext(fContext);
         fContext = IntPtr.Zero;
     }
 }
Пример #3
0
        public override GRGlTextureInfo CreateTexture(SKSizeI textureSize)
        {
            var textures = new uint[1];

            Cgl.glGenTextures(textures.Length, textures);
            var textureId = textures[0];

            Cgl.glBindTexture(Cgl.GL_TEXTURE_2D, textureId);
            Cgl.glTexImage2D(Cgl.GL_TEXTURE_2D, 0, Cgl.GL_RGBA, textureSize.Width, textureSize.Height, 0, Cgl.GL_RGBA, Cgl.GL_UNSIGNED_BYTE, IntPtr.Zero);
            Cgl.glBindTexture(Cgl.GL_TEXTURE_2D, 0);

            return(new GRGlTextureInfo {
                Id = textureId,
                Target = Cgl.GL_TEXTURE_2D
            });
        }
Пример #4
0
 public override void DestroyTexture(uint texture)
 {
     Cgl.glDeleteTextures(1, new[] { texture });
 }
Пример #5
0
 public override void SwapBuffers()
 {
     Cgl.CGLFlushDrawable(fContext);
 }
Пример #6
0
 public override void MakeCurrent()
 {
     Cgl.CGLSetCurrentContext(fContext);
 }