Java 类org.lwjgl.Sys 实例源码

项目:betaexpansion    文件:GuiTexturePacks.java   
protected void actionPerformed(GuiButton guibutton)
{
    if(!guibutton.enabled)
    {
        return;
    }
    if(guibutton.id == 5)
    {
        Sys.openURL((new StringBuilder()).append("file://").append(fileLocation).toString());
    } else
    if(guibutton.id == 6)
    {
        mc.displayGuiScreen(guiScreen);
    } else
    {
        guiTexturePackSlot.actionPerformed(guibutton);
    }
}
项目:PhET    文件:Cursor.java   
/**
 * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create
 * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported.
 * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values.
 * The constructor will copy the images and delays, so there's no need to keep them around.
 *
 * @param width cursor image width
 * @param height cursor image height
 * @param xHotspot the x coordinate of the cursor hotspot
 * @param yHotspot the y coordinate of the cursor hotspot
 * @param numImages number of cursor images specified. Must be 1 if animations are not supported.
 * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL.
 * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null
 * @throws LWJGLException if the cursor could not be created for any reason
 */
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
    synchronized (OpenGLPackageAccess.global_lock) {
        if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
            throw new LWJGLException("Native cursors not supported");
        images = NondirectBufferWrapper.wrapBuffer(images, width*height*numImages);
        if (delays != null)
            delays = NondirectBufferWrapper.wrapBuffer(delays, numImages);
        if (!Mouse.isCreated())
            throw new IllegalStateException("Mouse must be created before creating cursor objects");
        if (width*height*numImages > images.remaining())
            throw new IllegalArgumentException("width*height*numImages > images.remaining()");
        if (xHotspot >= width || xHotspot < 0)
            throw new IllegalArgumentException("xHotspot > width || xHotspot < 0");
        if (yHotspot >= height || yHotspot < 0)
            throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");

        Sys.initialize();

        // Hmm
        yHotspot = height - 1 - yHotspot;

        // create cursor (or cursors if multiple images supplied)
        cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
    }
}
项目:PhET    文件:SysTest.java   
/**
 * 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"); 
}
项目:PhET    文件:VBOTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:PhET    文件:VBOTest.java   
/**
 * Initialize
 */
private static void init() throws Exception {
    System.out.println("Timer resolution: " + Sys.getTimerResolution());
    // Go into orthographic projection mode.
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
    if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) {
        System.out.println("ARB VBO not supported!");
        System.exit(1);
    }
    buffer_id = glGenBuffersARB();
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer_id);
    vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    vertices.put(-50).put(-50).put(50).put(-50).put(50).put(50).put(-50).put(50);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, GL_STREAM_DRAW_ARB);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, 0);
}
项目:PhET    文件:VBOIndexTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:PhET    文件:LwjglTimer.java   
public void reset() {
    lastFrameDiff = 0;
    lastFPS = 0;
    lastTPF = 0;

    // init to -1 to indicate this is a new timer.
    oldTime = -1;
    //reset time
    startTime = Sys.getTime();

    tpf = new long[TIMER_SMOOTHNESS];
    smoothIndex = TIMER_SMOOTHNESS - 1;
    invTimerRezSmooth = ( 1f / (LWJGL_TIMER_RES * TIMER_SMOOTHNESS));

    // set tpf... -1 values will not be used for calculating the average in update()
    for ( int i = tpf.length; --i >= 0; ) {
        tpf[i] = -1;
    }
}
项目:FEMultiPlayer-V2    文件:FEMultiplayer.java   
/**
 * Disconnect from game. 
 * Allows for resetting server and client if triggered, but is not used in all situations.
 *
 * @param message the message
 */
