写作业时遇到的OpenGL版本不符的问题

console结果:

status: Using GLEW 1.7.0

Error: OpenGL 1.4 is not supported.

.cpp中main( int argc, char** argv )相应的代码:

 1 // Initialize GLEW.
 2 // The followings make sure OpenGL 1.4 is supported and set up the extensions.
 3 
 4    
 5     GLenum err = glewInit();
 6     if ( err != GLEW_OK )
 7     {
 8         fprintf( stderr, "Error: %s.\n", glewGetErrorString( err ) );
 9         exit( 1 );
10     }
11     printf( "Status: Using GLEW %s.\n\n", glewGetString( GLEW_VERSION ) );
12 
13     if ( !GLEW_VERSION_1_4 )
14     {
15         fprintf( stderr, "Error: OpenGL 1.4 is not supported.\n" );
16         exit( 1 );
17     }

本段代码的作用是确保OpenGL1.4能够作为支持的库并拓展出一些功能,但是问题是如果电脑上的OpenGL包不是1.4的版本,就会出现上述问题,解决办法是将这段注释,因为一般的OpenGL包都能提供相应功能的支持,没有必要一定要是OpenGL 1.4的版本,这样做的优点是更为万无一失,但是移植性不好。

以后如果遇到相应的版本问题,可以先将其注释,等程序写好了,再做进一步的调整和限制。

posted @ 2013-02-12 09:16  qingsun_ny  阅读(272)  评论(0)    收藏  举报