OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." |
| 7 #endif |
| 8 |
| 9 #import "remoting/client/ios/example_view_controller.h" |
| 10 |
| 11 #import "remoting/client/opengl_wrapper.h" |
| 12 |
| 13 @interface ExampleViewController() |
| 14 |
| 15 // Helper functions dealing with the GL Context. |
| 16 - (void)setupGL; |
| 17 - (void)tearDownGL; |
| 18 |
| 19 @end |
| 20 |
| 21 @implementation ExampleViewController |
| 22 |
| 23 #pragma mark - UIViewController |
| 24 |
| 25 - (void)viewDidLoad { |
| 26 [super viewDidLoad]; |
| 27 |
| 28 _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; |
| 29 static_cast<GLKView*>(self.view).context = _context; |
| 30 |
| 31 [self setupGL]; |
| 32 } |
| 33 |
| 34 - (void)viewDidUnload { |
| 35 [super viewDidUnload]; |
| 36 [self tearDownGL]; |
| 37 |
| 38 if ([EAGLContext currentContext] == _context) { |
| 39 [EAGLContext setCurrentContext:nil]; |
| 40 } |
| 41 _context = nil; |
| 42 } |
| 43 |
| 44 - (void)setupGL { |
| 45 [EAGLContext setCurrentContext:_context]; |
| 46 } |
| 47 |
| 48 - (void)tearDownGL { |
| 49 [EAGLContext setCurrentContext:_context]; |
| 50 } |
| 51 |
| 52 - (void)viewWillAppear:(BOOL)animated { |
| 53 [super viewWillAppear:animated]; |
| 54 } |
| 55 |
| 56 - (void)viewDidAppear:(BOOL)animated { |
| 57 } |
| 58 |
| 59 - (void)viewWillDisappear:(BOOL)animated { |
| 60 [super viewWillDisappear:NO]; |
| 61 } |
| 62 |
| 63 - (void)viewDidLayoutSubviews { |
| 64 [super viewDidLayoutSubviews]; |
| 65 } |
| 66 |
| 67 #pragma mark - GLKViewDelegate |
| 68 |
| 69 // In general, avoid expensive work in this function to maximize frame rate. |
| 70 - (void)glkView:(GLKView*)view drawInRect:(CGRect)rect { |
| 71 // Clear to give the background color. |
| 72 glClearColor(0.0, 40.0, 0.0, 1.0); |
| 73 glClear(GL_COLOR_BUFFER_BIT); |
| 74 } |
| 75 |
| 76 @end |
OLD | NEW |