const string &Window::getName() const { if(isLoaded()) return name = SDL_GetWindowTitle(win); else return name; }
std::string window::get_title() const { std::lock_guard<std::mutex> lock(m_lock); const std::string title = SDL_GetWindowTitle(m_sdl_window); sdl::log_debug_error_check(); return title; }
void Window::getInfo( WindowInfo& info ) const noexcept { info.id = getID(); info.title = SDL_GetWindowTitle( m_wimpl->window ); info.wflags = fromSDL2Flags_( SDL_GetWindowFlags( m_wimpl->window ) ); SDL_GetWindowPosition( m_wimpl->window, &info.x, &info.y ); SDL_GetWindowSize( m_wimpl->window, &info.w, &info.h ); info.lw = getLogicalWidth(); info.lh = getLogicalHeight(); SDL_RendererInfo rinfo; SDL_GetRendererInfo( m_wimpl->renderer, &rinfo ); info.accel = ( ( rinfo.flags & SDL_RENDERER_ACCELERATED ) != 0 ); }
const char* Window::utf8Title() const { lairAssert(isValid()); return SDL_GetWindowTitle(_window); }
//----------------------------------------------------------------- const char* GetWindowTitle() { assert(g_Window); return SDL_GetWindowTitle(g_Window); }
void OMW::Engine::createWindow(Settings::Manager& settings) { int screen = settings.getInt("screen", "Video"); int width = settings.getInt("resolution x", "Video"); int height = settings.getInt("resolution y", "Video"); bool fullscreen = settings.getBool("fullscreen", "Video"); bool windowBorder = settings.getBool("window border", "Video"); bool vsync = settings.getBool("vsync", "Video"); int antialiasing = settings.getInt("antialiasing", "Video"); int pos_x = SDL_WINDOWPOS_CENTERED_DISPLAY(screen), pos_y = SDL_WINDOWPOS_CENTERED_DISPLAY(screen); if(fullscreen) { pos_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen); pos_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen); } Uint32 flags = SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE; if(fullscreen) flags |= SDL_WINDOW_FULLSCREEN; if (!windowBorder) flags |= SDL_WINDOW_BORDERLESS; SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, settings.getBool("minimize on focus loss", "Video") ? "1" : "0"); checkSDLError(SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24)); if (antialiasing > 0) { checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing)); } while (!mWindow) { mWindow = SDL_CreateWindow("OpenMW", pos_x, pos_y, width, height, flags); if (!mWindow) { // Try with a lower AA if (antialiasing > 0) { std::cout << "Note: " << antialiasing << "x antialiasing not supported, trying " << antialiasing/2 << std::endl; antialiasing /= 2; Settings::Manager::setInt("antialiasing", "Video", antialiasing); checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing)); continue; } else { std::stringstream error; error << "Failed to create SDL window: " << SDL_GetError() << std::endl; throw std::runtime_error(error.str()); } } } setWindowIcon(); osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; SDL_GetWindowPosition(mWindow, &traits->x, &traits->y); SDL_GetWindowSize(mWindow, &traits->width, &traits->height); traits->windowName = SDL_GetWindowTitle(mWindow); traits->windowDecoration = !(SDL_GetWindowFlags(mWindow)&SDL_WINDOW_BORDERLESS); traits->screenNum = SDL_GetWindowDisplayIndex(mWindow); // FIXME: Some way to get these settings back from the SDL window? traits->red = 8; traits->green = 8; traits->blue = 8; traits->alpha = 0; // set to 0 to stop ScreenCaptureHandler reading the alpha channel traits->depth = 24; traits->stencil = 8; traits->vsync = vsync; traits->doubleBuffer = true; traits->inheritedWindowData = new SDLUtil::GraphicsWindowSDL2::WindowData(mWindow); osg::ref_ptr<SDLUtil::GraphicsWindowSDL2> graphicsWindow = new SDLUtil::GraphicsWindowSDL2(traits); if(!graphicsWindow->valid()) throw std::runtime_error("Failed to create GraphicsContext"); osg::ref_ptr<osg::Camera> camera = mViewer->getCamera(); camera->setGraphicsContext(graphicsWindow); camera->setViewport(0, 0, width, height); mViewer->realize(); }
int graphics_SetMode(int width, int height, int fullscreen, int resizable, const char* title, const char* renderer, char** error) { graphics_calculateUnitToPixels(width, height); #if defined(ANDROID) if (!fullscreen) { // do not use windowed on Android *error = strdup("Windowed mode is not supported on Android"); return 0; } #endif char errormsg[512]; // initialize SDL video if not done yet if (!graphics_InitVideoSubsystem(error)) { return 0; } // think about the renderer we want #ifndef WINDOWS #ifdef ANDROID char preferredrenderer[20] = "opengles"; #else char preferredrenderer[20] = "opengl"; #endif #else char preferredrenderer[20] = "direct3d"; #endif int softwarerendering = 0; if (renderer) { if (strcasecmp(renderer, "software") == 0) { #ifdef ANDROID // we don't want software rendering on Android #else softwarerendering = 1; strcpy(preferredrenderer, "software"); #endif } else { if (strcasecmp(renderer, "opengl") == 0) { #ifdef ANDROID // opengles is the opengl we want for android :-) strcpy(preferredrenderer, "opengles"); #else // regular opengl on desktop platforms strcpy(preferredrenderer, "opengl"); #endif } #ifdef WINDOWS // only windows knows direct3d obviously if (strcasecmp(renderer,"direct3d") == 0) { strcpy(preferredrenderer, "direct3d"); } #endif } } // get renderer index int rendererindex = -1; if (strlen(preferredrenderer) > 0 && !softwarerendering) { int count = SDL_GetNumRenderDrivers(); if (count > 0) { int r = 0; while (r < count) { SDL_RendererInfo info; SDL_GetRenderDriverInfo(r, &info); if (strcasecmp(info.name, preferredrenderer) == 0) { rendererindex = r; break; } r++; } } } // see if anything changes at all unsigned int oldw = 0; unsigned int oldh = 0; graphics_GetWindowDimensions(&oldw,&oldh); if (mainwindow && mainrenderer && width == (int)oldw && height == (int)oldh) { SDL_RendererInfo info; SDL_GetRendererInfo(mainrenderer, &info); if (strcasecmp(preferredrenderer, info.name) == 0) { // same renderer and resolution if (strcmp(SDL_GetWindowTitle(mainwindow), title) != 0) { SDL_SetWindowTitle(mainwindow, title); } // toggle fullscreen if desired if (graphics_IsFullscreen() != fullscreen) { graphics_ToggleFullscreen(); } return 1; } } // Check if we support the video mode for fullscreen - // This is done to avoid SDL allowing impossible modes and // giving us a fake resized/padded/whatever output we don't want. if (fullscreen) { // check all video modes in the list SDL returns for us int count = graphics_GetNumberOfVideoModes(); int i = 0; int supportedmode = 0; while (i < count) { int w,h; graphics_GetVideoMode(i, &w, &h); if (w == width && h == height) { supportedmode = 1; break; } i++; } if (!supportedmode) { // check for desktop video mode aswell int w,h; graphics_GetDesktopVideoMode(&w,&h); if (w == 0 || h == 0 || width != w || height != h) { *error = strdup("Video mode is not supported"); return 0; } } } // notify texture manager of device shutdown texturemanager_deviceLost(); // destroy old window/renderer if we got one graphics_Close(1); // create window if (fullscreen) { mainwindow = SDL_CreateWindow(title, 0, 0, width, height, SDL_WINDOW_FULLSCREEN); mainwindowfullscreen = 1; } else { mainwindow = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_MINIMIZED); mainwindowfullscreen = 0; } if (!mainwindow) { snprintf(errormsg, sizeof(errormsg), "Failed to open SDL window: %s", SDL_GetError()); errormsg[sizeof(errormsg)-1] = 0; *error = strdup(errormsg); return 0; } // see if we actually ended up with the resolution we wanted: int actualwidth, actualheight; SDL_GetWindowSize(mainwindow, &actualwidth, &actualheight); if (actualwidth != width || actualheight != height) { if (fullscreen) { // we failed to get the requested resolution: SDL_DestroyWindow(mainwindow); snprintf(errormsg, sizeof(errormsg), "Failed to open " "SDL window: ended up with other resolution than requested"); *error = strdup(errormsg); return 0; } } // Create renderer if (!softwarerendering) { mainrenderer = SDL_CreateRenderer(mainwindow, rendererindex, SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC); if (!mainrenderer) { softwarerendering = 1; strcpy(preferredrenderer, "software"); } } if (softwarerendering) { mainrenderer = SDL_CreateRenderer(mainwindow, -1, SDL_RENDERER_SOFTWARE); } if (!mainrenderer) { // we failed to create the renderer if (mainwindow) { // destroy window aswell in case it is open SDL_DestroyWindow(mainwindow); mainwindow = NULL; } if (softwarerendering) { snprintf(errormsg, sizeof(errormsg), "Failed to create SDL renderer (backend software): %s", SDL_GetError()); } else { SDL_RendererInfo info; SDL_GetRenderDriverInfo(rendererindex, &info); snprintf(errormsg, sizeof(errormsg), "Failed to create SDL renderer (backend %s): %s", info.name, SDL_GetError()); } errormsg[sizeof(errormsg)-1] = 0; *error = strdup(errormsg); return 0; } else { SDL_RendererInfo info; SDL_GetRendererInfo(mainrenderer, &info); } // notify texture manager that device is back texturemanager_deviceRestored(); // Transfer textures back to SDL /*if (!graphicstexturelist_TransferTexturesToHW()) { SDL_RendererInfo info; SDL_GetRendererInfo(mainrenderer, &info); snprintf(errormsg, sizeof(errormsg), "Failed to create SDL renderer (backend %s): " "Cannot recreate textures", info.name); *error = strdup(errormsg); SDL_DestroyRenderer(mainrenderer); SDL_DestroyWindow(mainwindow); return 0; }*/ // Re-focus window if previously focussed if (!inbackground) { SDL_RaiseWindow(mainwindow); } graphicsactive = 1; return 1; }
std::string SDL2GameWindow::getWindowTitle() const { return std::string(SDL_GetWindowTitle(nativeWindow_)); }
std::string title() const noexcept { return SDL_GetWindowTitle(ptr.get()); }
const char* graphics_GetWindowTitle() { if (!mainrenderer || !mainwindow) { return NULL; } return SDL_GetWindowTitle(mainwindow); }
const char* graphics_viewport_title() { return SDL_GetWindowTitle(screen); }
std::string Window::getTitle() noexcept { const char * TITLE = SDL_GetWindowTitle( m_wimpl->window ); return std::string( ( TITLE == nullptr ) ? "" : TITLE ); }
void GHOST_WindowSDL::getTitle(STR_String& title) const { title = SDL_GetWindowTitle(m_sdl_win); }
const char *aqwin_title(Aqwin *win, const char *title) { if (title) { SDL_SetWindowTitle(win->sdlwin, title); } return SDL_GetWindowTitle(win->sdlwin); }
const char *kexSystem::GetWindowTitle(void) { return SDL_GetWindowTitle(window); }
const char *UIInterface::getWindowTitle() const { return SDL_GetWindowTitle(m_Win); }
const char *video_get_title( ) { return SDL_GetWindowTitle( video_window ); }
void OMW::Engine::createWindow(Settings::Manager& settings) { int screen = settings.getInt("screen", "Video"); int width = settings.getInt("resolution x", "Video"); int height = settings.getInt("resolution y", "Video"); bool fullscreen = settings.getBool("fullscreen", "Video"); bool windowBorder = settings.getBool("window border", "Video"); bool vsync = settings.getBool("vsync", "Video"); int antialiasing = settings.getInt("antialiasing", "Video"); int pos_x = SDL_WINDOWPOS_CENTERED_DISPLAY(screen), pos_y = SDL_WINDOWPOS_CENTERED_DISPLAY(screen); if(fullscreen) { pos_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen); pos_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen); } Uint32 flags = SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE; if(fullscreen) flags |= SDL_WINDOW_FULLSCREEN; if (!windowBorder) flags |= SDL_WINDOW_BORDERLESS; SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, settings.getBool("minimize on focus loss", "Video") ? "1" : "0"); checkSDLError(SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24)); if (antialiasing > 0) { checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1)); checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing)); } while (!mWindow) { mWindow = SDL_CreateWindow("OpenMW", pos_x, pos_y, width, height, flags); if (!mWindow) { // Try with a lower AA if (antialiasing > 0) { Log(Debug::Warning) << "Warning: " << antialiasing << "x antialiasing not supported, trying " << antialiasing/2; antialiasing /= 2; Settings::Manager::setInt("antialiasing", "Video", antialiasing); checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing)); continue; } else { std::stringstream error; error << "Failed to create SDL window: " << SDL_GetError(); throw std::runtime_error(error.str()); } } } setWindowIcon(); osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; SDL_GetWindowPosition(mWindow, &traits->x, &traits->y); SDL_GetWindowSize(mWindow, &traits->width, &traits->height); traits->windowName = SDL_GetWindowTitle(mWindow); traits->windowDecoration = !(SDL_GetWindowFlags(mWindow)&SDL_WINDOW_BORDERLESS); traits->screenNum = SDL_GetWindowDisplayIndex(mWindow); // We tried to get rid of the hardcoding but failed: https://github.com/OpenMW/openmw/pull/1771 // Here goes kcat's quote: // It's ultimately a chicken and egg problem, and the reason why the code is like it was in the first place. // It needs a context to get the current attributes, but it needs the attributes to set up the context. // So it just specifies the same values that were given to SDL in the hopes that it's good enough to what the window eventually gets. traits->red = 8; traits->green = 8; traits->blue = 8; traits->alpha = 0; // set to 0 to stop ScreenCaptureHandler reading the alpha channel traits->depth = 24; traits->stencil = 8; traits->vsync = vsync; traits->doubleBuffer = true; traits->inheritedWindowData = new SDLUtil::GraphicsWindowSDL2::WindowData(mWindow); osg::ref_ptr<SDLUtil::GraphicsWindowSDL2> graphicsWindow = new SDLUtil::GraphicsWindowSDL2(traits); if(!graphicsWindow->valid()) throw std::runtime_error("Failed to create GraphicsContext"); osg::ref_ptr<osg::Camera> camera = mViewer->getCamera(); camera->setGraphicsContext(graphicsWindow); camera->setViewport(0, 0, width, height); mViewer->realize(); mViewer->getEventQueue()->getCurrentEventState()->setWindowRectangle(0, 0, width, height); }
std::string window::get_title() const { return SDL_GetWindowTitle(handle.get()); }
const char* Window::getTitle() const { return SDL_GetWindowTitle(_wnd); }
int inline Window::getWindowTitle(State & state, SDL_Window * window){ Stack * stack = state.stack; stack->pushLString(SDL_GetWindowTitle(window)); return 1; }