//-------------------------------------------------------------------------------------------- SDL_bool SDLX_ExpandFormat( SDL_PixelFormat * pformat ) { // use the basic screen format to create a surface with proper alpha support Uint8 i; if ( NULL == pformat ) return SDL_FALSE; if ( pformat->BitsPerPixel > 24 ) { pformat->Amask = amask; pformat->Bmask = bmask; pformat->Gmask = gmask; pformat->Rmask = rmask; for ( i = 0; i < sdl_scr.d && HAS_NO_BITS( pformat->Amask, 1 << i ); i++ ); if ( HAS_NO_BITS( pformat->Amask, 1 << i ) ) { // no alpha bits available pformat->Ashift = 0; pformat->Aloss = 8; } else { // normal alpha channel pformat->Ashift = i; pformat->Aloss = 0; } } return SDL_TRUE; }
//-------------------------------------------------------------------------------------------- SDL_bool SDLX_Get_Screen_Info( SDLX_screen_info_t * psi, SDL_bool make_report ) { Uint32 init_flags = 0; SDL_Surface * ps; const SDL_VideoInfo * pvi; memset( psi, 0, sizeof( *psi ) ); init_flags = SDL_WasInit( SDL_INIT_EVERYTHING ); if ( 0 == init_flags ) { if ( make_report ) fprintf( LOCAL_STDOUT, "ERROR: SDLX_Get_Screen_Info() called before initializing SDL\n" ); return SDL_FALSE; } else if ( HAS_NO_BITS( init_flags, SDL_INIT_VIDEO ) ) { if ( make_report ) fprintf( LOCAL_STDOUT, "ERROR: SDLX_Get_Screen_Info() called before initializing SDL video driver\n" ); return SDL_FALSE; } ps = SDL_GetVideoSurface(); pvi = SDL_GetVideoInfo(); // store the screen info for everyone to use psi->pscreen = ps; psi->d = ps->format->BitsPerPixel; psi->x = ps->w; psi->y = ps->h; // Grab all the available video modes psi->video_mode_list = SDL_ListModes( ps->format, ps->flags | SDL_FULLSCREEN ); // log the video driver info SDL_VideoDriverName( psi->szDriver, sizeof( psi->szDriver ) ); // grab all SDL_GL_* attributes SDLX_read_sdl_gl_attrib( &( psi->gl_att ) ); // translate the surface flags into the bitfield SDLX_download_sdl_video_flags( ps->flags, &( psi->flags ) ); psi->hw_available = pvi->hw_available; psi->wm_available = pvi->wm_available; psi->blit_hw = pvi->blit_hw; psi->blit_hw_CC = pvi->blit_hw_CC; psi->blit_hw_A = pvi->blit_hw_A; psi->blit_sw = pvi->blit_sw; psi->blit_sw_CC = pvi->blit_sw_CC; psi->blit_sw_A = pvi->blit_sw_A; if ( make_report ) SDLX_Report_Screen_Info( psi ); return SDL_TRUE; }
//-------------------------------------------------------------------------------------------- bool SDLX_Get_Screen_Info( SDLX_screen_info_t& psi, bool make_report ) { Uint32 init_flags = 0; SDL_Window *window; init_flags = SDL_WasInit( SDL_INIT_EVERYTHING ); if ( 0 == init_flags ) { if ( make_report ) Log::get().message("ERROR: SDLX_Get_Screen_Info() called before initializing SDL\n"); return false; } else if ( HAS_NO_BITS( init_flags, SDL_INIT_VIDEO ) ) { if ( make_report ) Log::get().message("ERROR: SDLX_Get_Screen_Info() called before initializing SDL video driver\n"); return false; } // store the screen info for everyone to use window = Ego::GraphicsSystem::window; psi.window = window; SDL_GetWindowSize(window, &(psi.x), &(psi.y)); SDLX_GetDrawableSize(window, &(psi.drawWidth), &(psi.drawHeight)); // Grab all the available video modes psi.video_mode_list.clear(); int displayNum = SDL_GetWindowDisplayIndex(window); int numDisplayModes = SDL_GetNumDisplayModes(displayNum); for (int i = 0; i < numDisplayModes; i++) { SDL_DisplayMode mode; SDL_GetDisplayMode(displayNum, i, &mode); psi.video_mode_list.push_back(mode); } // log the video driver info psi.szDriver = SDL_GetCurrentVideoDriver(); // grab all SDL_GL_* attributes SDLX_sdl_gl_attrib_t::download(psi.gl_att); // translate the surface flags into the bitfield SDLX_sdl_video_flags_t::download(psi.flags, SDL_GetWindowFlags(window)); if (make_report) { SDLX_screen_info_t::report(psi); } return true; }
//-------------------------------------------------------------------------------------------- bool BIT_FIELD_has_no_bits( BIT_FIELD val, BIT_FIELD test ) { return HAS_NO_BITS( val, test ); }