本文整理汇总了C++中VideoMode::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoMode::isValid方法的具体用法?C++ VideoMode::isValid怎么用?C++ VideoMode::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoMode
的用法示例。
在下文中一共展示了VideoMode::isValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
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();
}
示例2: initialize
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);
}
示例3: create
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();
}
示例4: create
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();
}
示例5: setVideoMode
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";
}