该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
}
//程序入口
int main(int argc, char *argv[])
{
//随机生成细胞的状态
MapRand();
std::cout<
//SDL初始化
const SDL_VideoInfo* info = NULL;
int width = 0;
int height = 0;
int bpp = 0;
int flags = 0;
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) );
quit_tutorial( 1 );
}
info = SDL_GetVideoInfo( );
if( !info ) {
fprintf( stderr, "Video query failed: %s\n",
SDL_GetError( ) );
quit_tutorial( 1 );
}
width = 1024;
height = 768;
bpp = info->vfmt->BitsPerPixel;
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 24 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 24 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 24 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
flags = SDL_OPENGL | SDL_FULLSCREEN;
if( SDL_SetVideoMode( width, height, bpp, flags ) == 0 ) {
fprintf( stderr, "Video mode set failed: %s\n",
SDL_GetError( ) );
quit_tutorial( 1 );
}
//初始化OpenGL
setup_opengl( width, height );
//进入消息循环
SDL_Process();
//退出程序
quit_tutorial( 0 );
return 0;
}
void SDL_Process()
{
bool gameOver = false;
while( !gameOver )
{
SDL_Event gameEvent;
SDL_PollEvent(&gameEvent);
if ( &gameEvent != 0 )