public static void disconnectGame(String message){
    /*
    //wouldn't be hard to use something like this to reset to lobby rather than quit the game:
    //at the moment this disconnect is only in a few places between stages, i.e. while waiting
    //so it's not too bad to quit the game.
    Player leaver = null;
    for(Player p : session.getPlayers()) {
        if(p.getID() == message.origin) {
            leaver = p;
        }
    }
    session.removePlayer(leaver);
    System.out.println(leaver.getName()+" LEFT THE GAME");
     * */
    if(FEServer.getServer() != null) {
        //boot the server back to lobby
        FEServer.resetToLobbyAndKickPlayers();
    }else{
        //exit the client
        if(message!=null && !message.equals("")){
            Sys.alert("FE:MP", message);
        }
        System.exit(0);
    }
}
项目:OpenAgar    文件:GameWindow.java   
public void run() {
    System.out.println("Starting a GameWindow with LWJGL "+ Sys.getVersion());

    try {
        /* Prepare the window */
        prepareWindow();

        /* Render the window in a loop */
        renderWindow();

        /* Release the window */
        glfwDestroyWindow(window);

        /* Release input handler */
        inputHandler.release();
    }
    finally {
        /* Terminate GLFW */
        glfwTerminate();
    }

    System.out.println("Terminating a GameWindow");
}
项目:cars    文件:Remote.java   
public void run() {
  System.out.println("Hello LWJGL " + Sys.getVersion() + "!");

  try (DatagramSocket socket = new DatagramSocket()) {
    init();
    loop(socket);

    glfwDestroyWindow(window);
    keyCallback.release();
  } catch (Exception e) {
    e.printStackTrace();
  } finally {
    glfwTerminate();
    errorCallback.release();
  }
}
项目:IWannaBeTheJavaEngine    文件:Main.java   
public void run() {
    System.out.println("Hello LWJGL " + Sys.getVersion() + "!");

    objects = new LinkedList<GObject>();
    objects.add(new GObject(200,200));
    objects.add(new GObject(600,200));
    objects.add(new GObject(200,400));
    objects.add(new GObject(600,400));

    try {
        init();
        loop();

        // Release window and window callbacks
        glfwDestroyWindow(window);
        keyCallback.release();
    } finally {
        // Terminate GLFW and release the GLFWerrorfun
        glfwTerminate();
        errorCallback.release();
    }
}
项目:Resilience-Client-Source    文件:HookGuiMainMenu.java   
@Override
 protected void actionPerformed(GuiButton btn)
 {
    if(invoker.getId(btn) == 69){
        this.mc.displayGuiScreen(GuiResilienceMain.screen);
        hasClickedRes = true;
    }else if(invoker.getId(btn) == 70){
        Sys.openURL("http://resilience.krispdev.com/suggest");
    }else if(invoker.getId(btn) == 199){
btn.displayString = "Change to "+version;
        if(version.equals("1.7.9")){
            version = "1.7.6";
            Resilience.getInstance().getValues().version = 4;
        }else if(version.equals("1.7.6")){
            version = "1.7.9";
            Resilience.getInstance().getValues().version = 5;
        }
    }//else if(invoker.getId(btn) == 124124){
        //this.func_140005_i();
    //}
    super.actionPerformed(btn);
 }
项目:SpaceStationAlpha    文件:VBOIndexTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:TeacherSmash    文件:VBOTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:Wolf_game    文件:SysTest.java   
/**
 * 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"); 
}
项目:Wolf_game    文件:VBOTest.java   
/**
 * Initialize
 */
