📜 ⬆️ ⬇️

Transparent OpenGL

image

Bon Jorno, lords!
I re-released the ancient game Dice 5 , which actually began life in the unusual world of iOS development.
I want to share a useful for many mode of imposing three-dimensional objects on the standard beautiful controls and fonts iOS.

As a dessert, I will talk about the approval process for the game in the apple store and peeping at the Apple Review Team. Suddenly someone come in handy?
The article will have a lot of foreign words , because I just rushing to use them after the ban from our DG.
')


Code example


You need to create a transparent layer of three-dimensional graphics and superimpose it on the classic UIView.
In the UIViewControllere of your choice, insert the code in the viewDidLoad function body

#import "PlayViewController.h" @interface PlayViewController () { GLKView *glkView; EAGLContext *context; } - (void)viewDidLoad { [super viewDidLoad]; //     //   ,    OpenGL ES1   ES2 context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; if (!context) { NSLog(@"Unable to create OpenGL context"); exit(1); } [EAGLContext setCurrentContext:context]; glkView = [[GLKView alloc] initWithFrame:self.view.frame ]; glkView.context = context; //       // CAEAGLLayer *v = (CAEAGLLayer *)glkView.layer; v.opaque = NO; v.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; //    UIView  glkView // [self.view addSubview:glkView]; //  ,     // glkView.userInteractionEnabled = NO; } 


After that, in the cycle, you draw your three-dimensional things, and they roll over the buttons and labels. Each time before displaying objects, do not forget to clear the screen.

  glViewport(0, 0, Width, Height); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //       ,      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 


Simple, but important is the procedure.

Everything works according to the documentation of iOS and OpenGL ES until you start using internal buffer for anti-aliasing .
Transparent shadows will become an unnecessary color, which is a mistake. Perhaps in iOS 8 this will be fixed.

Publication


As the Bolsheviks said, summer is the off season for games. Apple employees approved the program in 2 days. Judge for yourself, on Thursday I posted an application to check, okey came on Saturday. At the same time, the Apple Review Team honestly launched the game on its five devices on Friday evening. If they check us, why don't we check them?

Here is a list of Apple devices
image

Look closely, Review Team has launched the Dice 5 application on two iPads, iPad Mini, iPhone 4S and iPhone 5S.
Judging by the launch time, at Apple this happens automatically, and in the morning, employees are notified of new applications for inspection.

Here is a table of champions for today - only 2 of them are among them.
image

Thank you and have a great weekend.

Source: https://habr.com/ru/post/228861/


All Articles