當前位置: 首頁>>代碼示例>>Java>>正文


Java Sys.getTimerResolution方法代碼示例

本文整理匯總了Java中org.lwjgl.Sys.getTimerResolution方法的典型用法代碼示例。如果您正苦於以下問題:Java Sys.getTimerResolution方法的具體用法?Java Sys.getTimerResolution怎麽用?Java Sys.getTimerResolution使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.Sys的用法示例。


在下文中一共展示了Sys.getTimerResolution方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testTimer

import org.lwjgl.Sys; //導入方法依賴的package包/類
/**
 * Tests the timer
 */
private void testTimer() {
  long resolution = Sys.getTimerResolution();
  long time = Sys.getTime();
  
  System.out.println("==== Test Timer ====");
  System.out.println("Resolution of timer (ticks per second): " + resolution);
  System.out.println("Current time: " + time);
  System.out.println("Sleeping for 2 seconds, using Thread.sleep()");

  pause(2000);

  long time2 = Sys.getTime();
  System.out.println("Current time: " + time2);
  System.out.println("Actually slept for: " + ((time2 - time) / (float) resolution) + " seconds");
  System.out.println("---- Test Timer ----\n"); 
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:20,代碼來源:SysTest.java

示例2: main

import org.lwjgl.Sys; //導入方法依賴的package包/類
public static void main( String[] args ) {
    try {
        StartupUtils.setupLibraries();
    }
    catch ( IOException e ) {
        e.printStackTrace();
        throw new RuntimeException( e );
    }

    timerTicksPerSecond = Sys.getTimerResolution();

    new PickingTest().execute();
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:14,代碼來源:PickingTest.java

示例3: tick

import org.lwjgl.Sys; //導入方法依賴的package包/類
/**
 * Get the next time update from the system's hires timer. This method should
 * be called once per main loop iteration; all timers are updated simultaneously
 * from it.
 */
public static void tick() {
	currentTime = Sys.getTime();

	// Periodically refresh the timer resolution:
	queryCount ++;
	if (queryCount > QUERY_INTERVAL) {
		queryCount = 0;
		resolution = Sys.getTimerResolution();
	}
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:16,代碼來源:Timer.java

示例4: busyWait

import org.lwjgl.Sys; //導入方法依賴的package包/類
/**
 * Busy waits for a specified number of seconds
 * 
 * @param priority Priority to busy wait in
 * @param seconds Number of seconds to busy wait
 * @param message Message to print to user
 */
private void busyWait(int priority, int seconds, String message) {
  long future = Sys.getTime() + (Sys.getTimerResolution() * seconds);
  
  System.out.print(message);
  
  // waste some cycles
  while (Sys.getTime() < future) {
  }
  
  System.out.println("done");
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:19,代碼來源:SysTest.java

示例5: wiggleMouse

import org.lwjgl.Sys; //導入方法依賴的package包/類
private void wiggleMouse() {
	System.out.print("Please move the mouse around");

	long statustime = Sys.getTime();
	long endtime = Sys.getTime() + Sys.getTimerResolution() * 5;

	while (Sys.getTime() < endtime) {
     Display.update();

     // empty mouse buffer
     while(Mouse.next());

		position.x += Mouse.getDX();
		position.y += Mouse.getDY();

     if(position.x<0) {
       position.x = 0;
     } else if (position.x>640-60) {
       position.x = 640-60;
     }

     if(position.y < 0) {
       position.y = 0;
     } else if (position.y>480-30) {
       position.y = 480-30;
     }

		render();

		if (Sys.getTime() - statustime > Sys.getTimerResolution()) {
			System.out.print(".");
			statustime = Sys.getTime();
		}
	}
	System.out.println("thank you");
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:37,代碼來源:MouseCreationTest.java

示例6: run

import org.lwjgl.Sys; //導入方法依賴的package包/類
private void run() {
	long startTime = System.currentTimeMillis() + 5000;
	long fps = 0;

	long time = Sys.getTime();
	final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);

	renderer.render(false, true, 0);

	while ( run ) {
		Display.processMessages();
		handleInput();

		glClear(GL_COLOR_BUFFER_BIT);

		final long currTime = Sys.getTime();
		final int delta = (int)(currTime - time);
		if ( smooth || delta >= ticksPerUpdate ) {
			renderer.render(render, animate, delta);
			time = currTime;
		} else
			renderer.render(render, false, 0);

		Display.update(false);
		//Display.sync(60);

		if ( startTime > System.currentTimeMillis() ) {
			fps++;
		} else {
			long timeUsed = 5000 + (startTime - System.currentTimeMillis());
			startTime = System.currentTimeMillis() + 5000;
			System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
			System.out.println("\tAnimation: " + (animateTime / fps / 1000) + "us");
			animateTime = 0;
			fps = 0;
		}
	}
}
 
開發者ID:Arcbe,項目名稱:GPVM,代碼行數:39,代碼來源:SpriteShootout.java

示例7: run

import org.lwjgl.Sys; //導入方法依賴的package包/類
private void run() {
	long startTime = System.currentTimeMillis() + 5000;
	long fps = 0;

	long time = Sys.getTime();
	final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);

	renderer.render(false, true, 0);

	while ( run ) {
		Display.processMessages();
		handleInput();

		glClear(GL_COLOR_BUFFER_BIT);

		final long currTime = Sys.getTime();
		final int delta = (int)(currTime - time);
		if ( smooth || delta >= ticksPerUpdate ) {
			renderer.render(render, animate, delta);
			time = currTime;
		} else
			renderer.render(render, false, 0);

		Display.update(false);
		//Display.sync(60);

		if ( startTime > System.currentTimeMillis() ) {
			fps++;
		} else {
			long timeUsed = 5000 + (startTime - System.currentTimeMillis());
			startTime = System.currentTimeMillis() + 5000;
			System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
			System.out.println("Animation: " + animateTime / fps);
			animateTime = 0;
			fps = 0;
		}
	}
}
 
開發者ID:CodeConglomerate,項目名稱:TeacherSmash,代碼行數:39,代碼來源:SpriteShootoutMapped.java

示例8: run

import org.lwjgl.Sys; //導入方法依賴的package包/類
private void run() {
	long startTime = System.currentTimeMillis() + 5000;
	long fps = 0;

	long time = Sys.getTime();
	final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);

	renderer.render(false, true, 0);

	while ( run ) {
		Display.processMessages();
		handleInput();

		glClear(GL_COLOR_BUFFER_BIT);

		final long currTime = Sys.getTime();
		final int delta = (int)(currTime - time);
		if ( smooth || delta >= ticksPerUpdate ) {
			renderer.render(render, animate, delta);
			time = currTime;
		} else
			renderer.render(render, false, 0);

		Display.update(false);

		if ( startTime > System.currentTimeMillis() ) {
			fps++;
		} else {
			long timeUsed = 5000 + (startTime - System.currentTimeMillis());
			startTime = System.currentTimeMillis() + 5000;
			System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
			fps = 0;
		}
	}
}
 
開發者ID:CodeConglomerate,項目名稱:TeacherSmash,代碼行數:36,代碼來源:SpriteShootoutCL.java

示例9: run

import org.lwjgl.Sys; //導入方法依賴的package包/類
private void run() {
	long startTime = System.currentTimeMillis() + 5000;
	long fps = 0;

	long time = Sys.getTime();
	final int ticksPerUpdate = (int)(Sys.getTimerResolution() / ANIMATION_TICKS);

	renderer.render(false, true, 0);

	while ( run ) {
		Display.processMessages();
		handleInput();

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		final long currTime = Sys.getTime();
		final int delta = (int)(currTime - time);
		if ( smooth || delta >= ticksPerUpdate ) {
			renderer.render(render, animate, delta);
			time = currTime;
		} else
			renderer.render(render, false, 0);

		Display.update(false);
		//Display.sync(60);

		if ( startTime > System.currentTimeMillis() ) {
			fps++;
		} else {
			long timeUsed = 5000 + (startTime - System.currentTimeMillis());
			startTime = System.currentTimeMillis() + 5000;
			System.out.println("FPS: " + (Math.round(fps / (timeUsed / 1000.0) * 10) / 10.0) + ", Balls: " + ballCount);
			fps = 0;
		}
	}
}
 
開發者ID:Superloup10,項目名稱:Wolf_game,代碼行數:37,代碼來源:SpriteShootout2P.java

示例10: getCurrentTime

import org.lwjgl.Sys; //導入方法依賴的package包/類
private static long getCurrentTime() {
	return Sys.getTime() * 1000 / Sys.getTimerResolution();
}
 
開發者ID:marcioz98,項目名稱:MRCEngine,代碼行數:4,代碼來源:DisplayManager.java

示例11: getSystemTime

import org.lwjgl.Sys; //導入方法依賴的package包/類
/**
 * Gets the system time in milliseconds.
 */
public static long getSystemTime()
{
    return Sys.getTime() * 1000L / Sys.getTimerResolution();
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:Minecraft.java

示例12: getCurrentTime

import org.lwjgl.Sys; //導入方法依賴的package包/類
private long getCurrentTime(){
	return Sys.getTime()*1000/Sys.getTimerResolution();
}
 
開發者ID:TheThinMatrix,項目名稱:OcclusionQueries,代碼行數:4,代碼來源:DisplayManager.java

示例13: getSystemTime

import org.lwjgl.Sys; //導入方法依賴的package包/類
/**
 * Gets the system time in milliseconds.
 */
public static long getSystemTime() {
	return Sys.getTime() * 1000L / Sys.getTimerResolution();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:7,代碼來源:Minecraft.java

示例14: getTime

import org.lwjgl.Sys; //導入方法依賴的package包/類
private long getTime() {
	return (Sys.getTime() * 1000) / Sys.getTimerResolution();
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:4,代碼來源:UsingEntities.java

示例15: getTime

import org.lwjgl.Sys; //導入方法依賴的package包/類
private static long getTime() {
    return (Sys.getTime() * 1000) / Sys.getTimerResolution();
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:4,代碼來源:AdvancedRendering.java


注:本文中的org.lwjgl.Sys.getTimerResolution方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。