bool COpenGL::resizeDisplayScreen(const GsRect<Uint16>& newDim) { // NOTE: try not to free the last SDL_Surface of the screen, this is freed automatically by SDL const int w = m_VidConfig.mAspectCorrection.w; const int h = m_VidConfig.mAspectCorrection.h; // Render a black surface which cleans the screen, in case there already is some content in the screen if(mpScreenSfc->empty()) { clearSurfaces(); transformScreenToDisplay(); } #if SDL_VERSION_ATLEAST(2, 0, 0) updateAspectRect(newDim, w, h); setUpViewPort(mAspectCorrectionRect); #else mDisplaySfc.setPtr(SDL_SetVideoMode( newDim.w, newDim.h, 32, m_Mode )); if (mDisplaySfc.empty()) { gLogging.textOut(RED,"VidDrv_Start(): Couldn't create a SDL surface: %s<br>", SDL_GetError()); return false; } updateAspectRect(newDim, w, h); setUpViewPort(mAspectCorrectionRect); #endif return true; }
bool CSDLVideo::resizeDisplayScreen(const GsRect<Uint16>& newDim) { //const int w = m_VidConfig.mAspectCorrection.w; //const int h = m_VidConfig.mAspectCorrection.h; const int w = 0; const int h = 0; updateAspectRect(newDim, w, h); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_RenderSetLogicalSize(renderer, mAspectCorrectionRect.w, mAspectCorrectionRect.h); #endif return true; }
bool CSDLVideo::resizeDisplayScreen(const GsRect<Uint16>& newDim) { const int w = m_VidConfig.mAspectCorrection.w; const int h = m_VidConfig.mAspectCorrection.h; updateAspectRect(newDim, w, h); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_RenderSetLogicalSize(renderer, mAspectCorrectionRect.w, mAspectCorrectionRect.h); #else mDisplaySfc.setPtr(SDL_SetVideoMode( mAspectCorrectionRect.w, mAspectCorrectionRect.h, 32, m_Mode )); #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; }