开发者

gl calls end in EXC_BAC_ACCESS - bad opengl context?

开发者 https://www.devze.com 2023-01-19 21:20 出处:网络
I have the following program void allocVars(){ m_window = new GLWindow(); //glGenTexture() is called //CRASH!

I have the following program

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
    cam开发者_开发问答Init(); //ok
    allocVars(); // CRASH HERE

    trackingInit();

    glutMainLoop();


    return 0;

}

Acccording to other posts, in order to make gl calls I have to have a valid openGL context first. (For strange reasons in Windows it works even if the context is not valid yet.) That is why I move everything after glutInit and glInit functions but this application always crashes in gl functions like glGenTextures() inside of allocVars(); in GLWindow(); or in glBlendFunc() inside of glInit()

I wonder what am I missing here and/or how can I check I have a valid opengl context?

Thanks in advance


answer is in the comments ↑

0

精彩评论

暂无评论...
验证码 换一张
取 消