private static void init() throws Exception {
    System.out.println("Timer resolution: " + Sys.getTimerResolution());
    // Go into orthographic projection mode.
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
    if ( !GLContext.getCapabilities().GL_ARB_vertex_buffer_object ) {
        System.out.println("ARB VBO not supported!");
        System.exit(1);
    }
    buffer_id = glGenBuffersARB();
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer_id);
    vertices = ByteBuffer.allocateDirect(2 * 4 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
    vertices.put(-50).put(-50).put(50).put(-50).put(50).put(50).put(-50).put(50);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, 2 * 4 * 4, GL_STREAM_DRAW_ARB);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(2, GL_FLOAT, 0, 0);
}
项目:Wolf_game    文件:VBOIndexTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:Wolf_game    文件:MappedIndexedVBOTest.java   
/** All calculations are done in here */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:TeacherSmash    文件:SysTest.java   
/**
 * 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"); 
}
项目:SpaceStationAlpha    文件:MappedIndexedVBOTest.java   
/** All calculations are done in here */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:TeacherSmash    文件:Cursor.java   
/**
 * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create
 * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported.
 * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values.
 * The constructor will copy the images and delays, so there's no need to keep them around.
 *
 * @param width cursor image width
 * @param height cursor image height
 * @param xHotspot the x coordinate of the cursor hotspot
 * @param yHotspot the y coordinate of the cursor hotspot
 * @param numImages number of cursor images specified. Must be 1 if animations are not supported.
 * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL.
 * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null
 * @throws LWJGLException if the cursor could not be created for any reason
 */
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
    synchronized (OpenGLPackageAccess.global_lock) {
        if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
            throw new LWJGLException("Native cursors not supported");
        BufferChecks.checkBufferSize(images, width*height*numImages);
        if (delays != null)
            BufferChecks.checkBufferSize(delays, numImages);
        if (!Mouse.isCreated())
            throw new IllegalStateException("Mouse must be created before creating cursor objects");
        if (width*height*numImages > images.remaining())
            throw new IllegalArgumentException("width*height*numImages > images.remaining()");
        if (xHotspot >= width || xHotspot < 0)
            throw new IllegalArgumentException("xHotspot > width || xHotspot < 0");
        if (yHotspot >= height || yHotspot < 0)
            throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");

        Sys.initialize();

        // Hmm
        yHotspot = height - 1 - yHotspot;

        // create cursor (or cursors if multiple images supplied)
        cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
    }
}
项目:SpaceStationAlpha    文件:VBOTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:SpaceStationAlpha    文件:Cursor.java   
/**
 * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create
 * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported.
 * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values.
 * The constructor will copy the images and delays, so there's no need to keep them around.
 *
 * @param width cursor image width
 * @param height cursor image height
 * @param xHotspot the x coordinate of the cursor hotspot
 * @param yHotspot the y coordinate of the cursor hotspot
 * @param numImages number of cursor images specified. Must be 1 if animations are not supported.
 * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL.
 * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null
 * @throws LWJGLException if the cursor could not be created for any reason
 */
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
    synchronized (OpenGLPackageAccess.global_lock) {
        if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
            throw new LWJGLException("Native cursors not supported");
        BufferChecks.checkBufferSize(images, width*height*numImages);
        if (delays != null)
            BufferChecks.checkBufferSize(delays, numImages);
        if (!Mouse.isCreated())
            throw new IllegalStateException("Mouse must be created before creating cursor objects");
        if (width*height*numImages > images.remaining())
            throw new IllegalArgumentException("width*height*numImages > images.remaining()");
        if (xHotspot >= width || xHotspot < 0)
            throw new IllegalArgumentException("xHotspot > width || xHotspot < 0");
        if (yHotspot >= height || yHotspot < 0)
            throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");

        Sys.initialize();

        // Hmm
        yHotspot = height - 1 - yHotspot;

        // create cursor (or cursors if multiple images supplied)
        cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
    }
}
项目:GPVM    文件:Cursor.java   
/**
 * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create
 * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported.
 * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values.
 * The constructor will copy the images and delays, so there's no need to keep them around.
 *
 * @param width cursor image width
 * @param height cursor image height
 * @param xHotspot the x coordinate of the cursor hotspot
 * @param yHotspot the y coordinate of the cursor hotspot
 * @param numImages number of cursor images specified. Must be 1 if animations are not supported.
 * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL.
 * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null
 * @throws LWJGLException if the cursor could not be created for any reason
 */
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
    synchronized (OpenGLPackageAccess.global_lock) {
        if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
            throw new LWJGLException("Native cursors not supported");
        BufferChecks.checkBufferSize(images, width*height*numImages);
        if (delays != null)
            BufferChecks.checkBufferSize(delays, numImages);
        if (!Mouse.isCreated())
            throw new IllegalStateException("Mouse must be created before creating cursor objects");
        if (width*height*numImages > images.remaining())
            throw new IllegalArgumentException("width*height*numImages > images.remaining()");
        if (xHotspot >= width || xHotspot < 0)
            throw new IllegalArgumentException("xHotspot > width || xHotspot < 0");
        if (yHotspot >= height || yHotspot < 0)
            throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");

        Sys.initialize();

        // Hmm
        yHotspot = height - 1 - yHotspot;

        // create cursor (or cursors if multiple images supplied)
        cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
    }
}
项目:GPVM    文件:SysTest.java   
/**
 * 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"); 
}
项目:GPVM    文件:VBOIndexTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:TeacherSmash    文件:VBOIndexTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:GPVM    文件:MappedIndexedVBOTest.java   
/** All calculations are done in here */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:GPVM    文件:VBOTest.java   
/**
 * All calculations are done in here
 */
