APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.backends.lwjgl3

pack-priv Class Sync

extends Object
Class Inheritance
Static Imports
org.lwjgl.glfw.GLFW.glfwGetTime

A highly accurate sync method that continually adapts to the system it runs on to provide reliable results.
Authors
Riven, kappaOne

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private boolean
initialised

whether the initialisation code has run

private static final long
NANOS_IN_SECOND

number of nano seconds in a second

private long
nextFrame

The time to sleep/yield until the next frame

private Sync.RunningAvg
sleepDurations

for calculating the averages the previous sleep/yield times are stored

private Sync.RunningAvg

Constructor Summary

AccessConstructor and Description
public
Sync()

Method Summary

Modifier and TypeMethod and Description
private long

Returns:

will return the current time in nano's
getTime
()

Get the system time in nano seconds

private void
initialise()

This method will initialise the sync method by setting initial values for sleepDurations/yieldDurations and nextFrame.

public void
sync(int
- the desired frame rate, in frames per second
fps
)

An accurate sync method that will attempt to run at a constant frame rate.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

initialisedback to summary
private boolean initialised

whether the initialisation code has run

NANOS_IN_SECONDback to summary
private static final long NANOS_IN_SECOND

number of nano seconds in a second

nextFrameback to summary
private long nextFrame

The time to sleep/yield until the next frame

sleepDurationsback to summary
private Sync.RunningAvg sleepDurations

for calculating the averages the previous sleep/yield times are stored

yieldDurationsback to summary
private Sync.RunningAvg yieldDurations

Constructor Detail

Syncback to summary
public Sync()

Method Detail

getTimeback to summary
private long getTime()

Get the system time in nano seconds

Returns:long

will return the current time in nano's

initialiseback to summary
private void initialise()

This method will initialise the sync method by setting initial values for sleepDurations/yieldDurations and nextFrame. If running on windows it will start the sleep timer fix.

syncback to summary
public void sync(int fps)

An accurate sync method that will attempt to run at a constant frame rate. It should be called once every frame.

Parameters
fps:int

- the desired frame rate, in frames per second

com.badlogic.gdx.backends.lwjgl3 back to summary

private Class Sync.RunningAvg

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final float
private static final long
private int
private final long[]

Constructor Summary

AccessConstructor and Description
public
RunningAvg(int slotCount)

Method Summary

Modifier and TypeMethod and Description
public void
add(long value)

public long
avg()

public void
public void
init(long value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DAMPEN_FACTORback to summary
private static final float DAMPEN_FACTOR
DAMPEN_THRESHOLDback to summary
private static final long DAMPEN_THRESHOLD
offsetback to summary
private int offset
slotsback to summary
private final long[] slots

Constructor Detail

RunningAvgback to summary
public RunningAvg(int slotCount)

Method Detail

addback to summary
public void add(long value)
avgback to summary
public long avg()
dampenForLowResTickerback to summary
public void dampenForLowResTicker()
initback to summary
public void init(long value)