Add possibility to use half vsync
This commit is contained in:
parent
d205d80ad2
commit
fc8f6a218e
@ -29,7 +29,7 @@ namespace irr
|
|||||||
ZBufferBits(16),
|
ZBufferBits(16),
|
||||||
Fullscreen(false),
|
Fullscreen(false),
|
||||||
Stencilbuffer(false),
|
Stencilbuffer(false),
|
||||||
Vsync(false),
|
SwapInterval(0),
|
||||||
AntiAlias(0),
|
AntiAlias(0),
|
||||||
HandleSRGB(false),
|
HandleSRGB(false),
|
||||||
WithAlphaChannel(false),
|
WithAlphaChannel(false),
|
||||||
@ -67,7 +67,7 @@ namespace irr
|
|||||||
ZBufferBits = other.ZBufferBits;
|
ZBufferBits = other.ZBufferBits;
|
||||||
Fullscreen = other.Fullscreen;
|
Fullscreen = other.Fullscreen;
|
||||||
Stencilbuffer = other.Stencilbuffer;
|
Stencilbuffer = other.Stencilbuffer;
|
||||||
Vsync = other.Vsync;
|
SwapInterval = other.SwapInterval;
|
||||||
AntiAlias = other.AntiAlias;
|
AntiAlias = other.AntiAlias;
|
||||||
HandleSRGB = other.HandleSRGB;
|
HandleSRGB = other.HandleSRGB;
|
||||||
WithAlphaChannel = other.WithAlphaChannel;
|
WithAlphaChannel = other.WithAlphaChannel;
|
||||||
@ -130,10 +130,9 @@ namespace irr
|
|||||||
bool Stencilbuffer;
|
bool Stencilbuffer;
|
||||||
|
|
||||||
//! Specifies vertical syncronisation.
|
//! Specifies vertical syncronisation.
|
||||||
/** If set to true, the driver will wait for the vertical
|
/** 0 = disabled, 1 = full, 2 = half
|
||||||
retrace period, otherwise not. May be silently ignored.
|
Default: 0 */
|
||||||
Default: false */
|
int SwapInterval;
|
||||||
bool Vsync;
|
|
||||||
|
|
||||||
//! Specifies if the device should use fullscreen anti aliasing
|
//! Specifies if the device should use fullscreen anti aliasing
|
||||||
/** Makes sharp/pixelated edges softer, but requires more
|
/** Makes sharp/pixelated edges softer, but requires more
|
||||||
|
@ -308,8 +308,7 @@ namespace irr
|
|||||||
\param stencilbuffer: Specifies if the stencil buffer should be enabled. Set this to true,
|
\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
|
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.
|
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
|
\param swapInterval: Specifies vertical syncronisation: 0 = disabled, 1 = full, 2 = half
|
||||||
for the vertical retrace period, otherwise not.
|
|
||||||
\param receiver: A user created event receiver.
|
\param receiver: A user created event receiver.
|
||||||
\return Returns pointer to the created IrrlichtDevice or null if the
|
\return Returns pointer to the created IrrlichtDevice or null if the
|
||||||
device could not be created.
|
device could not be created.
|
||||||
@ -321,7 +320,7 @@ namespace irr
|
|||||||
u32 bits = 16,
|
u32 bits = 16,
|
||||||
bool fullscreen = false,
|
bool fullscreen = false,
|
||||||
bool stencilbuffer = false,
|
bool stencilbuffer = false,
|
||||||
bool vsync = false,
|
int swapInterval = 0,
|
||||||
IEventReceiver* receiver = 0,
|
IEventReceiver* receiver = 0,
|
||||||
io::IFileSystem *file_system = NULL);
|
io::IFileSystem *file_system = NULL);
|
||||||
|
|
||||||
@ -332,7 +331,7 @@ namespace irr
|
|||||||
u32 bits,
|
u32 bits,
|
||||||
bool fullscreen,
|
bool fullscreen,
|
||||||
bool stencilbuffer,
|
bool stencilbuffer,
|
||||||
bool vsync,
|
int swapInterval,
|
||||||
IEventReceiver* receiver);
|
IEventReceiver* receiver);
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ bool ContextManagerEGL::init(const ContextEGLParams& params)
|
|||||||
return false;
|
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;
|
m_initialized = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -83,7 +83,7 @@ struct ContextEGLParams
|
|||||||
bool force_legacy_device;
|
bool force_legacy_device;
|
||||||
bool handle_srgb;
|
bool handle_srgb;
|
||||||
bool with_alpha_channel;
|
bool with_alpha_channel;
|
||||||
bool vsync_enabled;
|
int swap_interval;
|
||||||
int pbuffer_width;
|
int pbuffer_width;
|
||||||
int pbuffer_height;
|
int pbuffer_height;
|
||||||
};
|
};
|
||||||
|
@ -1095,7 +1095,7 @@ bool CIrrDeviceWayland::initEGL()
|
|||||||
egl_params.force_legacy_device = CreationParams.ForceLegacyDevice;
|
egl_params.force_legacy_device = CreationParams.ForceLegacyDevice;
|
||||||
egl_params.handle_srgb = CreationParams.HandleSRGB;
|
egl_params.handle_srgb = CreationParams.HandleSRGB;
|
||||||
egl_params.with_alpha_channel = CreationParams.WithAlphaChannel;
|
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.platform = CEGL_PLATFORM_WAYLAND;
|
||||||
egl_params.window = m_egl_window;
|
egl_params.window = m_egl_window;
|
||||||
egl_params.display = m_display;
|
egl_params.display = m_display;
|
||||||
|
@ -84,7 +84,7 @@ namespace video
|
|||||||
egl_params.handle_srgb = Params.HandleSRGB;
|
egl_params.handle_srgb = Params.HandleSRGB;
|
||||||
egl_params.force_legacy_device = Params.ForceLegacyDevice;
|
egl_params.force_legacy_device = Params.ForceLegacyDevice;
|
||||||
egl_params.with_alpha_channel = Params.WithAlphaChannel;
|
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_)
|
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||||
egl_params.window = (EGLNativeWindowType)(data.OpenGLWin32.HWnd);
|
egl_params.window = (EGLNativeWindowType)(data.OpenGLWin32.HWnd);
|
||||||
|
@ -574,7 +574,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
|
|||||||
|
|
||||||
genericDriverInit();
|
genericDriverInit();
|
||||||
|
|
||||||
extGlSwapInterval(Params.Vsync ? 1 : 0);
|
extGlSwapInterval(Params.SwapInterval);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,7 +687,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceLinux* device)
|
|||||||
genericDriverInit();
|
genericDriverInit();
|
||||||
|
|
||||||
// set vsync
|
// set vsync
|
||||||
extGlSwapInterval(Params.Vsync ? 1 : 0);
|
extGlSwapInterval(Params.SwapInterval);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace irr
|
|||||||
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType,
|
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType,
|
||||||
const core::dimension2d<u32>& windowSize,
|
const core::dimension2d<u32>& windowSize,
|
||||||
u32 bits, bool fullscreen,
|
u32 bits, bool fullscreen,
|
||||||
bool stencilbuffer, bool vsync, IEventReceiver* res,
|
bool stencilbuffer, int swapInterval, IEventReceiver* res,
|
||||||
io::IFileSystem *file_system)
|
io::IFileSystem *file_system)
|
||||||
{
|
{
|
||||||
SIrrlichtCreationParameters p;
|
SIrrlichtCreationParameters p;
|
||||||
@ -60,7 +60,7 @@ namespace irr
|
|||||||
p.Bits = (u8)bits;
|
p.Bits = (u8)bits;
|
||||||
p.Fullscreen = fullscreen;
|
p.Fullscreen = fullscreen;
|
||||||
p.Stencilbuffer = stencilbuffer;
|
p.Stencilbuffer = stencilbuffer;
|
||||||
p.Vsync = vsync;
|
p.SwapInterval = swapInterval;
|
||||||
p.EventReceiver = res;
|
p.EventReceiver = res;
|
||||||
p.FileSystem = file_system;
|
p.FileSystem = file_system;
|
||||||
|
|
||||||
|
@ -904,7 +904,7 @@ bool CIrrDeviceMacOSX::createWindow()
|
|||||||
if(CreationParams.DriverType == video::EDT_OPENGL)
|
if(CreationParams.DriverType == video::EDT_OPENGL)
|
||||||
{
|
{
|
||||||
CGLSetCurrentContext(CGLContext);
|
CGLSetCurrentContext(CGLContext);
|
||||||
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
|
newSwapInterval = CreationParams.SwapInterval;
|
||||||
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
|
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -838,10 +838,10 @@ namespace UserConfigParams
|
|||||||
&m_graphics_quality,
|
&m_graphics_quality,
|
||||||
"Quality of anisotropic filtering (usual values include 2-4-8-16; 0 to disable)") );
|
"Quality of anisotropic filtering (usual values include 2-4-8-16; 0 to disable)") );
|
||||||
|
|
||||||
PARAM_PREFIX BoolUserConfigParam m_vsync
|
PARAM_PREFIX IntUserConfigParam m_swap_interval
|
||||||
PARAM_DEFAULT( BoolUserConfigParam(false, "vsync",
|
PARAM_DEFAULT( IntUserConfigParam(0, "swap_interval",
|
||||||
&m_graphics_quality,
|
&m_graphics_quality,
|
||||||
"Whether vertical sync is enabled") );
|
"Swap interval for vsync: 0 = disabled, 1 = full, 2 = half") );
|
||||||
PARAM_PREFIX BoolUserConfigParam m_motionblur
|
PARAM_PREFIX BoolUserConfigParam m_motionblur
|
||||||
PARAM_DEFAULT( BoolUserConfigParam(false,
|
PARAM_DEFAULT( BoolUserConfigParam(false,
|
||||||
"motionblur_enabled", &m_graphics_quality,
|
"motionblur_enabled", &m_graphics_quality,
|
||||||
|
@ -154,7 +154,7 @@ IrrDriver::IrrDriver()
|
|||||||
p.WindowSize = core::dimension2d<u32>(640,480);
|
p.WindowSize = core::dimension2d<u32>(640,480);
|
||||||
p.Bits = 16U;
|
p.Bits = 16U;
|
||||||
p.Fullscreen = false;
|
p.Fullscreen = false;
|
||||||
p.Vsync = false;
|
p.SwapInterval = 0;
|
||||||
p.EventReceiver = NULL;
|
p.EventReceiver = NULL;
|
||||||
p.FileSystem = file_manager->getFileSystem();
|
p.FileSystem = file_manager->getFileSystem();
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
@ -462,7 +462,7 @@ void IrrDriver::initDevice()
|
|||||||
params.Bits = bits;
|
params.Bits = bits;
|
||||||
params.EventReceiver = this;
|
params.EventReceiver = this;
|
||||||
params.Fullscreen = UserConfigParams::m_fullscreen;
|
params.Fullscreen = UserConfigParams::m_fullscreen;
|
||||||
params.Vsync = UserConfigParams::m_vsync;
|
params.SwapInterval = UserConfigParams::m_swap_interval;
|
||||||
params.FileSystem = file_manager->getFileSystem();
|
params.FileSystem = file_manager->getFileSystem();
|
||||||
params.WindowSize =
|
params.WindowSize =
|
||||||
core::dimension2du(UserConfigParams::m_width,
|
core::dimension2du(UserConfigParams::m_width,
|
||||||
@ -515,7 +515,7 @@ void IrrDriver::initDevice()
|
|||||||
32, //bits per pixel
|
32, //bits per pixel
|
||||||
UserConfigParams::m_fullscreen,
|
UserConfigParams::m_fullscreen,
|
||||||
false, // stencil buffers
|
false, // stencil buffers
|
||||||
false, // vsync
|
0, // vsync
|
||||||
this, // event receiver
|
this, // event receiver
|
||||||
file_manager->getFileSystem()
|
file_manager->getFileSystem()
|
||||||
);
|
);
|
||||||
|
@ -189,7 +189,7 @@ void OptionsScreenVideo::init()
|
|||||||
GUIEngine::CheckBoxWidget* vsync =
|
GUIEngine::CheckBoxWidget* vsync =
|
||||||
getWidget<GUIEngine::CheckBoxWidget>("vsync");
|
getWidget<GUIEngine::CheckBoxWidget>("vsync");
|
||||||
assert( vsync != NULL );
|
assert( vsync != NULL );
|
||||||
vsync->setState( UserConfigParams::m_vsync );
|
vsync->setState( UserConfigParams::m_swap_interval > 0 );
|
||||||
|
|
||||||
// ---- video modes
|
// ---- video modes
|
||||||
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
|
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
|
||||||
@ -622,7 +622,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
GUIEngine::CheckBoxWidget* vsync =
|
GUIEngine::CheckBoxWidget* vsync =
|
||||||
getWidget<GUIEngine::CheckBoxWidget>("vsync");
|
getWidget<GUIEngine::CheckBoxWidget>("vsync");
|
||||||
assert( vsync != NULL );
|
assert( vsync != NULL );
|
||||||
UserConfigParams::m_vsync = vsync->getState();
|
UserConfigParams::m_swap_interval = (int)vsync->getState();
|
||||||
}
|
}
|
||||||
else if (name == "rememberWinpos")
|
else if (name == "rememberWinpos")
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user