Add possibility to use half vsync

This commit is contained in:
Deve 2019-09-28 00:55:18 +02:00
parent d205d80ad2
commit fc8f6a218e
12 changed files with 26 additions and 28 deletions

View File

@ -29,7 +29,7 @@ namespace irr
ZBufferBits(16),
Fullscreen(false),
Stencilbuffer(false),
Vsync(false),
SwapInterval(0),
AntiAlias(0),
HandleSRGB(false),
WithAlphaChannel(false),
@ -67,7 +67,7 @@ namespace irr
ZBufferBits = other.ZBufferBits;
Fullscreen = other.Fullscreen;
Stencilbuffer = other.Stencilbuffer;
Vsync = other.Vsync;
SwapInterval = other.SwapInterval;
AntiAlias = other.AntiAlias;
HandleSRGB = other.HandleSRGB;
WithAlphaChannel = other.WithAlphaChannel;
@ -130,10 +130,9 @@ namespace irr
bool Stencilbuffer;
//! Specifies vertical syncronisation.
/** If set to true, the driver will wait for the vertical
retrace period, otherwise not. May be silently ignored.
Default: false */
bool Vsync;
/** 0 = disabled, 1 = full, 2 = half
Default: 0 */
int SwapInterval;
//! Specifies if the device should use fullscreen anti aliasing
/** Makes sharp/pixelated edges softer, but requires more

View File

@ -308,8 +308,7 @@ namespace irr
\param stencilbuffer: Specifies if the stencil buffer should be enabled. Set this to true,
if you want the engine be able to draw stencil buffer shadows. Note that not all
devices are able to use the stencil buffer. If they don't no shadows will be drawn.
\param vsync: Specifies vertical syncronisation: If set to true, the driver will wait
for the vertical retrace period, otherwise not.
\param swapInterval: Specifies vertical syncronisation: 0 = disabled, 1 = full, 2 = half
\param receiver: A user created event receiver.
\return Returns pointer to the created IrrlichtDevice or null if the
device could not be created.
@ -321,7 +320,7 @@ namespace irr
u32 bits = 16,
bool fullscreen = false,
bool stencilbuffer = false,
bool vsync = false,
int swapInterval = 0,
IEventReceiver* receiver = 0,
io::IFileSystem *file_system = NULL);
@ -332,7 +331,7 @@ namespace irr
u32 bits,
bool fullscreen,
bool stencilbuffer,
bool vsync,
int swapInterval,
IEventReceiver* receiver);

View File

@ -145,7 +145,7 @@ bool ContextManagerEGL::init(const ContextEGLParams& params)
return false;
}
eglSwapInterval(m_egl_display, m_creation_params.vsync_enabled ? 1 : 0);
eglSwapInterval(m_egl_display, m_creation_params.swap_interval);
m_initialized = true;
return true;

View File

@ -83,7 +83,7 @@ struct ContextEGLParams
bool force_legacy_device;
bool handle_srgb;
bool with_alpha_channel;
bool vsync_enabled;
int swap_interval;
int pbuffer_width;
int pbuffer_height;
};

View File

@ -1095,7 +1095,7 @@ bool CIrrDeviceWayland::initEGL()
egl_params.force_legacy_device = CreationParams.ForceLegacyDevice;
egl_params.handle_srgb = CreationParams.HandleSRGB;
egl_params.with_alpha_channel = CreationParams.WithAlphaChannel;
egl_params.vsync_enabled = CreationParams.Vsync;
egl_params.swap_interval = CreationParams.SwapInterval;
egl_params.platform = CEGL_PLATFORM_WAYLAND;
egl_params.window = m_egl_window;
egl_params.display = m_display;

View File

@ -84,7 +84,7 @@ namespace video
egl_params.handle_srgb = Params.HandleSRGB;
egl_params.force_legacy_device = Params.ForceLegacyDevice;
egl_params.with_alpha_channel = Params.WithAlphaChannel;
egl_params.vsync_enabled = Params.Vsync;
egl_params.swap_interval = Params.SwapInterval;
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
egl_params.window = (EGLNativeWindowType)(data.OpenGLWin32.HWnd);

View File

@ -574,7 +574,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
genericDriverInit();
extGlSwapInterval(Params.Vsync ? 1 : 0);
extGlSwapInterval(Params.SwapInterval);
return true;
}
@ -687,7 +687,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceLinux* device)
genericDriverInit();
// set vsync
extGlSwapInterval(Params.Vsync ? 1 : 0);
extGlSwapInterval(Params.SwapInterval);
return true;
}

View File

@ -51,7 +51,7 @@ namespace irr
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType,
const core::dimension2d<u32>& windowSize,
u32 bits, bool fullscreen,
bool stencilbuffer, bool vsync, IEventReceiver* res,
bool stencilbuffer, int swapInterval, IEventReceiver* res,
io::IFileSystem *file_system)
{
SIrrlichtCreationParameters p;
@ -60,9 +60,9 @@ namespace irr
p.Bits = (u8)bits;
p.Fullscreen = fullscreen;
p.Stencilbuffer = stencilbuffer;
p.Vsync = vsync;
p.SwapInterval = swapInterval;
p.EventReceiver = res;
p.FileSystem = file_system;
p.FileSystem = file_system;
return createDeviceEx(p);
}

View File

@ -904,7 +904,7 @@ bool CIrrDeviceMacOSX::createWindow()
if(CreationParams.DriverType == video::EDT_OPENGL)
{
CGLSetCurrentContext(CGLContext);
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
newSwapInterval = CreationParams.SwapInterval;
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
}
}

View File

@ -838,10 +838,10 @@ namespace UserConfigParams
&m_graphics_quality,
"Quality of anisotropic filtering (usual values include 2-4-8-16; 0 to disable)") );
PARAM_PREFIX BoolUserConfigParam m_vsync
PARAM_DEFAULT( BoolUserConfigParam(false, "vsync",
PARAM_PREFIX IntUserConfigParam m_swap_interval
PARAM_DEFAULT( IntUserConfigParam(0, "swap_interval",
&m_graphics_quality,
"Whether vertical sync is enabled") );
"Swap interval for vsync: 0 = disabled, 1 = full, 2 = half") );
PARAM_PREFIX BoolUserConfigParam m_motionblur
PARAM_DEFAULT( BoolUserConfigParam(false,
"motionblur_enabled", &m_graphics_quality,

View File

@ -154,7 +154,7 @@ IrrDriver::IrrDriver()
p.WindowSize = core::dimension2d<u32>(640,480);
p.Bits = 16U;
p.Fullscreen = false;
p.Vsync = false;
p.SwapInterval = 0;
p.EventReceiver = NULL;
p.FileSystem = file_manager->getFileSystem();
#ifdef ANDROID
@ -462,7 +462,7 @@ void IrrDriver::initDevice()
params.Bits = bits;
params.EventReceiver = this;
params.Fullscreen = UserConfigParams::m_fullscreen;
params.Vsync = UserConfigParams::m_vsync;
params.SwapInterval = UserConfigParams::m_swap_interval;
params.FileSystem = file_manager->getFileSystem();
params.WindowSize =
core::dimension2du(UserConfigParams::m_width,
@ -515,7 +515,7 @@ void IrrDriver::initDevice()
32, //bits per pixel
UserConfigParams::m_fullscreen,
false, // stencil buffers
false, // vsync
0, // vsync
this, // event receiver
file_manager->getFileSystem()
);

View File

@ -189,7 +189,7 @@ void OptionsScreenVideo::init()
GUIEngine::CheckBoxWidget* vsync =
getWidget<GUIEngine::CheckBoxWidget>("vsync");
assert( vsync != NULL );
vsync->setState( UserConfigParams::m_vsync );
vsync->setState( UserConfigParams::m_swap_interval > 0 );
// ---- video modes
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
@ -622,7 +622,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
GUIEngine::CheckBoxWidget* vsync =
getWidget<GUIEngine::CheckBoxWidget>("vsync");
assert( vsync != NULL );
UserConfigParams::m_vsync = vsync->getState();
UserConfigParams::m_swap_interval = (int)vsync->getState();
}
else if (name == "rememberWinpos")
{