小编Roo*_*ter的帖子

glGenVertexArrays(1,&vao)的分段错误;

我的gdb回溯给出:

(gdb) backtrace
#0  0x00000000 in ?? ()
#1  0x0804a211 in init () at example1.cpp:147
#2  0x0804a6bc in main (argc=1, argv=0xbffff3d4) at example1.cpp:283
Run Code Online (Sandbox Code Playgroud)

信息量不大.Eclipse调试器至少让我看到它停在下面的第3行:

// Create a vertex array object
GLuint vao;
glGenVertexArrays( 1, &vao );
glBindVertexArray( vao );
Run Code Online (Sandbox Code Playgroud)

这是一个非常常见的块,可以在gl编程中看到,我甚至可以使用相同的块运行其他代码,没有任何问题.所以我很困惑.

从运行make构建输出:

g++ -g -DFREEGLUT_STATIC -DGLEW_STATIC -I../../include example1.cpp ../../Commo/InitShader.o  -L/usr/lib/mesa -lGLEW -lglut -lGL -lX11  -lm  -o example1
Run Code Online (Sandbox Code Playgroud)

包含问题的程序:

// rotating cube with two texture objects
// change textures with 1 and 2 keys

#include "Angel.h"

const int  NumTriangles = 12; // …
Run Code Online (Sandbox Code Playgroud)

c++ opengl debugging segmentation-fault

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

"std :: bad_alloc":我使用的内存太多了吗?

消息:

terminate called after throwing an instance of 'std::bad_alloc'
what():  std::bad_alloc
Run Code Online (Sandbox Code Playgroud)

我查看了gdb backtrace,这是我自己实现的最低级别方法:

/*
 * get an array of vec3s, which will be used for rendering the image
 */
vec3 *MarchingCubes::getVertexNormalArray(){
    // Used the same array size technique as getVertexArray: we want indices to match     up
    vec3 *array = new vec3[this->meshPoints.getNumFaces() * 3]; //3 vertices per face

    int j=0;
    for (unsigned int i=0; i < (this->meshPoints.getNumFaces() * 3); i++) {
        realVec normal = this->meshPoints.getNormalForVertex(i);
 //     PCReal* iter = normal.begin();

        if …
Run Code Online (Sandbox Code Playgroud)

c++ bad-alloc

15
推荐指数
3
解决办法
8万
查看次数

在Ubuntu上安装C++库

我必须是一个菜鸟,总是在Linux上安装时遇到问题.我正在尝试安装:http://openil.sourceforge.net/download.php.所以我使用DL页面中的Devil 1.7.8 tar.gz来阅读手册(http://openil.sourceforge.net/docs/index.php).

  1. 我看到没有预编译的.so作为手册说明.

  2. 它尝试编译自己,我看到在执行配置,构建,安装后,没有对usr/lib或usr/include(作为手动状态)添加OpenIL.

  3. 我应该通过包管理器安装它...但我仍然不知道我需要包含/链接到哪些文件.

更新:仔细看看上面2的安装输出显示,实际上是在用户/本地下安装了东西(非常感谢手册).

所以,为了确定,我如何将.so和.h链接到我的程序.

c++ linux ubuntu devil

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

调用delete时出现分段错误

gdb回溯:

#0  0x0040cea9 in free () from /lib/tls/i686/cmov/libc.so.6
#1  0x0033c741 in operator delete(void*) () from /usr/lib/libstdc++.so.6
#2  0x080654b6 in mesh::calculateMeanNormalsPerVertex (this=0x807d684)
    at /home/brent/Desktop/protCAD/src/math/mesh.cc:230
#3  0x0805638f in buildCubes (argc=4, argv=0xbffff3e4)
    at /home/brent/Desktop/protCAD/src/driver/executeCubes.cc:163
#4  main (argc=4, argv=0xbffff3e4)
    at /home/brent/Desktop/protCAD/src/driver/executeCubes.cc:297
Run Code Online (Sandbox Code Playgroud)

声明并delete致电mesh.cc:

vector<vector<int> > faceIndicesPerVertex (vertexArray.size());
...
delete[] &faceIndicesPerVertex;    //line 230
Run Code Online (Sandbox Code Playgroud)

我确定我有这个错误,但我已经尝试了几种不同的方法来调用删除,但除了上面之外似乎没有编译.有什么问题?

c++ memory-management segmentation-fault

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

通过线程引用传递整数

我有一个带有全局变量的类,整数时钟,初始化为0.它将'clock'传递给几个线程构造函数,也启动线程.在线程中可以看到'clock'的增量,但在调用过程中,'clock'始终为0.因为Integer是一个对象而对象是通过引用传递的,所以我希望看到'clock'的变化到处.这不是这种情况吗?

java

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