iOS で glBindTexture glGenTextures などテクスチャ系処理が 0x502 (GL_INVALID_OPERATION) を出す

今回は、UIView の init 系で処理をすると、

コンテキストが正しく認識されず、 OpenGL がちゃんと初期化されていない事で起こっていた。

なぜか gl****Texture 系のみで、他の設定系はエラーが出ていなかったので迷ってしまった。

これが原因で、glDraw 系は EXC_BAD_ACCESS で止まる。

結論として、layoutSubviews の中で OpenGL を初期化するようにしたら直った。

Application windows are expected to have a root view controller at the end of application launch.

StoryBoard を使用したアプリを Empty Applicaton のテンプレートから作成すると、

実行時に、

"Application windows are expected to have a root view controller at the end of application launch."

とログに表示され、画面が真っ白になる状態に陥った。


これは、テンプレートが作成した AppDelegate.m 内の、

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}


を、各種コメントアウトし、


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//self.window.backgroundColor = [UIColor whiteColor];
//[self.window makeKeyAndVisible];
return YES;
}

とする事で正しく動作するようになる。

cast of indirect pointer to an Objective-C pointer

iOS7 対応しようとビルドしてみたらこんなエラーが出たのでメモ。

[Before]
NSData *data = NULL;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)attrDictionary, (CFTypeRef*)&data);
// (CFTypeRef*) のキャストの所で cast of indirect 〜 が出てビルド通らず


[After]

CFTypeRef cfref = NULL;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)attrDictionary, &cfref);
NSData *data = (__bridge id)cfref;
// 一度定義した CFTypeRef を渡した後ブリッジキャストで解決