在iOS 4上使用OpenGL ES 2.0.
我有一个继承自UIView的OpenGL视图.它位于提供背景的UIImageView前面.
我有一个 .png图像具有透明度,我用于OpenGL纹理.
我遇到的问题是OpenGL视图中的图像透明度显示到UIImageView背景中的图像.我想在OpenGL视图中显示具有透明纹理的元素后面的内容.
正在渲染下面的OpenGL纹理,但顶部具有透明纹理的任何部分都不会显示OpenGL纹理.它显示了UIImageView背景.
我需要做什么才能使透明度在OpenGL视图中显示透明内容背后的内容?
编辑:
我重新构造了索引数组,所以所有带有透明纹理的元素都在最后,当我调用glDrawElements时,应该在所有不透明元素之后渲染.
仍然存在透明度问题.
我设置了一些数据,这样我有2个三角形的4个顶点和6个索引来绘制一个带有不透明纹理的正方形.对于2个三角形,还有4个顶点和6个索引,用于绘制具有透明纹理的正方形,该正方形位于顶点/索引数组中的其他条目之后.透明元素坐标将其呈现在不透明元素的前面.
我可以看到透明元素,我也可以看到不透明元素的边缘从后面伸出来.但是,不是显示位于透明元素后面的不透明元素,而是直接显示透明度并显示OpenGL视图后面的视图背景.
不透明的黄色方块:

透明测试图像:

透明图像覆盖不透明图像,但透明度显示背景而不是后面的不透明图像:


所以,我有一个想法,在main中捕获意外的异常并尝试清理并优雅地退出:
int main(int argc, char *argv[])
{
@autoreleasepool
{
//return UIApplicationMain(argc, argv, nil, NSStringFromClass([GRWAppDelegate class]));
@try
{
int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([GRWAppDelegate class]));
return retVal;
}
@catch (NSException *exception)
{
[Utilities setPreferencesDefaults];
}
}
}
Run Code Online (Sandbox Code Playgroud)
这会捕获异常并更新首选项默认值.
然后我想,为什么退出,只是清理和重新启动,所以我把所有东西都包裹在while循环中:
int main(int argc, char *argv[])
{
while (YES)
{
@autoreleasepool
{
...
}
}
}
Run Code Online (Sandbox Code Playgroud)
当然,如果真的有效,我就不会在这里.问题是,一旦它再次执行
retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([GRWAppDelegate class]));
Run Code Online (Sandbox Code Playgroud)
它会立即抛出一个新的异常:
Assertion failure in void UIApplicationInstantiateSingleton(Class)(), /SourceCache/UIKit/UIKit-2380.17/UIApplication.m:2037
NSInternalInconsistencyException
@"There can only be one …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,支持所有四个方向,在iOS 5上正常工作.
但是,在iOS 6上,我的所有UIViewController类都可以正常旋转,但我的UITableViewController类不会旋转到PortraitUpsideDown.
应用程序支持的方向包括所有四个选项.
AppDelegate支持所有方向:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
//return (UIInterfaceOrientationMaskAll);
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
Run Code Online (Sandbox Code Playgroud)
我的所有视图类都实现了必要的方法,包括为iOS 6引入的方法:
- (NSUInteger)supportedInterfaceOrientations
{
//return (UIInterfaceOrientationMaskAll);
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (BOOL)shouldAutorotate
{
BOOL bReturn = [self shouldAutorotateToInterfaceOrientation:self.interfaceOrientation];
return (bReturn);
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (YES);
}
Run Code Online (Sandbox Code Playgroud)
我能找到的唯一区别是视图的显示方式.
的UIViewController
InfoViewController *infoController = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:[NSBundle mainBundle]];
[self presentModalViewController:infoController animated:YES];
Run Code Online (Sandbox Code Playgroud)
的UITableViewController …
我正在编写一个Android应用程序,并且在定义boolean资源方面存在问题.
我有一个文件, bools.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="preferences_autoplay">true</bool>
</resources>
Run Code Online (Sandbox Code Playgroud)
然而,当我尝试使用时R.bool.preferences_autoplay,它被认为是一个int而不是一个boolean:

我收到错误:
putBoolean(String, boolean)类型中的方法SharedPreferences.Editor不适用于参数(String, int)
int如果我需要,我当然可以使用一个,但我不明白为什么它不被认为是一个boolean.
关于如何使用boolean资源的任何想法boolean?