小编lig*_*rek的帖子

GL_ARRAY_BUFFER目标在glBindBuffer中的含义是什么?

我对VBO很困惑,

glGenBuffers(1, &positionBufferObject);
glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);
Run Code Online (Sandbox Code Playgroud)

除了GL_ARRAY_BUFFER,还有其他目标类型:GL_ATOMIC_COUNTER_BUFFER,GL_COPY_READ_BUFFER ......

但是,Opengl手册没有提到这些目标的含义.我检查了glew.h:

#define GL_ARRAY_BUFFER 0x8892
Run Code Online (Sandbox Code Playgroud)

这是否意味着目标(如GL_ARRAY_BUFFER)是地址?

目标 - GL_ARRAY_BUFFER在glBindBuffer中的含义是什么?

opengl graphics shader opengl-es glsl

21
推荐指数
1
解决办法
2万
查看次数

Qt创建者添加外部库(仍然:无法打开包含文件:'GL/glew.h')

我按照说明操作:

  1. 在"项目"窗格中,打开项目文件(.pro).
  2. 在代码编辑器中单击鼠标右键以打开上下文菜单,然后选择"添加库...".

添加库

然后将以下行添加到pro文件中:

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/D:/OpenGL/glew-1.5.4/lib/ -lglew32
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/D:/OpenGL/glew-1.5.4/lib/ -lglew32d

INCLUDEPATH += $$PWD/D:/OpenGL/glew-1.5.4/include
DEPENDPATH += $$PWD/D:/OpenGL/glew-1.5.4/include
Run Code Online (Sandbox Code Playgroud)

但是,我点击左下角的绿色三角形图标运行程序,仍然得到错误:

错误:C1083:无法打开包含文件:'GL/glew.h':没有这样的文件或目录

c++ qt qt4 qt-creator qt5

9
推荐指数
1
解决办法
2万
查看次数

似乎很难找出这个简单程序的时间复杂性

我有下面的代码来模拟算法的递归行为,因为我没有弄清楚该算法的时间复杂度:

int M(int n)
{
    int result = 1;
    for (int i = n-1; i >= 0; --i)
    {
        result += M(i);
    }
    return result;
}
Run Code Online (Sandbox Code Playgroud)

根据我的理解,我绘制了下面的树来说明算法: 当n为3时

(输入n在图中为3).我认为树中节点的数量是算法的复杂性.如果输入是n,那么时间复杂度是多少?谢谢!

c++ algorithm recursion time-complexity

5
推荐指数
1
解决办法
173
查看次数

Boost foreach 与 Q_FOREACH (Qt) 和 moc 生成冲突?

我有一个在 Vs 2008 中使用一些库(例如 Qt 和 Point Cloud Library (PCL))编辑的程序。

PCL 有一个包含 boost 的 3rd 方库。

但是编译后出现了一些错误:

1>C:\Program Files\PCL 1.5.1\3rdParty\Boost\include\boost/multi_index/sequenced_index.hpp(926) : error C3083: 'Q_FOREACH': '::'左边的符号必须是类型 1>C:\Program Files\PCL 1.5.1\3rdParty\Boost\include\boost/multi_index/sequenced_index.hpp(926) : error C2039: 'tag' : is not a member of 'boost' 1>C :\Program Files\PCL 1.5.1\3rdParty\Boost\include\boost/multi_index/sequenced_index.hpp(926):错误 C2061:语法错误:标识符“标签”1>C:\Program Files\PCL 1.5.1\ 3rdParty\Boost\include\boost/multi_index/ordered_index.hpp(1399) : error C3083: 'Q_FOREACH': '::' 左边的符号必须是类型 1>C:\Program Files\PCL 1.5。 1\3rdParty\Boost\include\boost/multi_index/ordered_index.hpp(1399):错误 C2039:'标签':不是 'boost' 1>C:\Program Files\PCL 1.5.1\3rdParty\Boost\include\boost/multi_index/ordered_index.hpp(1399) 的成员:错误 C2061:语法错误:标识符 '标签' 1> C:\Program Files\PCL 1.5.1\3rdParty\Boost\include\boost/multi_index/hashed_index.hpp(1254):错误 C3083:“Q_FOREACH”:“::”左边的符号必须是一个类型1>C:\Program Files\PCL 1.5.1\3rdParty\Boost\include\boost/multi_index/hashed_index.hpp(1254) : error C2039: 'tag' : is not a …

