【问题标题】:gl calls end in EXC_BAC_ACCESS - bad opengl context?gl 调用以 EXC_BAC_ACCESS 结束 - 糟糕的 opengl 上下文?
【发布时间】:2010-10-15 23:15:05
【问题描述】:

我有以下程序

void allocVars(){
    m_window = new GLWindow(); //glGenTexture() is called //CRASH!
    m_window->Init(m_cam.w, m_cam.h, "Window Name"); 

}
void glInit()
{
    glutReshapeFunc(reshape);
    glutIdleFunc(idle);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutDisplayFunc(display);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE); //CRASH!
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);

    glInit(); // CRASH HERE
    camInit(); //ok
    allocVars(); // CRASH HERE

    trackingInit();

    glutMainLoop();


    return 0;

}

根据其他帖子,为了进行 gl 调用,我必须首先拥有一个有效的 openGL 上下文。 (由于 Windows 中的奇怪原因,即使上下文无效,它也可以工作。) 这就是为什么我在 glutInit 和 glInit 函数之后移动所有内容,但是这个应用程序总是在 gl 函数中崩溃,比如 allocVars() 内的 glGenTextures();在 GLWindow();或在 glBlendFunc() 在 glInit() 内

我想知道我在这里遗漏了什么和/或如何检查我有一个有效的 opengl 上下文?

提前致谢

【问题讨论】:

  • 您的glutInitDisplayMode()glutCreateWindow() 电话在哪里?
  • 我刚刚意识到,...谢谢! glutInitDisplayMode(); -> glutInitWindowPosition(); -> glutInitWindowSize(); -> glutCreateWindow(名称); -> glGenTextures();是正确的顺序!,这解决了我的问题,现在程序运行;)

标签: opengl glut


【解决方案1】:

答案在 cmets ↑

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-14
    • 1970-01-01
    • 2012-06-14
    • 1970-01-01
    • 2014-06-30
    • 1970-01-01
    • 2014-09-07
    • 2020-05-08
    相关资源
    最近更新 更多