From: <joh...@us...> - 2003-10-31 18:54:10
|
Update of /cvsroot/freedroid/FreeDroid/src In directory sc8-pr-cvs1:/tmp/cvs-serv7408 Modified Files: graphics.c open_gl.c proto.h Log Message: * Added even more error checking and debug/status output for the OpenGL stuff. Index: graphics.c =================================================================== RCS file: /cvsroot/freedroid/FreeDroid/src/graphics.c,v retrieving revision 1.224 retrieving revision 1.225 diff -C2 -d -r1.224 -r1.225 *** graphics.c 31 Oct 2003 17:20:12 -0000 1.224 --- graphics.c 31 Oct 2003 18:54:07 -0000 1.225 *************** *** 1356,1359 **** --- 1356,1360 ---- int video_mode_ok_check_result ; char *fpath; + int buffer_size , depth_size, red_size, green_size, blue_size, alpha_size ; //-------------------- *************** *** 1439,1442 **** --- 1440,1445 ---- video_flags |= SDL_HWACCEL; + open_gl_check_error_status ( ); + /* Sets up OpenGL double buffering */ if ( SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ) ) *************** *** 1447,1450 **** --- 1450,1455 ---- } + open_gl_check_error_status ( ); + //-------------------- // First we check to see if the mode we wish to set is really supported. If it *************** *** 1460,1475 **** break; default: if ( video_mode_ok_check_result == vid_bpp ) { ! DebugPrintf ( -4 , "\nVideo mode requested seems to be available in this color depth..." ); } else { ! DebugPrintf ( -4 , "\nTesting if color depth %d bits is available... " , vid_bpp ); ! DebugPrintf ( -4 , "\nThe closest we will get is %d bits per pixel." , video_mode_ok_check_result ); GiveStandardErrorMessage ( "InitVideo(...)" , "\ SDL reported, that the video mode mentioned \nabove is not supported UNDER THE COLOR DEPTH MENTIONED ABOVE!\n\ We'll be using the alternate color depth given above instead...", PLEASE_INFORM, IS_WARNING_ONLY ); vid_bpp = video_mode_ok_check_result ; } --- 1465,1482 ---- break; default: + DebugPrintf ( -4 , "\nTesting if color depth %d bits is available... " , vid_bpp ); if ( video_mode_ok_check_result == vid_bpp ) { ! DebugPrintf ( -4 , "YES." ); } else { ! DebugPrintf ( -4 , "NO! \nThe closest we will get is %d bits per pixel." , video_mode_ok_check_result ); ! /* GiveStandardErrorMessage ( "InitVideo(...)" , "\ SDL reported, that the video mode mentioned \nabove is not supported UNDER THE COLOR DEPTH MENTIONED ABOVE!\n\ We'll be using the alternate color depth given above instead...", PLEASE_INFORM, IS_WARNING_ONLY ); + */ vid_bpp = video_mode_ok_check_result ; } *************** *** 1487,1500 **** Terminate ( ERR ) ; } //-------------------- // Since we want to use openGl, it might be good to check the OpenGL vendor string // provided by the graphics driver. Let's see... // ! fprintf( stderr , "\nUse of OpenGL for graphics output has been requested.\nYour GL_VENDOR string seems to be: %s\n", glGetString( GL_VENDOR ) ); /* initialize OpenGL */ initGL( ); /* resize the initial window */ // resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT ); --- 1494,1527 ---- Terminate ( ERR ) ; } + else + { + SDL_GL_GetAttribute( SDL_GL_BUFFER_SIZE , & buffer_size); + SDL_GL_GetAttribute( SDL_GL_RED_SIZE , & red_size); + SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE , & green_size); + SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE , & blue_size); + SDL_GL_GetAttribute( SDL_GL_ALPHA_SIZE , & alpha_size); + SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE , & depth_size); + fprintf( stderr , "\n\nvideo mode set (bpp=%d RGBA=%d%d%d%d depth=%d)" , + buffer_size , red_size, green_size, blue_size, alpha_size, depth_size ); + } + open_gl_check_error_status ( ); + //-------------------- // Since we want to use openGl, it might be good to check the OpenGL vendor string // provided by the graphics driver. Let's see... // ! fprintf( stderr , "\n-OpenGL-------------------------------------------------------" ); ! fprintf( stderr , "\nVendor : %s", glGetString( GL_VENDOR ) ); ! fprintf( stderr , "\nRenderer : %s", glGetString( GL_RENDERER ) ); ! fprintf( stderr , "\nVersion : %s", glGetString( GL_VERSION ) ); ! // fprintf( stderr , "\nExtentions : %s", glGetString( GL_EXTENSIONS ) ); ! fprintf( stderr , "\n\n" ); /* initialize OpenGL */ initGL( ); + open_gl_check_error_status ( ); + /* resize the initial window */ // resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT ); *************** *** 1531,1535 **** if ( vid_info->wm_available ) /* if there's a window-manager */ { ! SDL_WM_SetCaption ("Freedroid", ""); fpath = find_file (ICON_FILE, GRAPHICS_DIR, FALSE); SDL_WM_SetIcon( our_IMG_load_wrapper (fpath), NULL); --- 1558,1562 ---- if ( vid_info->wm_available ) /* if there's a window-manager */ { ! SDL_WM_SetCaption ("FreedroidRPG", ""); fpath = find_file (ICON_FILE, GRAPHICS_DIR, FALSE); SDL_WM_SetIcon( our_IMG_load_wrapper (fpath), NULL); Index: open_gl.c =================================================================== RCS file: /cvsroot/freedroid/FreeDroid/src/open_gl.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** open_gl.c 31 Oct 2003 17:20:13 -0000 1.30 --- open_gl.c 31 Oct 2003 18:54:07 -0000 1.31 *************** *** 520,523 **** --- 520,578 ---- /* ---------------------------------------------------------------------- + * This function checks the error status of the OpenGL driver. An error + * will produce at least a warning message, maybe even program termination + * if the errors are really severe. + * ---------------------------------------------------------------------- */ + void + open_gl_check_error_status ( void ) + { + #ifdef HAVE_LIBGL + + switch ( glGetError( ) ) + { + case GL_NO_ERROR: + //-------------------- + // All is well. No messages need to be generated... + break; + case GL_INVALID_ENUM: + GiveStandardErrorMessage ( "open_gl_check_error_status(...)" , "\ + Error code GL_INVALID_ENUM received!", + PLEASE_INFORM, IS_FATAL ); + break; + case GL_INVALID_VALUE: + GiveStandardErrorMessage ( "open_gl_check_error_status(...)" , "\ + Error code GL_INVALID_VALUE received!", + PLEASE_INFORM, IS_FATAL ); + break; + case GL_INVALID_OPERATION: + GiveStandardErrorMessage ( "open_gl_check_error_status(...)" , "\ + Error code GL_INVALID_OPERATION received!", + PLEASE_INFORM, IS_FATAL ); + break; + case GL_STACK_OVERFLOW: + GiveStandardErrorMessage ( "open_gl_check_error_status(...)" , "\ + Error code GL_STACK_OVERFLOW received!", + PLEASE_INFORM, IS_FATAL ); + break; + case GL_STACK_UNDERFLOW: + GiveStandardErrorMessage ( "open_gl_check_error_status(...)" , "\ + Error code GL_STACK_UNDERFLOW received!", + PLEASE_INFORM, IS_FATAL ); + break; + case GL_OUT_OF_MEMORY: + GiveStandardErrorMessage ( "open_gl_check_error_status(...)" , "\ + Error code GL_OUT_OF_MEMORY received!", + PLEASE_INFORM, IS_FATAL ); + break; + default: + GiveStandardErrorMessage ( "open_gl_check_error_status(...)" , "\ + Unhandled error code received!", + PLEASE_INFORM, IS_FATAL ); + break; + } + #endif + }; + + /* ---------------------------------------------------------------------- * Initialize the OpenGL interface. * ---------------------------------------------------------------------- */ Index: proto.h =================================================================== RCS file: /cvsroot/freedroid/FreeDroid/src/proto.h,v retrieving revision 1.369 retrieving revision 1.370 diff -C2 -d -r1.369 -r1.370 *** proto.h 31 Oct 2003 17:20:13 -0000 1.369 --- proto.h 31 Oct 2003 18:54:07 -0000 1.370 *************** *** 168,171 **** --- 168,172 ---- EXTERN void blit_open_gl_texture_to_screen_position ( iso_image our_floor_iso_image , int x , int y , int set_gl_parameters ) ; EXTERN void blit_special_background ( int background_code ); + EXTERN void open_gl_check_error_status ( void ); // blocks.c |