int SDLHardwareRenderDevice::createContext() { bool settings_changed = (fullscreen != FULLSCREEN || hwsurface != HWSURFACE || vsync != VSYNC || texture_filter != TEXTURE_FILTER); Uint32 w_flags = 0; Uint32 r_flags = 0; int window_w = SCREEN_W; int window_h = SCREEN_H; if (FULLSCREEN) { w_flags = w_flags | SDL_WINDOW_FULLSCREEN_DESKTOP; // make the window the same size as the desktop resolution SDL_DisplayMode desktop; if (SDL_GetDesktopDisplayMode(0, &desktop) == 0) { window_w = desktop.w; window_h = desktop.h; } } else if (fullscreen && is_initialized) { // if the game was previously in fullscreen, resize the window when returning to windowed mode window_w = MIN_SCREEN_W; window_h = MIN_SCREEN_H; w_flags = w_flags | SDL_WINDOW_SHOWN; } else { w_flags = w_flags | SDL_WINDOW_SHOWN; } w_flags = w_flags | SDL_WINDOW_RESIZABLE; if (HWSURFACE) { r_flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE; } else { r_flags = SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE; VSYNC = false; // can't have software mode & vsync at the same time } if (VSYNC) r_flags = r_flags | SDL_RENDERER_PRESENTVSYNC; if (settings_changed || !is_initialized) { if (is_initialized) { destroyContext(); } window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, window_w, window_h, w_flags); if (window) { renderer = SDL_CreateRenderer(window, -1, r_flags); if (renderer) { if (TEXTURE_FILTER && !IGNORE_TEXTURE_FILTER) SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); else SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); windowResize(); } SDL_SetWindowMinimumSize(window, MIN_SCREEN_W, MIN_SCREEN_H); // setting minimum size might move the window, so set position again SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } bool window_created = window != NULL && renderer != NULL; if (!window_created) { // try previous setting first FULLSCREEN = fullscreen; HWSURFACE = hwsurface; VSYNC = vsync; TEXTURE_FILTER = texture_filter; if (createContext() == -1) { // last resort, try turning everything off FULLSCREEN = false; HWSURFACE = false; VSYNC = false; TEXTURE_FILTER = false; int last_resort = createContext(); if (last_resort == -1 && !is_initialized) { // If this is the first attempt and it failed we are not // getting anywhere. logError("SDLHardwareRenderDevice: createContext() failed: %s", SDL_GetError()); Exit(1); } return last_resort; } else { return 0; } } else { fullscreen = FULLSCREEN; hwsurface = HWSURFACE; vsync = VSYNC; texture_filter = TEXTURE_FILTER; is_initialized = true; } } if (is_initialized) { // update minimum window size if it has changed if (min_screen.x != MIN_SCREEN_W || min_screen.y != MIN_SCREEN_H) { min_screen.x = MIN_SCREEN_W; min_screen.y = MIN_SCREEN_H; SDL_SetWindowMinimumSize(window, MIN_SCREEN_W, MIN_SCREEN_H); SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } windowResize(); // update title bar text and icon updateTitleBar(); // load persistent resources SharedResources::loadIcons(); delete curs; curs = new CursorManager(); } return (is_initialized ? 0 : -1); }
/** * @return whether setting the video mode was successful * * Sets SDL video mode options/settings */ bool SpringApp::CreateSDLWindow(const char* title) { int sdlflags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; // use standard: 24bit color + 24bit depth + 8bit stencil & doublebuffered SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); // Create GL debug context when wanted (allows further GL verbose informations, but runs slower) if (configHandler->GetBool("DebugGL")) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); } // FullScreen AntiAliasing globalRendering->FSAA = configHandler->GetInt("FSAALevel"); if (globalRendering->FSAA > 0) { if (getenv("LIBGL_ALWAYS_SOFTWARE") != NULL) { LOG_L(L_WARNING, "FSAALevel > 0 and LIBGL_ALWAYS_SOFTWARE set, this will very likely crash!"); } make_even_number(globalRendering->FSAA); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, globalRendering->FSAA); } // Get wanted resolution int2 res = globalRendering->GetWantedViewSize(globalRendering->fullScreen); // Borderless const bool borderless = configHandler->GetBool("WindowBorderless"); if (globalRendering->fullScreen) { sdlflags |= borderless ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN; } sdlflags |= borderless ? SDL_WINDOW_BORDERLESS : 0; #if defined(WIN32) if (borderless && !globalRendering->fullScreen) { sdlflags &= ~SDL_WINDOW_RESIZABLE; } #endif // Window Pos & State globalRendering->winPosX = configHandler->GetInt("WindowPosX"); globalRendering->winPosY = configHandler->GetInt("WindowPosY"); globalRendering->winState = configHandler->GetInt("WindowState"); switch (globalRendering->winState) { case CGlobalRendering::WINSTATE_MAXIMIZED: sdlflags |= SDL_WINDOW_MAXIMIZED; break; case CGlobalRendering::WINSTATE_MINIMIZED: sdlflags |= SDL_WINDOW_MINIMIZED; break; } // Create Window window = SDL_CreateWindow(title, globalRendering->winPosX, globalRendering->winPosY, res.x, res.y, sdlflags); if (!window) { char buf[1024]; SNPRINTF(buf, sizeof(buf), "Could not set video mode:\n%s", SDL_GetError()); handleerror(NULL, buf, "ERROR", MBF_OK|MBF_EXCL); return false; } // Create GL Context SDL_SetWindowMinimumSize(window, globalRendering->minWinSizeX, globalRendering->minWinSizeY); sdlGlCtx = SDL_GL_CreateContext(window); globalRendering->window = window; #ifdef STREFLOP_H // Something in SDL_SetVideoMode (OpenGL drivers?) messes with the FPU control word. // Set single precision floating point math. streflop::streflop_init<streflop::Simple>(); #endif #if !defined(HEADLESS) // disable desktop compositing to fix tearing // (happens at 300fps, neither fullscreen nor vsync fixes it, so disable compositing) // On Windows Aero often uses vsync, and so when Spring runs windowed it will run with // vsync too, resulting in bad performance. if (configHandler->GetBool("BlockCompositing")) { WindowManagerHelper::BlockCompositing(window); } #endif return true; }
static void VID_SDL_Init(void) { SDL_Surface *icon_surface; extern void InitSig(void); SDL_DisplayMode display_mode; int flags; if (glConfig.initialized == true) return; flags = SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_SHOWN; #ifdef SDL_WINDOW_ALLOW_HIGHDPI flags |= SDL_WINDOW_ALLOW_HIGHDPI; #endif if (r_fullscreen.integer <= 0) { flags &= ~SDL_WINDOW_FULLSCREEN; if (vid_win_borderless.integer <= 0) flags &= ~SDL_WINDOW_BORDERLESS; } #if defined(__linux__) InitSig(); #endif VID_SDL_InitSubSystem(); VID_SDL_GL_SetupAttributes(); VID_SetupResolution(); sdl_window = SDL_CreateWindow(WINDOW_CLASS_NAME, vid_xpos.integer, vid_ypos.integer, glConfig.vidWidth, glConfig.vidHeight, flags); icon_surface = SDL_CreateRGBSurfaceFrom((void *)ezquake_icon.pixel_data, ezquake_icon.width, ezquake_icon.height, ezquake_icon.bytes_per_pixel * 8, ezquake_icon.width * ezquake_icon.bytes_per_pixel, 0x000000FF,0x0000FF00,0x00FF0000,0xFF000000); if (icon_surface) { SDL_SetWindowIcon(sdl_window, icon_surface); SDL_FreeSurface(icon_surface); } SDL_SetWindowMinimumSize(sdl_window, 320, 240); sdl_context = SDL_GL_CreateContext(sdl_window); if (!sdl_context) { Com_Printf("Couldn't create OpenGL context: %s\n", SDL_GetError()); return; } r_swapInterval.modified = true; if (!SDL_GetWindowDisplayMode(sdl_window, &display_mode)) glConfig.displayFrequency = display_mode.refresh_rate; else glConfig.displayFrequency = 0; glConfig.colorBits = 24; // FIXME SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &glConfig.depthBits); SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &glConfig.stencilBits); glConfig.vendor_string = glGetString(GL_VENDOR); glConfig.renderer_string = glGetString(GL_RENDERER); glConfig.version_string = glGetString(GL_VERSION); glConfig.extensions_string = glGetString(GL_EXTENSIONS); glConfig.initialized = true; #if defined(__linux__) InitSig(); // not clear why this is at begin & end of function #endif }
int SDLHardwareRenderDevice::createContextInternal() { bool settings_changed = (fullscreen != settings->fullscreen || hwsurface != settings->hwsurface || vsync != settings->vsync || texture_filter != settings->texture_filter || ignore_texture_filter != eset->resolutions.ignore_texture_filter); Uint32 w_flags = 0; Uint32 r_flags = 0; int window_w = settings->screen_w; int window_h = settings->screen_h; if (settings->fullscreen) { w_flags = w_flags | SDL_WINDOW_FULLSCREEN_DESKTOP; // make the window the same size as the desktop resolution SDL_DisplayMode desktop; if (SDL_GetDesktopDisplayMode(0, &desktop) == 0) { window_w = desktop.w; window_h = desktop.h; } } else if (fullscreen && is_initialized) { // if the game was previously in fullscreen, resize the window when returning to windowed mode window_w = eset->resolutions.min_screen_w; window_h = eset->resolutions.min_screen_h; w_flags = w_flags | SDL_WINDOW_SHOWN; } else { w_flags = w_flags | SDL_WINDOW_SHOWN; } w_flags = w_flags | SDL_WINDOW_RESIZABLE; if (settings->hwsurface) { r_flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE; } else { r_flags = SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE; settings->vsync = false; // can't have software mode & vsync at the same time } if (settings->vsync) r_flags = r_flags | SDL_RENDERER_PRESENTVSYNC; if (settings_changed || !is_initialized) { destroyContext(); window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, window_w, window_h, w_flags); if (window) { renderer = SDL_CreateRenderer(window, -1, r_flags); if (renderer) { if (settings->texture_filter && !eset->resolutions.ignore_texture_filter) SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); else SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0"); windowResize(); } SDL_SetWindowMinimumSize(window, eset->resolutions.min_screen_w, eset->resolutions.min_screen_h); // setting minimum size might move the window, so set position again SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } if (window && renderer) { if (!is_initialized) { // save the system gamma levels if we just created the window SDL_GetWindowGammaRamp(window, gamma_r, gamma_g, gamma_b); Utils::logInfo("RenderDevice: Window size is %dx%d", settings->screen_w, settings->screen_h); } fullscreen = settings->fullscreen; hwsurface = settings->hwsurface; vsync = settings->vsync; texture_filter = settings->texture_filter; ignore_texture_filter = eset->resolutions.ignore_texture_filter; is_initialized = true; Utils::logInfo("RenderDevice: Fullscreen=%d, Hardware surfaces=%d, Vsync=%d, Texture Filter=%d", fullscreen, hwsurface, vsync, texture_filter); #if SDL_VERSION_ATLEAST(2, 0, 4) SDL_GetDisplayDPI(0, &ddpi, 0, 0); Utils::logInfo("RenderDevice: Display DPI is %f", ddpi); #else Utils::logError("RenderDevice: The SDL version used to compile Flare does not support SDL_GetDisplayDPI(). The virtual_dpi setting will be ignored."); #endif } } if (is_initialized) { // update minimum window size if it has changed if (min_screen.x != eset->resolutions.min_screen_w || min_screen.y != eset->resolutions.min_screen_h) { min_screen.x = eset->resolutions.min_screen_w; min_screen.y = eset->resolutions.min_screen_h; SDL_SetWindowMinimumSize(window, eset->resolutions.min_screen_w, eset->resolutions.min_screen_h); SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } windowResize(); // update title bar text and icon updateTitleBar(); // load persistent resources delete icons; icons = new IconManager(); delete curs; curs = new CursorManager(); if (settings->change_gamma) setGamma(settings->gamma); else { resetGamma(); settings->change_gamma = false; settings->gamma = 1.0; } } return (is_initialized ? 0 : -1); }
bool Window::Create(){ logger << ( "[LOG] CREATING WINDOW:" ); if( SDL_WasInit( SDL_INIT_VIDEO ) == 0 ){ if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 ){ logger << ( "[ERROR] SDL_Init: " + string( SDL_GetError() ) ); this->Init = false; return false; } else{ logger << ( "[LOG] SDL_Init: SUCCESS" ); } } this->Id = SDL_CreateWindow( this->Title.c_str(), this->PositionX, this->PositionY, this->Width, this->Height, this->Flag ); if( this->Id == NULL ){ logger << ( "[ERROR] SDL_CreateWindow: " + string( SDL_GetError() ) ); this->Init = false; return false; } else{ logger << ( "[LOG] SDL_CreateWindow: SUCCESS" ); } SDL_Surface *surface = NULL; Uint16 pixels[16*16] = { 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xffff, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xffff, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xffff, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000, 0xf000 }; surface = SDL_CreateRGBSurfaceFrom( pixels, 16, 16, 16, 16*2, 0x0f00, 0x00f0, 0x000f, 0xf000 ); if( surface == NULL ){ logger << ( "[ERROR] SDL_SetWindowIcon: " + string( SDL_GetError() ) ); this->Init = false; return false; } else{ logger << ( "[LOG] SDL_SetWindowIcon: SUCCESS" ); SDL_SetWindowIcon( this->Id, surface ); SDL_FreeSurface( surface ); } this->GLContext = SDL_GL_CreateContext( this->Id ); if( this->GLContext == NULL ){ logger << ( "[ERROR] SDL_GL_CreateContext: " + string( SDL_GetError() ) ); this->Init = false; return false; } else{ logger << ( "[LOG] SDL_GL_CreateContext: SUCCESS" ); } logger << ( "[LOG] SDL_GetWindowDisplayIndex: " + to_string( SDL_GetWindowDisplayIndex( this->Id ) ) ); logger << ( "[LOG] SDL_GetWindowID: " + to_string( SDL_GetWindowID( this->Id ) ) ); logger << ( "[LOG] SDL_GetWindowBrightness: " + to_string( SDL_GetWindowBrightness( this->Id ) ) ); SDL_SetWindowMinimumSize( this->Id, this->WidthMin, this->HeightMin ); SDL_SetWindowMaximumSize( this->Id, this->WidthMax, this->HeightMax ); Window::SetMaxMinResolution( this->Id, this->WidthMin, this->HeightMin, this->WidthMax, this->HeightMax ); logger << ( "[LOG] CREATED WINDOW" ); this->Init = true; return this->Init; }
bool Window::setWindow(int width, int height, WindowSettings *settings) { if (!graphics.get()) graphics.set(Module::getInstance<graphics::Graphics>(Module::M_GRAPHICS)); if (graphics.get() && graphics->isCanvasActive()) throw love::Exception("love.window.setMode cannot be called while a Canvas is active in love.graphics."); WindowSettings f; if (settings) f = *settings; f.minwidth = std::max(f.minwidth, 1); f.minheight = std::max(f.minheight, 1); f.display = std::min(std::max(f.display, 0), getDisplayCount() - 1); // Use the desktop resolution if a width or height of 0 is specified. if (width == 0 || height == 0) { SDL_DisplayMode mode = {}; SDL_GetDesktopDisplayMode(f.display, &mode); width = mode.w; height = mode.h; } Uint32 sdlflags = SDL_WINDOW_OPENGL; // On Android we always must have fullscreen type FULLSCREEN_TYPE_DESKTOP #ifdef LOVE_ANDROID f.fstype = FULLSCREEN_DESKTOP; #endif if (f.fullscreen) { if (f.fstype == FULLSCREEN_DESKTOP) sdlflags |= SDL_WINDOW_FULLSCREEN_DESKTOP; else { sdlflags |= SDL_WINDOW_FULLSCREEN; SDL_DisplayMode mode = {0, width, height, 0, nullptr}; // Fullscreen window creation will bug out if no mode can be used. if (SDL_GetClosestDisplayMode(f.display, &mode, &mode) == nullptr) { // GetClosestDisplayMode will fail if we request a size larger // than the largest available display mode, so we'll try to use // the largest (first) mode in that case. if (SDL_GetDisplayMode(f.display, 0, &mode) < 0) return false; } width = mode.w; height = mode.h; } } if (f.resizable) sdlflags |= SDL_WINDOW_RESIZABLE; if (f.borderless) sdlflags |= SDL_WINDOW_BORDERLESS; if (f.highdpi) sdlflags |= SDL_WINDOW_ALLOW_HIGHDPI; int x = f.x; int y = f.y; if (f.useposition && !f.fullscreen) { // The position needs to be in the global coordinate space. SDL_Rect displaybounds = {}; SDL_GetDisplayBounds(f.display, &displaybounds); x += displaybounds.x; y += displaybounds.y; } else { if (f.centered) x = y = SDL_WINDOWPOS_CENTERED_DISPLAY(f.display); else x = y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(f.display); } close(); if (!createWindowAndContext(x, y, width, height, sdlflags, f.msaa, f.stencil, f.depth)) return false; // Make sure the window keeps any previously set icon. setIcon(icon.get()); // Make sure the mouse keeps its previous grab setting. setMouseGrab(mouseGrabbed); // Enforce minimum window dimensions. SDL_SetWindowMinimumSize(window, f.minwidth, f.minheight); if ((f.useposition || f.centered) && !f.fullscreen) SDL_SetWindowPosition(window, x, y); SDL_RaiseWindow(window); SDL_GL_SetSwapInterval(f.vsync); // Check if adaptive vsync was requested but not supported, and fall back // to regular vsync if so. if (f.vsync == -1 && SDL_GL_GetSwapInterval() != -1) SDL_GL_SetSwapInterval(1); updateSettings(f, false); if (graphics.get()) { double scaledw, scaledh; fromPixels((double) pixelWidth, (double) pixelHeight, scaledw, scaledh); graphics->setMode((int) scaledw, (int) scaledh, pixelWidth, pixelHeight, f.stencil); } #ifdef LOVE_ANDROID love::android::setImmersive(f.fullscreen); #endif return true; }
void Engine_SetMinimumWindowSize(int width, int height) { SDL_SetWindowMinimumSize(window, width, height); }
void ZWindow::SetMinimumSize(SIZE sz) { SDL_SetWindowMinimumSize(m_win,sz.cx,sz.cy); }
void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest( const std::pair<unsigned, unsigned>& minimal_size) { SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second); }
void BasicWindow::MinSize(int w, int h) { SDL_SetWindowMinimumSize(window, w, h); }
void minimum_size(int width, int height) noexcept { SDL_SetWindowMinimumSize(ptr.get(), width, height); }
static void SetVideoMode(void) { int w, h; int x, y; unsigned int rmask, gmask, bmask, amask; int unused_bpp; int window_flags = 0, renderer_flags = 0; SDL_DisplayMode mode; w = window_width; h = window_height; // In windowed mode, the window can be resized while the game is // running. window_flags = SDL_WINDOW_RESIZABLE; // Set the highdpi flag - this makes a big difference on Macs with // retina displays, especially when using small window sizes. window_flags |= SDL_WINDOW_ALLOW_HIGHDPI; if (fullscreen) { if (fullscreen_width == 0 && fullscreen_height == 0) { // This window_flags means "Never change the screen resolution! // Instead, draw to the entire screen by scaling the texture // appropriately". window_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; } else { w = fullscreen_width; h = fullscreen_height; window_flags |= SDL_WINDOW_FULLSCREEN; } } // Running without window decorations is potentially useful if you're // playing in three window mode and want to line up three game windows // next to each other on a single desktop. // Deliberately not documented because I'm not sure how useful this is yet. if (M_ParmExists("-borderless")) { window_flags |= SDL_WINDOW_BORDERLESS; } I_GetWindowPosition(&x, &y, w, h); // Create window and renderer contexts. We set the window title // later anyway and leave the window position "undefined". If // "window_flags" contains the fullscreen flag (see above), then // w and h are ignored. if (screen == NULL) { screen = SDL_CreateWindow(NULL, x, y, w, h, window_flags); if (screen == NULL) { I_Error("Error creating window for video startup: %s", SDL_GetError()); } pixel_format = SDL_GetWindowPixelFormat(screen); SDL_SetWindowMinimumSize(screen, SCREENWIDTH, actualheight); I_InitWindowTitle(); I_InitWindowIcon(); } // The SDL_RENDERER_TARGETTEXTURE flag is required to render the // intermediate texture into the upscaled texture. renderer_flags = SDL_RENDERER_TARGETTEXTURE; if (SDL_GetCurrentDisplayMode(video_display, &mode) != 0) { I_Error("Could not get display mode for video display #%d: %s", video_display, SDL_GetError()); } // Turn on vsync if we aren't in a -timedemo if (!singletics && mode.refresh_rate > 0) { renderer_flags |= SDL_RENDERER_PRESENTVSYNC; } if (force_software_renderer) { renderer_flags |= SDL_RENDERER_SOFTWARE; renderer_flags &= ~SDL_RENDERER_PRESENTVSYNC; } if (renderer != NULL) { SDL_DestroyRenderer(renderer); // all associated textures get destroyed texture = NULL; texture_upscaled = NULL; } renderer = SDL_CreateRenderer(screen, -1, renderer_flags); if (renderer == NULL) { I_Error("Error creating renderer for screen window: %s", SDL_GetError()); } // Important: Set the "logical size" of the rendering context. At the same // time this also defines the aspect ratio that is preserved while scaling // and stretching the texture into the window. if (aspect_ratio_correct || integer_scaling) { SDL_RenderSetLogicalSize(renderer, SCREENWIDTH, actualheight); } // Force integer scales for resolution-independent rendering. #if SDL_VERSION_ATLEAST(2, 0, 5) SDL_RenderSetIntegerScale(renderer, integer_scaling); #endif // Blank out the full screen area in case there is any junk in // the borders that won't otherwise be overwritten. SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); SDL_RenderPresent(renderer); // Create the 8-bit paletted and the 32-bit RGBA screenbuffer surfaces. if (screenbuffer != NULL) { SDL_FreeSurface(screenbuffer); screenbuffer = NULL; } if (screenbuffer == NULL) { screenbuffer = SDL_CreateRGBSurface(0, SCREENWIDTH, SCREENHEIGHT, 8, 0, 0, 0, 0); SDL_FillRect(screenbuffer, NULL, 0); } // Format of argbbuffer must match the screen pixel format because we // import the surface data into the texture. if (argbbuffer != NULL) { SDL_FreeSurface(argbbuffer); argbbuffer = NULL; } if (argbbuffer == NULL) { SDL_PixelFormatEnumToMasks(pixel_format, &unused_bpp, &rmask, &gmask, &bmask, &amask); argbbuffer = SDL_CreateRGBSurface(0, SCREENWIDTH, SCREENHEIGHT, 32, rmask, gmask, bmask, amask); SDL_FillRect(argbbuffer, NULL, 0); } if (texture != NULL) { SDL_DestroyTexture(texture); } // Set the scaling quality for rendering the intermediate texture into // the upscaled texture to "nearest", which is gritty and pixelated and // resembles software scaling pretty well. SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"); // Create the intermediate texture that the RGBA surface gets loaded into. // The SDL_TEXTUREACCESS_STREAMING flag means that this texture's content // is going to change frequently. texture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, SCREENWIDTH, SCREENHEIGHT); // Initially create the upscaled texture for rendering to screen CreateUpscaledTexture(true); }
/** * @brief Initializes Game Window. * @param TITLE Set the title of the Window. * @param Background Set the background of the window. * @param SDL_SCREEN_FLAGS Start the window with given flags. * @return Returns 0 on success. */ int GameWindow::init( const char* TITLE , SDL_Color Background , int SDL_SCREEN_FLAGS ) { //If it already was inited, do not bother with it again if ( this->inited ) return 0; //Support for Resizeable windows //Check if the settings contain the option bool resizable; if ( this->content->Settings()->getBool ( "window" , "resizeable" , &resizable ) == true ) { //Evaluate if the option is set on if ( resizable ) { SDL_SCREEN_FLAGS |= SDL_WINDOW_RESIZABLE; } } //Support for fullscreen windows //Check if the settings contain the option bool fullscreen; if ( this->content->Settings()->getBool ( "window" , "fullscreen", &fullscreen ) == true ) { //Evaluate if the option is set on if ( fullscreen ) { SDL_SCREEN_FLAGS |= //Build option to use SDL_WINDOW_FULLSCREEN instead of DESKTOP #ifdef GAME_WINDOW_USE_WINDOW_FULLSCREEN SDL_WINDOW_FULLSCREEN; #else SDL_WINDOW_FULLSCREEN_DESKTOP; #endif } } int display = 0; this->content->Settings()->getInt ( "window" , "display" , &display ); //Set display to be rendered to SDL_DisplayMode display_mode; if ( SDL_GetDisplayMode( display , 0 , &display_mode ) != 0 ) { display = 0; std::cout << "An error has occurred" << std::endl << SDL_GetError() << std::endl; std::cout << "Defaulting to display index : " << display << std::endl; } int WIDTH = 800; if ( this->content->Settings()->getInt( "window" , "width" , &WIDTH ) == false ) { std::string native; if ( this->content->Settings()->get ( "window" , "width" , &native ) == true ) { if ( native == "native" ) { //Set height as native screen width SDL_DisplayMode dm; if ( SDL_GetDesktopDisplayMode( display , &dm ) == 0 ) { WIDTH = dm.w; } } } if ( WIDTH == 800 ) { std::cout << "Warning! Window width is set to default, 800px" << std::endl; } } int HIEGHT = 600; if ( this->content->Settings()->getInt( "window" , "height" , &HIEGHT ) == false ) { std::string native; if ( this->content->Settings()->get ( "window" , "height" , &native ) == true ) { if ( native == "native" ) { //Set height as native screen height SDL_DisplayMode dm; if ( SDL_GetDesktopDisplayMode( display , &dm ) == 0 ) { HIEGHT = dm.h; } } } if ( HIEGHT == 600 ) { std::cout << "Warning! Window height is set to default, 600px" << std::endl; } } //Create the window this->window = SDL_CreateWindow ( TITLE , SDL_WINDOWPOS_CENTERED_DISPLAY( display ) , SDL_WINDOWPOS_CENTERED_DISPLAY( display ) , WIDTH , HIEGHT , SDL_SCREEN_FLAGS ); //Set minimum size of window (640x480) SDL_SetWindowMinimumSize( this->window , 640, 480 ); SDL_SetWindowDisplayMode( this->window , &display_mode ); //Check if the window was created if ( this->window == nullptr ) { std::cout << "An error has occurred" << std::endl << SDL_GetError() << std::endl; std::cerr << SDL_GetError() << std::endl; return 1; } int render_flags = SDL_RENDERER_ACCELERATED; //Support for SDL_Render VSync //Check if the settings contain the option bool vsync; if ( this->content->Settings()->getBool ( "window" , "vsync" , &vsync ) ) { //Evaluate if the option is set on if ( vsync ) { //render_flags |= SDL_RENDERER_PRESENTVSYNC; this->CAP_FRAMES = true; } } int FRAME_LIMIT = display_mode.refresh_rate; if ( this->content->Settings()->getInt ( "window" , "framelimit" , &FRAME_LIMIT ) ) { std::cout << FRAME_LIMIT << std::endl; if ( FRAME_LIMIT > 0 ) { this->FRAME_LIMIT = FRAME_LIMIT; } else { std::cout << "Cannot set negative Frame Limit " << FRAME_LIMIT << std::endl; } } else { this->FRAME_LIMIT = FRAME_LIMIT; } bool windowborder = false; if ( this->content->Settings()->getBool ( "window" , "borderless" , &windowborder ) ) { if ( windowborder ) { SDL_SetWindowBordered( this->window , SDL_FALSE ); } } //Create Renderer this->renderer = SDL_CreateRenderer ( this->window , -1 , render_flags ); //Make sure it was created correctly if ( this->renderer == nullptr ) { std::cout << "An error has occurred" << std::endl << SDL_GetError() << std::endl; std::cerr << SDL_GetError() << std::endl; return 1; } //Set background colour this->background = Background; //Check if the System has a battery this->has_battery = etc::has_battery(); //Camera bnounds this->camera.setBounds( WIDTH , HIEGHT ); this->camera.setPosition( 0, 0 ); this->textures = graphics::TextureManager(this->renderer); this->content->Maps()->init(&(this->textures) , this->content->TileTypes()); this->content->load(); this->inited = true; //All done correctly return 0; }
void twindow::set_minimum_size(int min_w, int min_h) { SDL_SetWindowMinimumSize(window_, min_w, min_h); }
void window_init(void) { // SDL base stuff if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { error(1, SDL_GetError()); } if ((windowMain = SDL_CreateWindow("Engine", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, windowWidth, windowHeight, FLAGS)) == NULL) { error(1, SDL_GetError()); } SDL_SetWindowMinimumSize(windowMain, 100, 100); // Renderer stuff windowMainGLContext = SDL_GL_CreateContext(windowMain); // yes, it's openGL stuff int oglId = -1; int rdnum = SDL_GetNumRenderDrivers(); for (int i=0;i<rdnum;i++) { SDL_RendererInfo info; if (SDL_GetRenderDriverInfo(i, &info)) { continue; } if (!strcmp(info.name, "opengl")) { oglId = i; } } if (oglId == -1) { error(-1, "Cannot find the OpenGL renderer driver."); } if ((windowMainRenderer = SDL_CreateRenderer(windowMain, oglId, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC)) < 0) { error(1, SDL_GetError()); } // OpenGL stuff SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, true); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); if (SDL_GL_SetSwapInterval(17) < 0) { log_write(loggingLevel_warn, "Unable to setup VSync ! %s", SDL_GetError()); } glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(1.0f, 1.0f, 1.0f, 0.0f); glClearDepth(1.0f); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fov, (float)windowWidth/(float)windowHeight, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0, 0, windowWidth, windowHeight); if (glGetError() != GL_NO_ERROR) { error(glGetError(), "OpenGL error."); } log_write(loggingLevel_debug, "GL version: %s", glGetString(GL_VERSION)); log_write(loggingLevel_debug, "GL vendor: %s", glGetString(GL_VENDOR)); log_write(loggingLevel_debug, "GL renderer: %s", glGetString(GL_RENDERER)); log_write(loggingLevel_debug, "Video driver: %s", SDL_GetCurrentVideoDriver()); // nothing else to do }
SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state) { int i, j, m, n, w, h; SDL_DisplayMode fullscreen_mode; if (state->flags & SDL_INIT_VIDEO) { if (state->verbose & VERBOSE_VIDEO) { n = SDL_GetNumVideoDrivers(); if (n == 0) { fprintf(stderr, "No built-in video drivers\n"); } else { fprintf(stderr, "Built-in video drivers:"); for (i = 0; i < n; ++i) { if (i > 0) { fprintf(stderr, ","); } fprintf(stderr, " %s", SDL_GetVideoDriver(i)); } fprintf(stderr, "\n"); } } if (SDL_VideoInit(state->videodriver) < 0) { fprintf(stderr, "Couldn't initialize video driver: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->verbose & VERBOSE_VIDEO) { fprintf(stderr, "Video driver: %s\n", SDL_GetCurrentVideoDriver()); } /* Upload GL settings */ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, state->gl_red_size); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, state->gl_green_size); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, state->gl_blue_size); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, state->gl_alpha_size); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, state->gl_double_buffer); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, state->gl_buffer_size); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, state->gl_depth_size); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, state->gl_stencil_size); SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, state->gl_accum_red_size); SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, state->gl_accum_green_size); SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, state->gl_accum_blue_size); SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, state->gl_accum_alpha_size); SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples); if (state->gl_accelerated >= 0) { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, state->gl_accelerated); } SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing); if (state->gl_major_version) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version); } if (state->gl_debug) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); } if (state->gl_profile_mask) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, state->gl_profile_mask); } if (state->verbose & VERBOSE_MODES) { SDL_Rect bounds; SDL_DisplayMode mode; int bpp; Uint32 Rmask, Gmask, Bmask, Amask; #if SDL_VIDEO_DRIVER_WINDOWS int adapterIndex = 0; #endif n = SDL_GetNumVideoDisplays(); fprintf(stderr, "Number of displays: %d\n", n); for (i = 0; i < n; ++i) { fprintf(stderr, "Display %d: %s\n", i, SDL_GetDisplayName(i)); SDL_zero(bounds); SDL_GetDisplayBounds(i, &bounds); fprintf(stderr, "Bounds: %dx%d at %d,%d\n", bounds.w, bounds.h, bounds.x, bounds.y); SDL_GetDesktopDisplayMode(i, &mode); SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); fprintf(stderr, " Current mode: %dx%d@%dHz, %d bits-per-pixel (%s)\n", mode.w, mode.h, mode.refresh_rate, bpp, SDL_GetPixelFormatName(mode.format)); if (Rmask || Gmask || Bmask) { fprintf(stderr, " Red Mask = 0x%.8x\n", Rmask); fprintf(stderr, " Green Mask = 0x%.8x\n", Gmask); fprintf(stderr, " Blue Mask = 0x%.8x\n", Bmask); if (Amask) fprintf(stderr, " Alpha Mask = 0x%.8x\n", Amask); } /* Print available fullscreen video modes */ m = SDL_GetNumDisplayModes(i); if (m == 0) { fprintf(stderr, "No available fullscreen video modes\n"); } else { fprintf(stderr, " Fullscreen video modes:\n"); for (j = 0; j < m; ++j) { SDL_GetDisplayMode(i, j, &mode); SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); fprintf(stderr, " Mode %d: %dx%d@%dHz, %d bits-per-pixel (%s)\n", j, mode.w, mode.h, mode.refresh_rate, bpp, SDL_GetPixelFormatName(mode.format)); if (Rmask || Gmask || Bmask) { fprintf(stderr, " Red Mask = 0x%.8x\n", Rmask); fprintf(stderr, " Green Mask = 0x%.8x\n", Gmask); fprintf(stderr, " Blue Mask = 0x%.8x\n", Bmask); if (Amask) fprintf(stderr, " Alpha Mask = 0x%.8x\n", Amask); } } } #if SDL_VIDEO_DRIVER_WINDOWS /* Print the adapter index */ adapterIndex = SDL_Direct3D9GetAdapterIndex( i ); fprintf( stderr, "Adapter Index: %d", adapterIndex ); #endif } } if (state->verbose & VERBOSE_RENDER) { SDL_RendererInfo info; n = SDL_GetNumRenderDrivers(); if (n == 0) { fprintf(stderr, "No built-in render drivers\n"); } else { fprintf(stderr, "Built-in render drivers:\n"); for (i = 0; i < n; ++i) { SDL_GetRenderDriverInfo(i, &info); SDLTest_PrintRenderer(&info); } } } SDL_zero(fullscreen_mode); switch (state->depth) { case 8: fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8; break; case 15: fullscreen_mode.format = SDL_PIXELFORMAT_RGB555; break; case 16: fullscreen_mode.format = SDL_PIXELFORMAT_RGB565; break; case 24: fullscreen_mode.format = SDL_PIXELFORMAT_RGB24; break; default: fullscreen_mode.format = SDL_PIXELFORMAT_RGB888; break; } fullscreen_mode.refresh_rate = state->refresh_rate; state->windows = (SDL_Window **) SDL_malloc(state->num_windows * sizeof(*state->windows)); state->renderers = (SDL_Renderer **) SDL_malloc(state->num_windows * sizeof(*state->renderers)); if (!state->windows || !state->renderers) { fprintf(stderr, "Out of memory!\n"); return SDL_FALSE; } for (i = 0; i < state->num_windows; ++i) { char title[1024]; if (state->num_windows > 1) { SDL_snprintf(title, SDL_arraysize(title), "%s %d", state->window_title, i + 1); } else { SDL_strlcpy(title, state->window_title, SDL_arraysize(title)); } state->windows[i] = SDL_CreateWindow(title, state->window_x, state->window_y, state->window_w, state->window_h, state->window_flags); if (!state->windows[i]) { fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->window_minW || state->window_minH) { SDL_SetWindowMinimumSize(state->windows[i], state->window_minW, state->window_minH); } if (state->window_maxW || state->window_maxH) { SDL_SetWindowMaximumSize(state->windows[i], state->window_maxW, state->window_maxH); } SDL_GetWindowSize(state->windows[i], &w, &h); if (!(state->window_flags & SDL_WINDOW_RESIZABLE) && (w != state->window_w || h != state->window_h)) { printf("Window requested size %dx%d, got %dx%d\n", state->window_w, state->window_h, w, h); state->window_w = w; state->window_h = h; } if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) { fprintf(stderr, "Can't set up fullscreen display mode: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->window_icon) { SDL_Surface *icon = SDLTest_LoadIcon(state->window_icon); if (icon) { SDL_SetWindowIcon(state->windows[i], icon); SDL_FreeSurface(icon); } } SDL_ShowWindow(state->windows[i]); state->renderers[i] = NULL; if (!state->skip_renderer && (state->renderdriver || !(state->window_flags & SDL_WINDOW_OPENGL))) { m = -1; if (state->renderdriver) { SDL_RendererInfo info; n = SDL_GetNumRenderDrivers(); for (j = 0; j < n; ++j) { SDL_GetRenderDriverInfo(j, &info); if (SDL_strcasecmp(info.name, state->renderdriver) == 0) { m = j; break; } } if (m == n) { fprintf(stderr, "Couldn't find render driver named %s", state->renderdriver); return SDL_FALSE; } } state->renderers[i] = SDL_CreateRenderer(state->windows[i], m, state->render_flags); if (!state->renderers[i]) { fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->logical_w && state->logical_h) { SDL_RenderSetLogicalSize(state->renderers[i], state->logical_w, state->logical_h); } else if (state->scale) { SDL_RenderSetScale(state->renderers[i], state->scale, state->scale); } if (state->verbose & VERBOSE_RENDER) { SDL_RendererInfo info; fprintf(stderr, "Current renderer:\n"); SDL_GetRendererInfo(state->renderers[i], &info); SDLTest_PrintRenderer(&info); } } } } if (state->flags & SDL_INIT_AUDIO) { if (state->verbose & VERBOSE_AUDIO) { n = SDL_GetNumAudioDrivers(); if (n == 0) { fprintf(stderr, "No built-in audio drivers\n"); } else { fprintf(stderr, "Built-in audio drivers:"); for (i = 0; i < n; ++i) { if (i > 0) { fprintf(stderr, ","); } fprintf(stderr, " %s", SDL_GetAudioDriver(i)); } fprintf(stderr, "\n"); } } if (SDL_AudioInit(state->audiodriver) < 0) { fprintf(stderr, "Couldn't initialize audio driver: %s\n", SDL_GetError()); return SDL_FALSE; } if (state->verbose & VERBOSE_VIDEO) { fprintf(stderr, "Audio driver: %s\n", SDL_GetCurrentAudioDriver()); } if (SDL_OpenAudio(&state->audiospec, NULL) < 0) { fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); return SDL_FALSE; } } return SDL_TRUE; }
static void VL_SDL2_FlushParams() { SDL_SetWindowFullscreen(vl_sdl2_window, vl_isFullScreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); SDL_SetWindowMinimumSize(vl_sdl2_window, VL_VGA_GFX_SCALED_WIDTH_PLUS_BORDER / VL_VGA_GFX_WIDTH_SCALEFACTOR, VL_VGA_GFX_SCALED_HEIGHT_PLUS_BORDER / VL_VGA_GFX_HEIGHT_SCALEFACTOR); VL_SDL2_ResizeWindow(); }