c++ qt boost point-cloud-library

4
推荐指数
1
解决办法
2847
查看次数

结构专用原子类型如何可以自由锁定?

我找到了以下代码,输出总是:

std::atomic<A> is lock free? false
std::atomic<B> is lock free? true
Run Code Online (Sandbox Code Playgroud)

这是代码:

struct A { int a[100]; };
struct B { int x, y; };
int main()
{
    std::cout << std::boolalpha
              << "std::atomic<A> is lock free? "
              << std::atomic<A>{}.is_lock_free() << '\n'
              << "std::atomic<B> is lock free? "
              << std::atomic<B>{}.is_lock_free() << '\n';
}
Run Code Online (Sandbox Code Playgroud)

我不明白第二个结构专用原子类型怎么能锁定自由而第一个专用原子类型不能无锁?

提前致谢.

c++ multithreading atomicity c++11

4
推荐指数
1
解决办法
193
查看次数

为什么我在解决方案资源管理器窗口中有一个External Dependencies文件夹(快捷方式)?

我的计算机上有Qt5和vs2010 qmake -tp vc chapter01.pro然后在vs2010中打开它:

文件快捷方式 展开外部依赖关系快捷方式

为什么我在解决方案资源管理器窗口中有一个External Dependencies文件夹(快捷方式)?

当前程序似乎正在使用External Dependencies文件夹(快捷方式)中的头文件.如何禁用此文件夹或如何使用此文件夹中的头文件停止程序?

c++ qt glsl visual-studio-2010

3
推荐指数
1
解决办法
6307
查看次数

对右值引用 vector::push_back 函数如何提高效率感到困惑

从 cppreference.com,我找到了一个关于使用 std::move 的简单示例:

std::string str = "Hello";
std::vector<std::string> v;

// uses the push_back(const T&) overload, which means 
// we'll incur the cost of copying str
v.push_back(str);                                    // First push_back
std::cout << "After copy, str is \"" << str << "\"\n";

// uses the rvalue reference push_back(T&&) overload, 
// which means no strings will be copied; instead, the contents
// of str will be moved into the vector.  This is less
// expensive, but also means str might now be …
Run Code Online (Sandbox Code Playgroud)

c++ move vector rvalue-reference c++11

3
推荐指数
1
解决办法
1452
查看次数

for循环中奇怪的std :: string :: size()

如果我input.size() - 1用作for循环条件,程序将打印"进入循环" .

std::string input;
input = {""};
int i = 0;
for (; i < input.size() - 1; ++i)
{
    cout << "Entered the loop" << endl;
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我将值传递input.size() -1给整数(checksize):

std::string input;
input = {""};
int checksize = input.size() - 1;
int i = 0;
for (; i < checksize; ++i)
{
    cout << "Entered the loop" << endl;
}
Run Code Online (Sandbox Code Playgroud)

然后程序将不会进入循环并且不会打印"进入循环"

我想知道为什么会这样?看来这两段代码对我来说是一样的.

c++ size unsigned for-loop unsigned-integer

2
推荐指数
1
解决办法
406
查看次数

关于以null结尾的字符串(混淆)

以下着色器被称为一个字符串和一个以null结尾的字符串.

着色器:

const GLchar* VertexShader =
{
    "#version 330\n"\

    "layout(location=0) in vec4 in_Position;\n"\
    "layout(location=1) in vec4 in_Color;\n"\
    "out vec4 ex_Color;\n"\

    "void main(void)\n"\
    "{\n"\
    "   gl_Position = in_Position;\n"\
    "   ex_Color = in_Color;\n"\
    "}\n"
};
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  1. 每行末尾的斜线是什么意思?而且,为什么最后一行没有斜线?
  2. 着色器中有几个字符串,为什么着色器据说只有一个字符串?
  3. 为什么它被称为以空字符结尾的字符串?(因为没有'\ 0')

c c++

1
推荐指数
1
解决办法
228
查看次数