org.lwjgl.glfw.GLFW.glfwGetTime()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(473)

本文整理了Java中org.lwjgl.glfw.GLFW.glfwGetTime()方法的一些代码示例,展示了GLFW.glfwGetTime()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwGetTime()方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwGetTime

GLFW.glfwGetTime介绍

[英]Returns the value of the GLFW timer. Unless the timer has been set using #glfwSetTime, the timer measures time elapsed since GLFW was initialized.

The resolution of the timer is system dependent, but is usually on the order of a few micro- or nanoseconds. It uses the highest-resolution monotonic time source on each supported platform.

This function may be called from any thread. Reading and writing of the internal timer offset is not atomic, so it needs to be externally synchronized with calls to #glfwSetTime.
[中]返回GLFW计时器的值。除非已使用#glfwSetTime设置计时器,否则计时器将测量自GLFW初始化以来经过的时间。
计时器的分辨率取决于系统,但通常为几微秒或纳秒。它在每个支持的平台上使用最高分辨率的单调时间源。
此函数可以从任何线程调用。内部计时器偏移量的读取和写入不是原子的,因此需要与对#glfwSetTime的调用进行外部同步。

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
  public long getInputTimeNanos() {
    return (long) (glfwGetTime() * 1000000000);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public long getInputTimeNanos() {
  return (long) (glfwGetTime() * 1000000000);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public long getInputTimeNanos() {
  return (long) (glfwGetTime() * 1000000000);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public long getInputTimeNanos() {
    return (long) (glfwGetTime() * 1000000000);
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public void update() {
  // Manage cursor animation
  if (currentCursor != null && currentCursor.length > 1) {
    double now = glfwGetTime();
    double frameTime = (glfwGetTime() - currentCursorFrameStartTime) * 1000;
    if (currentCursorDelays == null || frameTime >= currentCursorDelays.get(currentCursorFrame)) {
      currentCursorFrame = ++currentCursorFrame % currentCursor.length;
      currentCursorFrameStartTime = now;
      glfwSetCursor(context.getWindowHandle(), currentCursor[currentCursorFrame]);
    }
  }
  // Process events
  while (!mouseMotionEvents.isEmpty()) {
    listener.onMouseMotionEvent(mouseMotionEvents.poll());
  }
  while (!mouseButtonEvents.isEmpty()) {
    listener.onMouseButtonEvent(mouseButtonEvents.poll());
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
public void setNativeCursor(final JmeCursor jmeCursor) {
  if (jmeCursor != null) {
    final long[] glfwCursor = jmeToGlfwCursorMap.computeIfAbsent(jmeCursor, GlfwMouseInput::createGlfwCursor);
    currentCursorFrame = 0;
    currentCursor = glfwCursor;
    currentCursorDelays = null;
    currentCursorFrameStartTime = glfwGetTime();
    if (jmeCursor.getImagesDelay() != null) {
      currentCursorDelays = jmeCursor.getImagesDelay();
    }
    glfwSetCursor(context.getWindowHandle(), glfwCursor[currentCursorFrame]);
  } else {
    currentCursor = null;
    currentCursorDelays = null;
    glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL);
  }
}

代码示例来源:origin: nifty-gui/nifty-gui

@Override
public long getMsTime() {
 return (long) (GLFW.glfwGetTime() * CONVERSATION_FACTOR);
}

代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3

@Override
public long getInputTimeNanos() {
  return (long) (glfwGetTime() * 1000000000);
}

代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3

public long getInputTimeNanos() {
    return (long) (glfwGetTime() * 1000000000);
  }
}

代码示例来源:origin: jsettlers/settlers-remake

@Override
  public void invoke(long window, int button, int action, int mods) {
    UIPoint point = last_point;
    if(action == GLFW.GLFW_PRESS) {
      switch(button) {
        case GLFW.GLFW_MOUSE_BUTTON_1:
          startDraw(point);
          break;
        case GLFW.GLFW_MOUSE_BUTTON_2:
          presstime = GLFW.glfwGetTime();
        case GLFW.GLFW_MOUSE_BUTTON_3:
          startPan(point);
          break;
      }
    } else {
      switch(button) {
        case GLFW.GLFW_MOUSE_BUTTON_1:
          endDraw(point);
          break;
        case GLFW.GLFW_MOUSE_BUTTON_2:
          presstime = -1;
        case GLFW.GLFW_MOUSE_BUTTON_3:
          endPan(point);
          break;
      }
    }
  }
};

代码示例来源:origin: jsettlers/settlers-remake

@Override
  public void invoke(long window, double xpos, double ypos) {
    last_point = new UIPoint(xpos, height - ypos);
    updateHoverPosition(last_point);
    if(presstime+0.1<GLFW.glfwGetTime()) {
      updatePanPosition(last_point);
      updateDrawPosition(last_point);
    }
  }
};

代码示例来源:origin: SpinyOwl/legui

private void updateCaret(Vector4f bc) {
  oppositeBlackOrWhite(bc, caretColor);
  caretColor.w = (float) Math.abs(GLFW.glfwGetTime() % 1 * 2 - 1);
}

代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3

@Override
public void update() {
  // Manage cursor animation
  if (currentCursor != null && currentCursor.length > 1) {
    double now = glfwGetTime();
    double frameTime = (glfwGetTime() - currentCursorFrameStartTime) * 1000;
    if (currentCursorDelays == null || frameTime >= currentCursorDelays.get(currentCursorFrame)) {
      currentCursorFrame = ++currentCursorFrame % currentCursor.length;
      currentCursorFrameStartTime = now;
      glfwSetCursor(context.getWindowHandle(), currentCursor[currentCursorFrame]);
    }
  }
  // Process events
  while (!mouseMotionEvents.isEmpty()) {
    listener.onMouseMotionEvent(mouseMotionEvents.poll());
  }
  while (!mouseButtonEvents.isEmpty()) {
    listener.onMouseButtonEvent(mouseButtonEvents.poll());
  }
}

代码示例来源:origin: SpinyOwl/legui

private void drawSelectionAndUpdateCaret(long context, Vector4f rect, Vector4f bc, Vector4f highlightColor, int startSelectionIndex, int endSelectionIndex,
                     boolean focused, float startSelectionX, float endSelectionX, Float poffset) {
  if (focused) {
    // calculate caret color based on time
    oppositeBlackOrWhite(bc, caretColor);
    caretColor.w = (float) Math.abs(GLFW.glfwGetTime() % 1 * 2 - 1);
    // draw selection
    if (startSelectionIndex != endSelectionIndex) {
      NvgShapes.drawRect(context, new Vector4f(startSelectionX - poffset, rect.y, endSelectionX - startSelectionX, rect.w), highlightColor);
    }
  }
}

代码示例来源:origin: SpinyOwl/legui

/**
 * This method used to process animations.
 */
public void runAnimations() {
  double currentTime = GLFW.glfwGetTime();
  double delta = currentTime - previousTime;
  List<Animation> initializeList = new ArrayList<>(animationsToInitialize);
  for (Animation animation : initializeList) {
    animation.beforeAnimation();
    animationsToInitialize.remove(animation);
    animations.add(animation);
  }
  List<Animation> processList = new ArrayList<>(animations);
  for (Animation animation : processList) {
    if (animationsToRemove.contains(animation)) {
      animationsToRemove.remove(animation);
      animations.remove(animation);
      animationsToDestroy.add(animation);
    } else if (animation.animate(delta)) {
      animations.remove(animation);
      animationsToDestroy.add(animation);
    }
  }
  List<Animation> destroyList = new ArrayList<>(animationsToDestroy);
  for (Animation animation : destroyList) {
    animation.afterAnimation();
    animationsToDestroy.remove(animation);
  }
  previousTime = currentTime;
}

代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3

@Override
public void setNativeCursor(JmeCursor jmeCursor) {
  if (jmeCursor != null) {
    long[] glfwCursor = jmeToGlfwCursorMap.get(jmeCursor);
    if (glfwCursor == null) {
      glfwCursor = createGlfwCursor(jmeCursor);
      jmeToGlfwCursorMap.put(jmeCursor, glfwCursor);
    }
    currentCursorFrame = 0;
    currentCursor = glfwCursor;
    currentCursorDelays = null;
    currentCursorFrameStartTime = glfwGetTime();
    if (jmeCursor.getImagesDelay() != null) {
      currentCursorDelays = jmeCursor.getImagesDelay();
    }
    glfwSetCursor(context.getWindowHandle(), glfwCursor[currentCursorFrame]);
  } else {
    currentCursor = null;
    currentCursorDelays = null;
    glfwSetCursor(context.getWindowHandle(), MemoryUtil.NULL);
  }
}

代码示例来源:origin: SpinyOwl/legui

caretColor.w = (float) Math.abs(GLFW.glfwGetTime() % 1 * 2 - 1);

相关文章

GLFW类方法