private static void mainLoop() {
    angle += 1f;
    if ( angle > 360.0f )
        angle = 0.0f;

    if ( Mouse.getDX() != 0 || Mouse.getDY() != 0 || Mouse.getDWheel() != 0 )
        System.out.println("Mouse moved " + Mouse.getDX() + " " + Mouse.getDY() + " " + Mouse.getDWheel());
    for ( int i = 0; i < Mouse.getButtonCount(); i++ )
        if ( Mouse.isButtonDown(i) )
            System.out.println("Button " + i + " down");
    if ( Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) )
        finished = true;
    for ( int i = 0; i < Keyboard.getNumKeyboardEvents(); i++ ) {
        Keyboard.next();
        if ( Keyboard.getEventKey() == Keyboard.KEY_ESCAPE && Keyboard.getEventKeyState() )
            finished = true;
        if ( Keyboard.getEventKey() == Keyboard.KEY_T && Keyboard.getEventKeyState() )
            System.out.println("Current time: " + Sys.getTime());
    }
}
项目:GPVM    文件:Cursor.java   
/**
 * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create
 * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported.
 * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values.
 * The constructor will copy the images and delays, so there's no need to keep them around.
 *
 * @param width cursor image width
 * @param height cursor image height
 * @param xHotspot the x coordinate of the cursor hotspot
 * @param yHotspot the y coordinate of the cursor hotspot
 * @param numImages number of cursor images specified. Must be 1 if animations are not supported.
 * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL.
 * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null
 * @throws LWJGLException if the cursor could not be created for any reason
 */
