我在使用GLSL中的变量索引时遇到了一些麻烦.下面的GLSL代码在NVidia卡上运行良好.但它不适用于我的Intel HD 4000:
for(int i=0;i<int(uLightCount);++i)
{
vec3 lightPos = uLightsPos[i];
....
}
Run Code Online (Sandbox Code Playgroud)
没有着色器编译器错误.该程序只是崩溃了glUseProgram
我怎样才能解决这个问题?
编辑:
uLightCount并且uLightsPos是制服:
#define MAX_LIGHTS 10
uniform float uLightCount;
uniform vec3 uLightsPos[MAX_LIGHTS];
Run Code Online (Sandbox Code Playgroud)
编辑2:
我找到了一个奇怪的解决方法:
#define i0 0
#define i1 1
#define i2 2
...
for(int i=0;i<int(uLightCount);++i)
{
vec3 lightPos;
if (i==i0)
lightPos = uLightsPos[i0];
if (i==i1)
lightPos = uLightsPos[i1];
....
}
Run Code Online (Sandbox Code Playgroud)
知道为什么这个有用吗?
我正在尝试在android上使用opencv(仅限ndk).我编译了armeabi的git存储库的最新源代码.(基于:Building_OpenCV4Android_from_trunk)
但是我得到了这个错误(使用ndk-build):
error: undefined reference to 'cv::Mat::deallocate()'
error: undefined reference to 'cv::fastFree(void*)'
error: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)'
error: undefined reference to 'cv::Mat::copyTo(cv::_OutputArray const&)'
error: undefined reference to 'cv::Mat::inv(int) const'
Run Code Online (Sandbox Code Playgroud)
简单的测试代码:
cv::Mat testMat = cv::Mat(cv::Matx44d
(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
));
cv::Mat testMatInv = testMat.inv();
Run Code Online (Sandbox Code Playgroud)
我的Android.mk:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../libs/opencv/include
LOCAL_LDLIBS += -L../../../../libs/opencv/lib/android/armeabi
LOCAL_LDLIBS += -llog -lGLESv2 –lz
LOCAL_STATIC_LIBRARIES := libzip libpng libjpeg freetype
LOCAL_STATIC_LIBRARIES += libopencv_calib3d libopencv_contrib …Run Code Online (Sandbox Code Playgroud) 我想用它AVFoundation Famework来预览和拍摄照片.我创建了一个AVCaptureSession和添加AVCaptureVideoDataOutput,AVCaptureStillImageOutput本届会议.我将预设设置为AVCaptureSessionPresetLow.
现在我想以全分辨率拍摄照片.但在captureStillImageAsynchronouslyFromConnection分辨率内与我的预览代表相同.
这是我的代码:
AVCaptureSession* cameraSession = [[AVCaptureSession alloc] init];
cameraSession.sessionPreset = AVCaptureSessionPresetLow;
AVCaptureVideoDataOutput* output = [[AVCaptureVideoDataOutput alloc] init];
[cameraSession addOutput:output];
AVCaptureStillImageOutput* cameraStillImage = [[AVCaptureStillImageOutput alloc] init];
[cameraSession addOutput:cameraStillImage];
// delegation
dispatch_queue_t queue = dispatch_queue_create("MyQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);
[cameraSession startRunning];
Run Code Online (Sandbox Code Playgroud)
拍照:
//[cameraSession beginConfiguration];
//[cameraSession setSessionPreset:AVCaptureSessionPresetPhoto]; <-- slow
//[cameraSession commitConfiguration];
[cameraStillImage captureStillImageAsynchronouslyFromConnection:photoConnection completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error)
{
...
}];
Run Code Online (Sandbox Code Playgroud)
我通过将预设更改为照片来尝试拍摄图像.但这非常慢(更改预设需要2-3秒).我不想有这么大的延迟.
我怎样才能做到这一点?谢谢.
iphone video-capture objective-c avfoundation avcapturesession
我在循环中创建一些随机向量/方向作为圆顶形状,如下所示:
void generateDome(glm::vec3 direction)
{
for(int i=0;i<1000;++i)
{
float xDir = randomByRange(-1.0f, 1.0f);
float yDir = randomByRange(0.0f, 1.0f);
float zDir = randomByRange(-1.0f, 1.0f);
auto vec = glm::vec3(xDir, yDir, zDir);
vec = glm::normalize(vec);
...
//some transformation with direction-vector
}
...
}
Run Code Online (Sandbox Code Playgroud)
这会将矢量创建为+y方向上的圆顶形状(0,1,0):

现在我想vec按给定的方向旋转-Vector - 像矢量一样(1,0,0).这应该将"圆顶"旋转到x方向,如下所示:

我怎样才能做到这一点?(最好用glm)
opengl ×2
android ×1
android-ndk ×1
avfoundation ×1
c++ ×1
glm-math ×1
glsl ×1
intel ×1
iphone ×1
matrix ×1
objective-c ×1
opencv ×1