我的程序接收 PCL 点云并使用以下方法一一绘制每个点:
glBegin(GL_POINTS);
glVertex3f(point.x, point.y, point].z);
glEnd();
Run Code Online (Sandbox Code Playgroud)
它有效,但由于点数很多,程序速度很慢。有没有更有效的方法来做到这一点?
我正在学习,constexpr并且据我所知,它constexpr告诉编译器在编译期间计算函数而不是运行时间.我使用以下代码进行测试,但遇到了一个我真的不明白的错误.你能解释一下原因吗?
#include <iostream>
#include <array>
using namespace std;
constexpr int foo(int i)
{
return i + 5;
}
int main()
{
int i = 10;
std::array<int, foo(5)> arr; // OK
// But...
std::array<int, foo(i)> arr1; // Error
}
Run Code Online (Sandbox Code Playgroud)
错误是:' i' 的值在常量表达式中不可用.为什么?i事先声明为什么它必须是一个const?