我尝试在Mac上使用OpenGL过剩,并在以下内容中出现分段错误:
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
时出错答案 0 :(得分:1)
你应该在调用glEnable(GL_TEXTURE_2D)后调用glTexParameteri。你可能在这里有段错误,因为你没有有效的opengl上下文(你在glutCreateWindow之后有它)