我知道iPhone使用OpenGL ES 2.0,但我不知道底层语言GLSL的版本.是1.3,1.4,2.0还是其他?
已知分支在OpenGL ES着色器中特别具有计算成本.在这样的着色器中,我在除以之前检查值是否为null,例如:
if(value == 0.0)
other_value = 0.0;
else
other_value = 1.0 / value;
Run Code Online (Sandbox Code Playgroud)
为了加快速度,我想if通过直接做到这一点来避免这种情况:
other_value = 1.0 / value;
Run Code Online (Sandbox Code Playgroud)
我想知道如果value碰巧等于0会发生什么,这在我的治疗中有点罕见,这就是为什么测试它并不容易.着色器是否会崩溃?应用程序崩溃了吗?
我用来argparse从用户那里获取一个文件:
import argparse, os
parser = argparse.ArgumentParser()
parser.add_argument('file', type=file)
args = parser.parse_args()
Run Code Online (Sandbox Code Playgroud)
然后我想知道这个文件的目录,如:
print(os.path.abspath(os.path.dirname(args.inputfile)))
Run Code Online (Sandbox Code Playgroud)
但是,当然,作为args.inputfile一个file对象,这不起作用.怎么做?
我有一些从我的本机代码生成的值,我想传递给phonegap.这些数据是实时生成的,并不直接受用户通过phonegap gui操作的影响.我的本机代码是我制作的插件的一部分.
解决这个问题的最佳方法是什么?我希望有一个函数可以随时发送数据,并在cordova端有一个监听器.我正在使用Cordova 1.5和Xcode 4.3.
这是我到目前为止:
swipe.js:
var swipe={
callNativeFunction: function (success, fail, resultType) {
return Cordova.exec( success, fail,
"ca.swipe",
"nativeFunction",
[resultType]); }
};
Run Code Online (Sandbox Code Playgroud)
index.html的:
...
function callNativePlugin( returnSuccess ) {
swipe.callNativeFunction( nativePluginResultHandler, nativePluginErrorHandler, returnSuccess );
}
function nativePluginResultHandler (result) {
alert("SUCCESS: \r\n"+result );
}
function nativePluginErrorHandler (error) {
alert("ERROR: \r\n"+error );
} ... <body onload="onBodyLoad()"> <h1>Hey, it's Cordova!</h1>
<button onclick="callNativePlugin('success');">Success</button>
<button onclick="callNativePlugin('error');">Fail</button>
</body> ...
Run Code Online (Sandbox Code Playgroud)
swipe.h:
...
@interface swipe : CDVPlugin
- (void) nativeFunction:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
@end
Run Code Online (Sandbox Code Playgroud)
swipe.m:
...
- (void) …Run Code Online (Sandbox Code Playgroud) 四边形不包含在OpenGL ES 2.0中,因为它们在1.1中.使用OpenGL ES 2.0提供的可编程管道,如何将纹理(最初是一个png文件)绘制成4个定义的点?
我需要一个VBO吗?我是否需要计算透视矩阵?所有这些对我来说都很混乱......使用的平台是iPhone.
我尝试为warpPerspective()函数指定一个与基本(0,0)不同的原点,以便独立于支持图像大小应用变换.我在原始代码中添加了一个CvPoint参数,但是我找不到使用这些坐标的位置.我试图在X0,Y0和W0的计算中使用它们,但它不起作用,这只是在生成的图像中移动变换后的图像.任何的想法?
这里的代码:
void warpPerspective( const Mat& src, Mat& dst, const Mat& M0, Size dsize,
int flags, int borderType, const Scalar& borderValue, CvPoint origin )
{
dst.create( dsize, src.type() );
const int BLOCK_SZ = 32;
short XY[BLOCK_SZ*BLOCK_SZ*2], A[BLOCK_SZ*BLOCK_SZ];
double M[9];
Mat _M(3, 3, CV_64F, M);
int interpolation = flags & INTER_MAX;
if( interpolation == INTER_AREA )
interpolation = INTER_LINEAR;
CV_Assert( (M0.type() == CV_32F || M0.type() == CV_64F) && M0.rows == 3 && M0.cols == 3 );
M0.convertTo(_M, _M.type());
if( !(flags & …Run Code Online (Sandbox Code Playgroud)