使用GLFW + GLEW时glGenFramebuffers()访问冲突 [英] glGenFramebuffers() access violation when using GLFW + GLEW

查看:116
本文介绍了使用GLFW + GLEW时glGenFramebuffers()访问冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:

访问冲突执行位置0x00000000."

"Access violation executing location 0x00000000."

在Windows上使用GLFW + GLEW时.

when I use GLFW + GLEW on Windows.

我正在使用Windows7.我也有自己的实现(从头开始),该实现创建一个窗口,初始化OpenGL上下文,初始化GLEW等,并且一切正常.因此,当然,我的视频卡具有帧缓冲功能,并且驱动程序一切正常……仅当我尝试使用GLFW时,问题才会发生.

I am using Windows 7. I also have my own implementation (from scratch) that that creates a window, initializes OpenGL context, initializes GLEW, etc... and everything works fine. So of course my video card has the Frame Buffer capability and everything is pretty fine with the drivers... the problem only happens when I try to use GLFW.

有什么建议吗?

代码:

void start()
{
    if( !glfwInit() )
    {
        glfwTerminate();
        throw exception( "Failed to initialize GLFW" );
    }

    glfwOpenWindowHint( GLFW_FSAA_SAMPLES, 4 );
    glfwOpenWindowHint( GLFW_OPENGL_VERSION_MAJOR, 3 );
    glfwOpenWindowHint( GLFW_OPENGL_VERSION_MINOR, 3 );
    glfwOpenWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );

    if( !glfwOpenWindow( m_width, m_height, 0, 0, 0, 0, 32, 0, GLFW_WINDOW ) )
    {
        throw exception( "Failed to open GLFW window." );
        glfwTerminate();
    }

    if ( glewInit() != GLEW_OK )
    {
        throw exception( "Failed to initialize GLEW" );
    }

    // texture
    glGenTextures( 1, &m_texture );
    glBindTexture( GL_TEXTURE_2D, m_texture );

    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

    // frame buffer
    glGenFramebuffers( 1, &m_frameBuffer ); // IT CRASHES HERE! :-(
    glBindFramebuffer( GL_FRAMEBUFFER, m_frameBuffer );

    glBindTexture( GL_TEXTURE_2D, m_texture );

    ...
}

推荐答案

GLEW在使用核心OpenGL配置文件时存在已知问题.您可以使用 GLEW解决方法,也可以对

GLEW has known problems when working with a core OpenGL profile. You can either use the GLEW workaround or abandon GLEW for extension loaders that actually work.

这篇关于使用GLFW + GLEW时glGenFramebuffers()访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