public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
    synchronized (OpenGLPackageAccess.global_lock) {
        if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
            throw new LWJGLException("Native cursors not supported");
        BufferChecks.checkBufferSize(images, width*height*numImages);
        if (delays != null)
            BufferChecks.checkBufferSize(delays, numImages);
        if (!Mouse.isCreated())
            throw new IllegalStateException("Mouse must be created before creating cursor objects");
        if (width*height*numImages > images.remaining())
            throw new IllegalArgumentException("width*height*numImages > images.remaining()");
        if (xHotspot >= width || xHotspot < 0)
            throw new IllegalArgumentException("xHotspot > width || xHotspot < 0");
        if (yHotspot >= height || yHotspot < 0)
            throw new IllegalArgumentException("yHotspot > height || yHotspot < 0");

        Sys.initialize();

        // Hmm
        yHotspot = height - 1 - yHotspot;

        // create cursor (or cursors if multiple images supplied)
        cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays);
    }
}
项目:BaseClient    文件:Config.java   
private static void checkOpenGlCaps()
{
    log("");
    log(getVersion());
    log("Build: " + getBuild());
    log("OS: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
    log("Java: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor"));
    log("VM: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
    log("LWJGL: " + Sys.getVersion());
    openGlVersion = GL11.glGetString(GL11.GL_VERSION);
    openGlRenderer = GL11.glGetString(GL11.GL_RENDERER);
    openGlVendor = GL11.glGetString(GL11.GL_VENDOR);
    log("OpenGL: " + openGlRenderer + ", version " + openGlVersion + ", " + openGlVendor);
    log("OpenGL Version: " + getOpenGlVersionString());

    if (!GLContext.getCapabilities().OpenGL12)
    {
        log("OpenGL Mipmap levels: Not available (GL12.GL_TEXTURE_MAX_LEVEL)");
    }

    fancyFogAvailable = GLContext.getCapabilities().GL_NV_fog_distance;

    if (!fancyFogAvailable)
    {
        log("OpenGL Fancy fog: Not available (GL_NV_fog_distance)");
    }

    occlusionAvailable = GLContext.getCapabilities().GL_ARB_occlusion_query;

    if (!occlusionAvailable)
    {
        log("OpenGL Occlussion culling: Not available (GL_ARB_occlusion_query)");
    }

    int i = Minecraft.getGLMaximumTextureSize();
    dbg("Maximum texture size: " + i + "x" + i);
}
项目:BaseClient    文件:Config.java   
private static void checkOpenGlCaps()
{
    log("");
    log(getVersion());
    log("" + new Date());
    log("OS: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
    log("Java: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor"));
    log("VM: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
    log("LWJGL: " + Sys.getVersion());
    openGlVersion = GL11.glGetString(GL11.GL_VERSION);
    openGlRenderer = GL11.glGetString(GL11.GL_RENDERER);
    openGlVendor = GL11.glGetString(GL11.GL_VENDOR);
    log("OpenGL: " + openGlRenderer + ", version " + openGlVersion + ", " + openGlVendor);
    log("OpenGL Version: " + getOpenGlVersionString());

    if (!GLContext.getCapabilities().OpenGL12)
    {
        log("OpenGL Mipmap levels: Not available (GL12.GL_TEXTURE_MAX_LEVEL)");
    }

    fancyFogAvailable = GLContext.getCapabilities().GL_NV_fog_distance;

    if (!fancyFogAvailable)
    {
        log("OpenGL Fancy fog: Not available (GL_NV_fog_distance)");
    }

    occlusionAvailable = GLContext.getCapabilities().GL_ARB_occlusion_query;

    if (!occlusionAvailable)
    {
        log("OpenGL Occlussion culling: Not available (GL_ARB_occlusion_query)");
    }

    int i = Minecraft.getGLMaximumTextureSize();
    dbg("Maximum texture size: " + i + "x" + i);
}
项目:Backmemed    文件:Config.java   
private static void checkOpenGlCaps()
{
    log("");
    log(getVersion());
    log("Build: " + getBuild());
    log("OS: " + System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"));
    log("Java: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor"));
    log("VM: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
    log("LWJGL: " + Sys.getVersion());
    openGlVersion = GL11.glGetString(GL11.GL_VERSION);
    openGlRenderer = GL11.glGetString(GL11.GL_RENDERER);
    openGlVendor = GL11.glGetString(GL11.GL_VENDOR);
    log("OpenGL: " + openGlRenderer + ", version " + openGlVersion + ", " + openGlVendor);
    log("OpenGL Version: " + getOpenGlVersionString());

    if (!GLContext.getCapabilities().OpenGL12)
    {
        log("OpenGL Mipmap levels: Not available (GL12.GL_TEXTURE_MAX_LEVEL)");
    }

    fancyFogAvailable = GLContext.getCapabilities().GL_NV_fog_distance;

    if (!fancyFogAvailable)
    {
        log("OpenGL Fancy fog: Not available (GL_NV_fog_distance)");
    }

    occlusionAvailable = GLContext.getCapabilities().GL_ARB_occlusion_query;

    if (!occlusionAvailable)
    {
        log("OpenGL Occlussion culling: Not available (GL_ARB_occlusion_query)");
    }

    int i = TextureUtils.getGLMaximumTextureSize();
    dbg("Maximum texture size: " + i + "x" + i);
}
项目:4Space-5    文件:ItemRendererBeamReflector.java   
public void transform(ItemRenderType type)
{
    if (type == ItemRenderType.EQUIPPED)
    {
        GL11.glTranslatef(0.6F, 0.45F, 0.6F);
        GL11.glRotatef(185, 1, 0, 0);
        GL11.glRotatef(40, 0, 1, 0);
        GL11.glRotatef(0, 0, 0, 1);
        GL11.glScalef(2.0F, 2.0F, 2.0F);
    }

    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON)
    {
        GL11.glScalef(2.2F, 2.2F, 2.2F);
        GL11.glTranslatef(0.291F, 0.2F, 0.3F);
        GL11.glRotatef(180.0F, 0.0F, 0F, 1F);
    }

    GL11.glScalef(-0.4F, -0.4F, 0.4F);

    if (type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY)
    {
        if (type == ItemRenderType.INVENTORY)
        {
            GL11.glTranslatef(0.0F, 1.45F, 0.0F);
            GL11.glScalef(2.0F, 2.0F, 2.0F);
            GL11.glRotatef(180, 0, 0, 1);
            GL11.glRotatef(180, 0, 1, 0);
        }
        else
        {
            GL11.glRotatef(Sys.getTime() / 90F % 360F, 0F, 1F, 0F);
            GL11.glScalef(2F, -2F, 2F);
        }

        GL11.glScalef(1.3F, 1.3F, 1.3F);
    }
}
项目:4Space-5    文件:ItemRendererBeamReceiver.java   
public void transform(ItemRenderType type)
{
    if (type == ItemRenderType.EQUIPPED)
    {
        GL11.glTranslatef(1.0F, -0.2F, 0.9F);
        GL11.glRotatef(185, 1, 0, 0);
        GL11.glRotatef(40, 0, 1, 0);
        GL11.glRotatef(0, 0, 0, 1);
        GL11.glScalef(3.2F, 3.2F, 3.2F);
    }

    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON)
    {
        GL11.glScalef(2.0F, 2.0F, 2.0F);
        GL11.glTranslatef(-0.1F, 1.0F, 0.35F);
    }

    GL11.glScalef(-0.4F, -0.4F, 0.4F);

    if (type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY)
    {
        if (type == ItemRenderType.INVENTORY)
        {
            GL11.glTranslatef(0.0F, 2.45F, -0.8F);
            GL11.glScalef(3.0F, 3.0F, 3.0F);
            GL11.glRotatef(180, 0, 0, 1);
            GL11.glRotatef(-90, 0, 1, 0);
        }
        else
        {
            GL11.glTranslatef(0, -3.9F, 0);
            GL11.glRotatef(Sys.getTime() / 90F % 360F, 0F, 1F, 0F);
            GL11.glScalef(4.0F, 4.0F, 4.0F);
        }

        GL11.glScalef(1.3F, 1.3F, 1.3F);
    }
}
项目:4Space-5    文件:AsteroidsEventHandlerClient.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onBodyRender(CelestialBodyRenderEvent.Pre renderEvent)
{
    if (renderEvent.celestialBody.equals(AsteroidsModule.planetAsteroids))
    {
        GL11.glRotatef(Sys.getTime() / 10.0F % 360, 0, 0, 1);
    }
}
项目:PhET    文件:PickingTest.java   
public static void main( String[] args ) {
    try {
        StartupUtils.setupLibraries();
    }
    catch ( IOException e ) {
        e.printStackTrace();
        throw new RuntimeException( e );
    }

    timerTicksPerSecond = Sys.getTimerResolution();

    new PickingTest().execute();
}
项目:PhET    文件:PickingTest.java   
/**
 * Get the high resolution time in milliseconds
 *
 * @return The high resolution time in milliseconds
 */
public static long getTime() {
    // we get the "timer ticks" from the high resolution timer
    // multiply by 1000 so our end result is in milliseconds
    // then divide by the number of ticks in a second giving
    // us a nice clear time in milliseconds
    return ( Sys.getTime() * 1000 ) / timerTicksPerSecond;
}
项目:PhET    文件:Game.java   
/**
 * Get the high resolution time in milliseconds
 *
 * @return The high resolution time in milliseconds
 */
public static long getTime() {
    // we get the "timer ticks" from the high resolution timer
    // multiply by 1000 so our end result is in milliseconds
    // then divide by the number of ticks in a second giving
    // us a nice clear time in milliseconds
    return (Sys.getTime() * 1000) / timerTicksPerSecond;
}
项目:PhET    文件:Game.java   
/**
 * Application init
 * @param args Commandline args
 */
public static void main(String[] args) {
    try {
        init();
        run();
    } catch (Exception e) {
        e.printStackTrace(System.err);
        Sys.alert(GAME_TITLE, "An error occured and the game will exit.");
    } finally {
        cleanup();
    }

    System.exit(0);
}