我尝试在Mac上使用OpenGL glut,并在以下内容上出现细分fult错误:

GLuint g_frameBuffer;

void render()
{
    //Clear color buffer
    glClear( GL_COLOR_BUFFER_BIT );

    //Render quad
    glBegin( GL_QUADS );
        glVertex2f( -0.5f, -0.5f );
        glVertex2f(  0.5f, -0.5f );
        glVertex2f(  0.5f,  0.5f );
        glVertex2f( -0.5f,  0.5f );
    glEnd();

    //Update screen
    glutSwapBuffers();
}

int main( int argc, char* args[] ){

    glutInit( &argc, args );
    glutInitWindowSize  ( 1000, 1000);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

    glutCreateWindow("Paintstorm");
    glutInitDisplayMode(GLUT_RGBA);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glEnable(GL_TEXTURE_2D);

    glGenFramebuffersEXT( 1, &g_frameBuffer );
    //Set rendering function
    glutDisplayFunc( render );
    //Start GLUT main loop
    glutMainLoop();

    return 0;
}

我用-framewok OpenGL,-framework GLUT,-framework Cocoa编译它
当我添加glTextParametri时出现错误

最佳答案

调用glEnable(GL_TEXTURE_2D)之后,应调用glTexParameteri。您可能在这里遇到了段错误,因为您没有有效的opengl上下文(在glutCreateWindow之后拥有它)

关于c++ - Mac中的glTexParameteri段错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29576366/

10-10 00:57