github.com/cybriq/giocore@v0.0.7-0.20210703034601-cfb9cb5f3900/app/internal/wm/gl_ios.m (about)

     1  // SPDX-License-Identifier: Unlicense OR MIT
     2  
     3  // +build darwin,ios
     4  
     5  @import UIKit;
     6  @import OpenGLES;
     7  
     8  #include "_cgo_export.h"
     9  
    10  int gio_renderbufferStorage(CFTypeRef ctxRef, CFTypeRef layerRef, GLenum buffer) {
    11  	EAGLContext *ctx = (__bridge EAGLContext *)ctxRef;
    12  	CAEAGLLayer *layer = (__bridge CAEAGLLayer *)layerRef;
    13  	return (int)[ctx renderbufferStorage:buffer fromDrawable:layer];
    14  }
    15  
    16  int gio_presentRenderbuffer(CFTypeRef ctxRef, GLenum buffer) {
    17  	EAGLContext *ctx = (__bridge EAGLContext *)ctxRef;
    18  	return (int)[ctx presentRenderbuffer:buffer];
    19  }
    20  
    21  int gio_makeCurrent(CFTypeRef ctxRef) {
    22  	EAGLContext *ctx = (__bridge EAGLContext *)ctxRef;
    23  	return (int)[EAGLContext setCurrentContext:ctx];
    24  }
    25  
    26  CFTypeRef gio_createContext(void) {
    27  	EAGLContext *ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
    28  	if (ctx == nil) {
    29  		return nil;
    30  	}
    31  	return CFBridgingRetain(ctx);
    32  }
    33  
    34  CFTypeRef gio_createGLLayer(void) {
    35  	CAEAGLLayer *layer = [[CAEAGLLayer layer] init];
    36  	if (layer == nil) {
    37  		return nil;
    38  	}
    39  	layer.drawableProperties = @{kEAGLDrawablePropertyColorFormat: kEAGLColorFormatSRGBA8};
    40  	layer.opaque = YES;
    41  	layer.anchorPoint = CGPointMake(0, 0);
    42  	return CFBridgingRetain(layer);
    43  }