2

试图初始化最近的 GLEW,程序中断并且 lldb 给出了提到的消息。

最小的例子:

#define GLEW_STATIC
#include <GL/glew.h>

int main(int argc, const char * argv[]) {
    glewExperimental = GL_TRUE;
    glewInit();    <<<< EXC_BAD_ACCESS here
}

堆栈框架调试器输出:

1 ___lldb_unnamed_function...

libGLEW.1.10.0.dylib`___lldb_unnamed_function2$$libGLEW.1.10.0.dylib:
0x100005e30:  pushq  %rbp
0x100005e31:  movq   %rsp, %rbp
0x100005e34:  pushq  %r15
0x100005e36:  pushq  %r14
0x100005e38:  pushq  %r12
0x100005e3a:  pushq  %rbx
0x100005e3b:  movl   $7938, %edi
0x100005e40:  callq  0x100044668               ; symbol stub for: glGetString
0x100005e45:  movl   $1, %r14d        <<<< EXC_BAD_ACCESS here
0x100005e4b:  testq  %rax, %rax
0x100005e4e:  je     0x100034a86               ; ___lldb_unnamed_function2$$libGLEW.1.10.0.dylib + 191574
...

0 glGetString

libGL.dylib`glGetString:
0x7fff8bfa28a6:  pushq  %rbp
0x7fff8bfa28a7:  movq   %rsp, %rbp
0x7fff8bfa28aa:  movl   %edi, %eax
0x7fff8bfa28ac:  movq   %gs:240, %rdx
0x7fff8bfa28b5:  movq   944(%rdx), %rcx    <<<< EXC_BAD_ACCESS here
0x7fff8bfa28bc:  movq   (%rdx), %rdi
0x7fff8bfa28bf:  movl   %eax, %esi
0x7fff8bfa28c1:  popq   %rbp
0x7fff8bfa28c2:  jmpq   *%rcx

这是 GLEW 或我的配置中的一些错误吗?

4

1 回答 1

3

显然gl,首先需要创建一个上下文。

所以万一glfwglfwCreateWindow需要调用成功才glewInit可以。

于 2013-08-23T18:20:51.077 回答