Skip to content

Commit fc8f6a2

Browse files
committed
Add possibility to use half vsync
1 parent d205d80 commit fc8f6a2

File tree

12 files changed

+26
-28
lines changed

12 files changed

+26
-28
lines changed

lib/irrlicht/include/SIrrCreationParameters.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace irr
2929
ZBufferBits(16),
3030
Fullscreen(false),
3131
Stencilbuffer(false),
32-
Vsync(false),
32+
SwapInterval(0),
3333
AntiAlias(0),
3434
HandleSRGB(false),
3535
WithAlphaChannel(false),
@@ -67,7 +67,7 @@ namespace irr
6767
ZBufferBits = other.ZBufferBits;
6868
Fullscreen = other.Fullscreen;
6969
Stencilbuffer = other.Stencilbuffer;
70-
Vsync = other.Vsync;
70+
SwapInterval = other.SwapInterval;
7171
AntiAlias = other.AntiAlias;
7272
HandleSRGB = other.HandleSRGB;
7373
WithAlphaChannel = other.WithAlphaChannel;
@@ -130,10 +130,9 @@ namespace irr
130130
bool Stencilbuffer;
131131

132132
//! Specifies vertical syncronisation.
133-
/** If set to true, the driver will wait for the vertical
134-
retrace period, otherwise not. May be silently ignored.
135-
Default: false */
136-
bool Vsync;
133+
/** 0 = disabled, 1 = full, 2 = half
134+
Default: 0 */
135+
int SwapInterval;
137136

138137
//! Specifies if the device should use fullscreen anti aliasing
139138
/** Makes sharp/pixelated edges softer, but requires more

lib/irrlicht/include/irrlicht.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@ namespace irr
308308
\param stencilbuffer: Specifies if the stencil buffer should be enabled. Set this to true,
309309
if you want the engine be able to draw stencil buffer shadows. Note that not all
310310
devices are able to use the stencil buffer. If they don't no shadows will be drawn.
311-
\param vsync: Specifies vertical syncronisation: If set to true, the driver will wait
312-
for the vertical retrace period, otherwise not.
311+
\param swapInterval: Specifies vertical syncronisation: 0 = disabled, 1 = full, 2 = half
313312
\param receiver: A user created event receiver.
314313
\return Returns pointer to the created IrrlichtDevice or null if the
315314
device could not be created.
@@ -321,7 +320,7 @@ namespace irr
321320
u32 bits = 16,
322321
bool fullscreen = false,
323322
bool stencilbuffer = false,
324-
bool vsync = false,
323+
int swapInterval = 0,
325324
IEventReceiver* receiver = 0,
326325
io::IFileSystem *file_system = NULL);
327326

@@ -332,7 +331,7 @@ namespace irr
332331
u32 bits,
333332
bool fullscreen,
334333
bool stencilbuffer,
335-
bool vsync,
334+
int swapInterval,
336335
IEventReceiver* receiver);
337336

338337

lib/irrlicht/source/Irrlicht/CContextEGL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ bool ContextManagerEGL::init(const ContextEGLParams& params)
145145
return false;
146146
}
147147

148-
eglSwapInterval(m_egl_display, m_creation_params.vsync_enabled ? 1 : 0);
148+
eglSwapInterval(m_egl_display, m_creation_params.swap_interval);
149149

150150
m_initialized = true;
151151
return true;

lib/irrlicht/source/Irrlicht/CContextEGL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct ContextEGLParams
8383
bool force_legacy_device;
8484
bool handle_srgb;
8585
bool with_alpha_channel;
86-
bool vsync_enabled;
86+
int swap_interval;
8787
int pbuffer_width;
8888
int pbuffer_height;
8989
};

lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ bool CIrrDeviceWayland::initEGL()
10951095
egl_params.force_legacy_device = CreationParams.ForceLegacyDevice;
10961096
egl_params.handle_srgb = CreationParams.HandleSRGB;
10971097
egl_params.with_alpha_channel = CreationParams.WithAlphaChannel;
1098-
egl_params.vsync_enabled = CreationParams.Vsync;
1098+
egl_params.swap_interval = CreationParams.SwapInterval;
10991099
egl_params.platform = CEGL_PLATFORM_WAYLAND;
11001100
egl_params.window = m_egl_window;
11011101
egl_params.display = m_display;

lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace video
8484
egl_params.handle_srgb = Params.HandleSRGB;
8585
egl_params.force_legacy_device = Params.ForceLegacyDevice;
8686
egl_params.with_alpha_channel = Params.WithAlphaChannel;
87-
egl_params.vsync_enabled = Params.Vsync;
87+
egl_params.swap_interval = Params.SwapInterval;
8888

8989
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
9090
egl_params.window = (EGLNativeWindowType)(data.OpenGLWin32.HWnd);

lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
574574

575575
genericDriverInit();
576576

577-
extGlSwapInterval(Params.Vsync ? 1 : 0);
577+
extGlSwapInterval(Params.SwapInterval);
578578
return true;
579579
}
580580

@@ -687,7 +687,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceLinux* device)
687687
genericDriverInit();
688688

689689
// set vsync
690-
extGlSwapInterval(Params.Vsync ? 1 : 0);
690+
extGlSwapInterval(Params.SwapInterval);
691691
return true;
692692
}
693693

lib/irrlicht/source/Irrlicht/Irrlicht.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace irr
5151
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType,
5252
const core::dimension2d<u32>& windowSize,
5353
u32 bits, bool fullscreen,
54-
bool stencilbuffer, bool vsync, IEventReceiver* res,
54+
bool stencilbuffer, int swapInterval, IEventReceiver* res,
5555
io::IFileSystem *file_system)
5656
{
5757
SIrrlichtCreationParameters p;
@@ -60,9 +60,9 @@ namespace irr
6060
p.Bits = (u8)bits;
6161
p.Fullscreen = fullscreen;
6262
p.Stencilbuffer = stencilbuffer;
63-
p.Vsync = vsync;
63+
p.SwapInterval = swapInterval;
6464
p.EventReceiver = res;
65-
p.FileSystem = file_system;
65+
p.FileSystem = file_system;
6666

6767
return createDeviceEx(p);
6868
}

lib/irrlicht/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ long GetDictionaryLong(CFDictionaryRef theDict, const void* key)
904904
if(CreationParams.DriverType == video::EDT_OPENGL)
905905
{
906906
CGLSetCurrentContext(CGLContext);
907-
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
907+
newSwapInterval = CreationParams.SwapInterval;
908908
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
909909
}
910910
}

src/config/user_config.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,10 @@ namespace UserConfigParams
838838
&m_graphics_quality,
839839
"Quality of anisotropic filtering (usual values include 2-4-8-16; 0 to disable)") );
840840

841-
PARAM_PREFIX BoolUserConfigParam m_vsync
842-
PARAM_DEFAULT( BoolUserConfigParam(false, "vsync",
841+
PARAM_PREFIX IntUserConfigParam m_swap_interval
842+
PARAM_DEFAULT( IntUserConfigParam(0, "swap_interval",
843843
&m_graphics_quality,
844-
"Whether vertical sync is enabled") );
844+
"Swap interval for vsync: 0 = disabled, 1 = full, 2 = half") );
845845
PARAM_PREFIX BoolUserConfigParam m_motionblur
846846
PARAM_DEFAULT( BoolUserConfigParam(false,
847847
"motionblur_enabled", &m_graphics_quality,

0 commit comments

Comments
 (0)