コード例 #1
0
void Window::create(VideoMode mode, const String &title, uint32 style, const ContextSettings &settings) {
    close();

    if (style & WindowStyle::Fullscreen) {
        if (fullscreenWindow) {
            std::cerr << "Creating two fullscreen windows is not allowed, switching to windowed mode\n";
            style &= ~WindowStyle::Fullscreen;
        } else {
            if (!mode.isValid()) {
                std::cerr << "The requested video mode is not available, switching to a valid mode.\n";
                mode = VideoMode::getFullScreenModes()[0];
            }

            fullscreenWindow = this;
        }
    }

#	if defined (Q_IOS) || defined(Q_ANDROID)
    if (style & WindowStyle::Fullscreen) {
        style &= ~WindowStyle::Fullscreen;
    } else {
        style |= WindowStyle::Titlebar;
    }
#	else
    if ((style & WindowStyle::Close) || (style & WindowStyle::Resize)) {
        style |= WindowStyle::Titlebar;
    }
#	endif

    mBase = WindowBase::createWindow(mode, title, style, settings);
    mContext = GLContext::create(settings, mBase, mode.bpp);

    init(mode.maximize);
}
コード例 #2
0
ファイル: Window.cpp プロジェクト: 42bottles/SFML
void Window::create(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings)
{
    // Destroy the previous window implementation
    close();

    // Fullscreen style requires some tests
    if (style & Style::Fullscreen)
    {
        // Make sure there's not already a fullscreen window (only one is allowed)
        if (fullscreenWindow)
        {
            err() << "Creating two fullscreen windows is not allowed, switching to windowed mode" << std::endl;
            style &= ~Style::Fullscreen;
        }
        else
        {
            // Make sure that the chosen video mode is compatible
            if (!mode.isValid())
            {
                err() << "The requested video mode is not available, switching to a valid mode" << std::endl;
                mode = VideoMode::getFullscreenModes()[0];
            }

            // Update the fullscreen window
            fullscreenWindow = this;
        }
    }

    // Check validity of style according to the underlying platform
    #if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID)
        if (style & Style::Fullscreen)
            style &= ~Style::Titlebar;
        else
            style |= Style::Titlebar;
    #else
        if ((style & Style::Close) || (style & Style::Resize))
            style |= Style::Titlebar;
    #endif

    // Recreate the window implementation
    m_impl = priv::WindowImpl::create(mode, title, style, settings);

    // Recreate the context
    m_context = priv::GlContext::create(settings, m_impl, mode.bitsPerPixel);

    // Perform common initializations
    initialize();
}
コード例 #3
0
ファイル: renderer.cpp プロジェクト: silidur/keeperrl
void Renderer::initialize(bool fs, int mode) {
  fullscreen = fs;
  if (!renderThreadId)
    renderThreadId = currentThreadId();
  else
    CHECK(currentThreadId() == *renderThreadId);
  CHECK(!getResolutions().empty()) << sf::VideoMode::getFullscreenModes().size() << " " << int(sf::VideoMode::getDesktopMode().bitsPerPixel);
  CHECK(mode >= 0 && mode < getResolutions().size()) << mode << " " << getResolutions().size();
  VideoMode vMode = getResolutions()[mode];
  CHECK(vMode.isValid()) << "Video mode invalid: " << int(vMode.width) << " " << int(vMode.height) << " " << int(vMode.bitsPerPixel) << " " << fs;
  if (fullscreen)
    display.create(vMode, "KeeperRL", sf::Style::Fullscreen);
  else
    display.create(sf::VideoMode::getDesktopMode(), "KeeperRL");
  sfView = new sf::View(display.getDefaultView());
  display.setVerticalSyncEnabled(true);
}
コード例 #4
0
ファイル: SFMLWindow.cpp プロジェクト: GrimshawA/Nephilim
void Window::create(VideoMode mode, const String& title, Uint32 style, const ContextSettings& settings)
{
    // Destroy the previous window implementation
    close();

    // Fullscreen style requires some tests
    if (style & Style::Fullscreen)
    {
        // Make sure there's not already a fullscreen window (only one is allowed)
        if (fullscreenWindow)
        {
            err() << "Creating two fullscreen windows is not allowed, switching to windowed mode" << std::endl;
            style &= ~Style::Fullscreen;
        }
        else
        {
            // Make sure that the chosen video mode is compatible
            if (!mode.isValid())
            {
                err() << "The requested video mode is not available, switching to a valid mode" << std::endl;
                mode = VideoMode::getFullscreenModes()[0];
            }

            // Update the fullscreen window
            fullscreenWindow = this;
        }
    }

    // Check validity of style
    if ((style & Style::Close) || (style & Style::Resize))
        style |= Style::Titlebar;

    // Recreate the window implementation
    m_impl = priv::WindowImpl::create(mode, title, style);
    m_impl->onDragDrop.connect(sigc::mem_fun(this, &Window::RedirectDragDrop));

    // Recreate the context
    m_context = priv::GlContext::create(settings, m_impl, mode.bitsPerPixel);

    // Perform common initializations
    initialize();
}
コード例 #5
0
ファイル: Window.cpp プロジェクト: MrShedman/GL-Dev
void Window::create(VideoMode mode, const std::string& title, Uint32 style, const ContextSettings& settings)
{
    // Destroy the previous window implementation
    close();

    // Fullscreen style requires some tests
    if (style & Style::Fullscreen)
    {
        // Make sure there's not already a fullscreen window (only one is allowed)
        if (fullscreenWindow)
        {
            style &= ~Style::Fullscreen;
        }
        else
        {
            // Make sure that the chosen video mode is compatible
            if (!mode.isValid())
            {
                mode = VideoMode::getFullscreenModes()[0];
            }

            // Update the fullscreen window
            fullscreenWindow = this;
        }
    }

    // Check validity of style
    if ((style & Style::Close) || (style & Style::Resize))
        style |= Style::Titlebar;

    // Recreate the window implementation
	m_impl = priv::WindowImplWin32::create(mode, title, style, settings);

    // Recreate the context
    m_context = priv::GlContext::create(settings, m_impl, mode.bitsPerPixel);

    // Perform common initializations
    initialize();
}
コード例 #6
0
ファイル: Window.cpp プロジェクト: cristicbz/AdventureMiner
	void Window::setVideoMode( const VideoMode& mode ) {
		log << "Setting video mode " << mode << ".\n";

		if(!mode.isValid()) {
			log << "VideoModeNotSupportedException raised.\n";
			throw VideoModeNotSupportedException();
		}

		if( mode == mode_ ) {
			log << "No changes detected. Not doing anything.\n";
			return;
		}

		bool opOk;
		int w = mode.getWidth();
		int h = mode.getHeight();
		int bpp = mode.getBpp();
		int flags = SDL_OPENGL;

		if( mode.isFullscreen() )
			flags |= SDL_FULLSCREEN;

		if( !mode.isDecorated() )
			flags |= SDL_NOFRAME;

		_putenv(_strdup("SDL_VIDEO_CENTERED=1")); 
		SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
		SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,mode.hasVSync()?1:0);
		
		opOk = SDL_SetVideoMode(w,h,bpp,flags) != 0;
		if( !opOk ) {
			log << "Warning: Mode reported it was valid, but SDL_SetVideoMode() failed.\n";
			throw VideoModeNotSupportedException();
		}

		mode_ = mode;
		log << "Video mode set.\n";
	}