bool CVideoEngine::init() { const CRect &Res = m_VidConfig.m_DisplayRect; const CRect &GameRect = m_VidConfig.m_GameRect; // Setup mode depends on some systems. #if defined(CAANOO) || defined(WIZ) || defined(DINGOO) || defined(NANONOTE) || defined(ANDROID) m_Mode = SDL_SWSURFACE; #elif defined(GP2X) m_Mode = SDL_DOUBLEBUF | SDL_HWSURFACE; #else // Support for double-buffering m_Mode = SDL_DOUBLEBUF | SDL_HWPALETTE | SDL_HWSURFACE; #endif // Enable OpenGL #ifdef USE_OPENGL if(m_VidConfig.m_opengl) { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); #if SDL_VERSION_ATLEAST(1, 3, 0) #else SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); #endif m_Mode |= SDL_OPENGL; } #endif // Now we decide if it will be fullscreen or windowed mode. if(m_VidConfig.Fullscreen) { m_Mode |= SDL_FULLSCREEN; } else { m_Mode |= SDL_RESIZABLE; } // And set the proper Display Dimensions // The screen is also setup in this function if(!resizeDisplayScreen(Res)) return false; // If Fullscreen hide the mouse cursor. // Anyway, it just can point but does not interact yet SDL_ShowCursor(!m_VidConfig.Fullscreen); m_src_slice = GameRect.w*screen->format->BytesPerPixel; return true; }
bool CVideoEngine::init() { // Setup mode depends on some systems. #if defined(CAANOO) || defined(WIZ) || defined(DINGOO) || defined(NANONOTE) || defined(ANDROID) || defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) m_Mode = SDL_SWSURFACE; #elif defined(GP2X) m_Mode = SDL_HWSURFACE; #else // Support for double-buffering #if !SDL_VERSION_ATLEAST(2, 0, 0) m_Mode = SDL_HWPALETTE; #endif #endif // Enable OpenGL #ifdef USE_OPENGL if(m_VidConfig.m_opengl) { if(m_VidConfig.vsync) { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); #if SDL_VERSION_ATLEAST(2, 0, 0) #else SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); #endif } #if SDL_VERSION_ATLEAST(2, 0, 0) #else m_Mode |= SDL_OPENGL; #endif } else #endif { if(m_VidConfig.vsync) { #if SDL_VERSION_ATLEAST(2, 0, 0) #else m_Mode |= (SDL_DOUBLEBUF | SDL_HWSURFACE); #endif } } // Now we decide if it will be fullscreen or windowed mode. #if SDL_VERSION_ATLEAST(2, 0, 0) #else if(m_VidConfig.Fullscreen) m_Mode |= SDL_FULLSCREEN; else m_Mode |= SDL_RESIZABLE; #endif // And set the proper Display Dimensions // The screen is also setup in this function if( !resizeDisplayScreen(m_VidConfig.m_DisplayRect) ) { return false; } #ifdef _WIN32 // So far this only works under windows else { SDL_SysWMinfo info; SDL_VERSION(&info.version); #if SDL_VERSION_ATLEAST(2, 0, 0) int ok = SDL_GetWindowWMInfo(window,&info); #else int ok = SDL_GetWMInfo(&info); #endif if( ok ) { if(ok > 0) { #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_ShowWindow(window); #else ShowWindow(info.window, SW_SHOWNORMAL); #endif } } } #endif return true; }
bool CSDLVideo::init() { if(!CVideoEngine::init()) return false; #if SDL_VERSION_ATLEAST(2, 0, 0) // NOTE: try not to free the last SDL_Surface of the screen, this is freed automatically by SDL const int aspW = m_VidConfig.mAspectCorrection.w; const int aspH = m_VidConfig.mAspectCorrection.h; if(window) { SDL_DestroyWindow(window); } window = SDL_CreateWindow("Commander Genius", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_VidConfig.m_DisplayRect.w, m_VidConfig.m_DisplayRect.h, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); if(renderer) { SDL_DestroyRenderer(renderer); } renderer = SDL_CreateRenderer(window, -1, 0); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); SDL_RenderPresent(renderer); updateAspectRect(m_VidConfig.m_DisplayRect, aspW, aspH); //SDL_RenderSetLogicalSize(renderer, m_VidConfig.m_DisplayRect.w, m_VidConfig.m_DisplayRect.h); resizeDisplayScreen(m_VidConfig.m_DisplayRect); #else mDisplaySfc = SDL_SetVideoMode( m_VidConfig.m_DisplayRect.w, m_VidConfig.m_DisplayRect.h, 32, m_Mode ); if (!mDisplaySfc) { gLogging.textOut(RED,"VidDrv_Start(): Couldn't create a SDL surface: %s<br>", SDL_GetError()); return false; } const GsRect<Uint16> &GameRect = m_VidConfig.m_GameRect; m_src_slice = GameRect.w*mDisplaySfc->format->BytesPerPixel; /*aspectCorrectResizing(newDim, w, h); if(FilteredSurface) { Scaler.setDynamicFactor( float(FilteredSurface->w)/float(aspectCorrectionRect.w), float(FilteredSurface->h)/float(aspectCorrectionRect.h)); }*/ #endif return true; }
bool CSDLVideo::init() { if(!CVideoEngine::init()) return false; #if SDL_VERSION_ATLEAST(2, 0, 0) if(m_VidConfig.mRenderScQuality == "linear") SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); else SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); const int aspW = m_VidConfig.mAspectCorrection.w; const int aspH = m_VidConfig.mAspectCorrection.h; if(window) { SDL_DestroyWindow(window); } Uint32 flags = 0; if(m_VidConfig.Fullscreen) flags |= SDL_WINDOW_FULLSCREEN; else flags |= (SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); window = SDL_CreateWindow("Commander Genius", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_VidConfig.m_DisplayRect.w, m_VidConfig.m_DisplayRect.h, flags); if(renderer) { SDL_DestroyRenderer(renderer); } renderer = SDL_CreateRenderer(window, -1, 0); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); SDL_RenderPresent(renderer); updateAspectRect(m_VidConfig.m_DisplayRect, aspW, aspH); resizeDisplayScreen(m_VidConfig.m_DisplayRect); #else mDisplaySfc.setPtr(SDL_SetVideoMode( m_VidConfig.m_DisplayRect.w, m_VidConfig.m_DisplayRect.h, 32, m_Mode )); if (mDisplaySfc.empty()) { gLogging.textOut(RED,"VidDrv_Start(): Couldn't create a SDL surface: %s<br>", SDL_GetError()); return false; } #endif return true; }