本文僅是學習中遇到問題的整理,可能說得非常不詳細,如果有問題,請指正。
XCode5中創建OpenGL ES 2.0的例子時,按照下面的方法。出現無法顯示黑屏的現象。
http://www.cnblogs.com/creolophus/archive/2013/05/21/3090139.html
使用XCode4的windows-base模板創建新工程時,可以正常顯示。
XCode4 windows-base template
http://forums.bignerdranch.com/viewtopic.php?f=73&t=3336
原因找到了,
XCode5的時候,Storyboard生成的View在OpenGL View的上面,將其覆蓋。如果試着晚一點生成OpenGL View則不會出現這個問題。
XCode5時,可以使用Empty Application模板,這樣創建時,需要在 AppDelegate的application didFinishLaunchingWithOption中先生成self.window
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
// At top of application:didFinishLaunchingWithOptions
CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.glView = [[OpenGLView alloc] initWithFrame:screenBounds];
[self.window addSubview:_glView];
[self.window makeKeyAndVisible];
return YES;
}
一篇很好的例子: 第2部分講解的是Texture,還沒有閱讀。
http://www.raywenderlich.com/3664/opengl-tutorial-for-ios-opengl-es-2-0
http://www.raywenderlich.com/4404/opengl-es-2-0-for-iphone-tutorial-part-2-textures
The common mistakes
http://www.opengl.org/wiki/Common_Mistakes
1, glLoadIdentity
座標系復位,當前矩陣變爲單位矩陣。