Skip to content

Instantly share code, notes, and snippets.

@alexargo
Last active April 14, 2016 19:11
Show Gist options
  • Save alexargo/9f9bcc9d1216ca7cb0a0c63d126dd0d8 to your computer and use it in GitHub Desktop.
Save alexargo/9f9bcc9d1216ca7cb0a0c63d126dd0d8 to your computer and use it in GitHub Desktop.
AdMob Integration
ASAppConfig *appConfig = [[ASAppConfig alloc] initWithUrl:[self configUrl]];
[DependencyInjector registerObject:appConfig withGlobalId:@"AppConfig"];
[self registerSharedConfigDefaults];
[self registerConfigDefaults];
self.appWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ASGameplayViewController *vc = [[ASGameplayViewController alloc] initWithNibName:@"ASGameplayViewController"
bundle:[ASUtils bundleWithName:@"CardGameUIResources"]];
self.viewController = vc;
//Set tint color to blue color that we use for all of our colored buttons
if ([self.appWindow respondsToSelector:@selector(setTintColor:)]) {
self.appWindow.tintColor = [ASStyleConstants tintColor];
[[UISwitch appearance] setOnTintColor:[ASStyleConstants tintColor]];
}
self.appWindow.rootViewController = self.viewController;
[self.appWindow makeKeyWindow];
- (void)viewDidLoad {
[super viewDidLoad];
CGSize screenSize = [UIScreen mainScreen].bounds.size;
GLKView *glkView = [self glkView];
glkView.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
glkView.delegate = self;
glkView.backgroundColor = [UIColor blackColor];
glkView.drawableMultisample = GLKViewDrawableMultisampleNone;
glkView.enableSetNeedsDisplay = YES;
glkView.drawableDepthFormat = GLKViewDrawableDepthFormat16;
glkView.frame = CGRectMake(0, 0, screenSize.width, screenSize.height);
if (glkView.context == nil) {
NSLog(@"Failed to create ES context");
}
[EAGLContext setCurrentContext:glkView.context];
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0, 0, 0, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// OpenGL optimization - our objects are simple enough (only 1 texture is used
// per object), so we can set this value once and not change it
glActiveTexture(GL_TEXTURE0);
[self startAnimation];
[[NSNotificationCenter defaultCenter] postNotificationName:OpenGLInitializedNotification
object:nil];
}
- (GLKView *)glkView {
return (GLKView *)self.view;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment