Top Description Inners Fields Constructors Methods
org.lwjgl.opengl

pack-priv Class Sync

extends Object
Class Inheritance
Imports
org.lwjgl.Sys

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 static class

Field Summary

Modifier and TypeField and Description
private static boolean
initialised

whether the initialisation code has run

private static final long
NANOS_IN_SECOND

number of nano seconds in a second

private static long
nextFrame

The time to sleep/yield until the next frame

private static Sync.RunningAvg
sleepDurations

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

private static Sync.RunningAvg

Constructor Summary

AccessConstructor and Description
pack-priv
Sync()

Method Summary

Modifier and TypeMethod and Description
private static long

Returns:

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

Get the system time in nano seconds

private static void
initialise()

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

public static 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 static 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 static long nextFrame

The time to sleep/yield until the next frame

sleepDurationsback to summary
private static Sync.RunningAvg sleepDurations

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

yieldDurationsback to summary
private static Sync.RunningAvg yieldDurations

Constructor Detail

Syncback to summary
pack-priv Sync()

Method Detail

getTimeback to summary
private static long getTime()

Get the system time in nano seconds

Returns:long

will return the current time in nano's

initialiseback to summary
private static 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 static 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

org.lwjgl.opengl 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)