亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? glart_9_timing.java

?? OPENGL animation timing tutorial using LWJGL engine.
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;

import org.lwjgl.Sys;
import org.lwjgl.opengl.*;
import org.lwjgl.opengl.glu.GLU;
import org.lwjgl.input.Keyboard;

/**
 * GLART_9_timing.java
 *
 * Simulates a clock with second hand moving in real-time.  Demonstrates
 * use of a timing loop to control program execution speed.
 * 
 * The frequency at which screen images are drawn is called the 
 * framerate and is usually measure in frames per second.  The goal
 * in this demo is to animate a clock at the same speed (real time)
 * no matter how fast or slow the system is rendering.
 * 
 * Since cpu performance varies, program execution speed can vary from 
 * one computer to another.  If you move an animation a fixed amount
 * in each render(), then the animation will move at different rates on 
 * different computers, as render() is called more often on the faster
 * cpu.  
 * 
 * VSync also affects the framerate.  Display.setVSyncEnabled(true)
 * will synchronize OpenGL frame updates with the monitor refresh rate.  
 * Most monitors refresh the screen 60 or 75 per second, and VSync will 
 * force Display.update() to wait till the monitor is ready to draw.  
 * This controls the refresh rate somewhat, but monitors can have different refresh
 * rates, and slower graphics cards will slow this down the refresh rate.  
 * 
 * To insure that animations run at the same
 * rate across various computers, you need to move animations according
 * to actual time elapsed, not frame renders.
 * 
 * Check how much time has elapsed since the last frame rendered, then
 * "step" the simulation forward by that amount of time.  The simulation
 * advances in proportion to the time elapsed, and keeps track of 
 * how much time has elapsed within the simulatulation.
 * 
 * Java's time function, System.currentTimeMillis(), does not measure 
 * time accurately below 10 milliseconds, and will not give accurate
 * results when measuring time elapsed between frames.
 * 
 * LWJGL includes a hardware timer that measures cpu ticks (Sys.getTime()).
 * May vary in resolution from one computer to another.  Use double data 
 * type for highest precision. 
 */
public class GLART_9_timing {
    private boolean done = false;
    private final String windowTitle = "Timing Demo";
    private DisplayMode displayMode;
    private float rotation = 0f;

    // texture handle (a number that refers to an allocated texture)
    int myTextureHandle = 0;

    // For Text: character set display list "base" and Font texture  
    int fontListBase = -1;           // Base Display List For The character set
    int fontTextureHandle = -1;      // Texture handle for character set image

    // For time tracking
    double startTime;       // starting time of simulation (in seconds)
    double simulationTime;  // current time of simulation (in seconds)

    
    /**
     * Main function just creates and runs the application.
     */
    public static void main(String args[]) {
    	GLART_9_timing app = new GLART_9_timing();
        app.run();
    }

    /**
     * Initialize the app, then sit in a render loop until done==true.
     */
    public void run() {
        try {
            init();
            while (!done) {
                mainloop();
                render();
                Display.update();
            }
            cleanup();
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    /**
     * Initialize the environment
     * @throws Exception
     */
    private void init() throws Exception {
        initDisplay();
        initGL();

        // Load the image as RGBA pixels
        GLImage textureImg = new GLImage("images/grid_texture_marked.png");
        
        // Allocate and configure a texture based on the image
        myTextureHandle = makeTexture(textureImg);
        
        // Make "mipmap" so texture can scale up/down gracefully
        makeTextureMipMap(textureImg);
        
        //----------------------------------------------------
        // Initialize values for tracking time:
        //----------------------------------------------------
        resetTimeCounters();
    }

    /**
     * Create an OpenGL display, in this case a fullscreen window.
     * @throws Exception
     */
    private void initDisplay() throws Exception {
        // get all possible display resolutions
        DisplayMode d[] = Display.getAvailableDisplayModes();
        // find a resolution we like
        for (int i = 0; i < d.length; i++) {
            if (d[i].getWidth() == 800
                && d[i].getHeight() == 600
                && d[i].getBitsPerPixel() == 32) {
                displayMode = d[i];
                break;
            }
        }
        // set the display to the resolution we picked
        Display.setDisplayMode(displayMode);
        Display.setTitle(windowTitle);
        // syncronize refresh to monitor refresh rate (usually 60 or 75 frames per second)
        Display.setVSyncEnabled(true);
        // if true, set to full screen, no chrome
        Display.setFullscreen(false);
        // create the window
        Display.create();
   }

    /**
     * Initialize OpenGL
     *
     */
    private void initGL() {
        // Select the Projection Matrix (controls perspective)
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glLoadIdentity();    // Reset The Projection Matrix

        // Define perspective
        GLU.gluPerspective(
            45.0f,        // Field Of View
            (float)displayMode.getWidth() / (float)displayMode.getHeight(), // aspect ratio
            0.1f,         // near Z clipping plane
            100.0f);      // far Z clipping plane

        // set the background color
        GL11.glClearColor(.2f, .2f, .23f, 1);

        //===========================================================
        // For text rendering
        //===========================================================
        
        // Enable blending so that text background is transparent 
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 
        
        // Turn texturing on (text is a texture so we need this on)
        GL11.glEnable(GL11.GL_TEXTURE_2D);

        // prepare character set for text rendering
        buildFont("images/font_tahoma.png", 12);
    }

    /**
     * Handle keyboard input.  Just check for escape key or user
     * clicking to close the window.
     */
    private void mainloop() {
        if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {   // Escape is pressed
            done = true;
        }
        if(Display.isCloseRequested()) {                // Window is closed
            done = true;
        }
        if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {    // Escape is pressed
            resetTimeCounters();
        }
    }

    /**
     * Reset the timer values.
     */
    public void resetTimeCounters() {
        // reset simulation time from LWJGL timer
    	startTime = simulationTime = getTimeInSeconds();
        
        // rotation of clock hand in degrees
        rotation = 0;
    }

    /**
     * Render the scene.
     */
    private void render() {
    	// how far should second hand rotate per second
    	float degreesPerSecond = 6f;
    	
    	// time elapsed since we last rendered
    	double secondsSinceLastFrame = getTimeInSeconds() - simulationTime;

    	// update the simulation current time
    	simulationTime += secondsSinceLastFrame;

    	///////////////////////////////////////////////////////
    	// Animate second hand of clock PICK ONE:
    	
    	// OLD WAY: rotate an arbitrary amount
    	//rotation += .06f;
    	
    	// BETTER: rotate in proportion to time elapsed
    	rotation += degreesPerSecond * secondsSinceLastFrame;
    	
    	// done 
    	///////////////////////////////////////////////////////

        // Clear screen and depth buffer
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        
        // Select The Modelview Matrix (controls model orientation)
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        
        // Reset the Modelview matrix
        // this resets the coordinate system to center of screen
        GL11.glLoadIdentity();
        
        // Where is the 'eye'
        GLU.gluLookAt(
            -1f, 0f, 7f,   // eye position
            -1f, 0f, 0f,    // target to look at
            0f, 1f, 0f);   // which way is up

        // draw the clock face
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glColor4f(.5f, .5f, .5f, 1f);
        GL11.glPushMatrix();
        {
        	// draw markers every 5 minutes (30 degrees)
 	        for (int i=0; i < 12; i++) {
	        	GL11.glRotatef(30f, 0,0,1);
		        GL11.glBegin(GL11.GL_LINES);   
		        {
		            GL11.glVertex3f(0f, 1.5f, -.1f);  
		            GL11.glVertex3f(0f, 2f, -.1f); 
		        }
		        GL11.glEnd();
	        }
        }
        GL11.glPopMatrix();

        // draw the second hand
        GL11.glColor4f(.9f, .8f, .8f, 1f);
        GL11.glPushMatrix();
        {
	        // rotate coordinate system
	        GL11.glRotatef(-rotation, 0,0,1);
	    	// draw a triangular second hand
	        GL11.glBegin(GL11.GL_TRIANGLES);   
	        {
	            GL11.glTexCoord2f(0, 0);
	            GL11.glVertex3f(-.1f, 0f, 0f);         // Bottom Left
	            
	            GL11.glTexCoord2f(1, 0);
	            GL11.glVertex3f( .1f, 0f, 0f);         // Bottom Right
	            
	            GL11.glTexCoord2f(.5f, .5f);
	            GL11.glVertex3f( 0, 2f, 0f);           // Top
	        }
	        GL11.glEnd();
        }
        GL11.glPopMatrix();
        
        // text needs textures ON
        GL11.glEnable(GL11.GL_TEXTURE_2D);

        // Show the simulated time elapsed.
        // This is the time that we have processed within our simulation.
        glText(-4.5f, -.25f, 0f, 0, .03f, formatTime(simulationTime-startTime) );
		
        // Show the actual system time elapsed.
        // This is the computer clock time that has elapsed since we started the simulation.
        glPrint(50,40,0, "Actual time elapsed: " + formatTime(getTimeInSeconds()-startTime) );
    }

    /**
     * Cleanup all the resources.
     *

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品国产91久久久 | 精品久久久久久久久久久久久久久久久| 男男视频亚洲欧美| av在线不卡网| 日韩欧美国产成人一区二区| 亚洲欧洲日韩在线| 国产一区二区在线观看视频| 欧美视频在线观看一区| 中文文精品字幕一区二区| 日本不卡在线视频| 欧美在线你懂得| 国产精品久久99| 国产自产视频一区二区三区| 欧美日韩精品一区二区| 亚洲欧洲日韩在线| 成人丝袜视频网| wwwwxxxxx欧美| 久久丁香综合五月国产三级网站| 在线免费观看视频一区| 国产精品黄色在线观看| 国产酒店精品激情| 久久综合色一综合色88| 偷拍一区二区三区| 欧美在线免费观看亚洲| 亚洲精选在线视频| 93久久精品日日躁夜夜躁欧美| 国产视频一区不卡| 国产一区二区影院| 久久久精品免费免费| 国内偷窥港台综合视频在线播放| 欧美一区日本一区韩国一区| 亚洲aⅴ怡春院| 日本欧美一区二区在线观看| 国产河南妇女毛片精品久久久| 日韩午夜激情av| 久久aⅴ国产欧美74aaa| 精品三级av在线| 激情文学综合丁香| 国产午夜精品理论片a级大结局| 国内成人自拍视频| 国产日韩精品一区| 成人av在线一区二区三区| 专区另类欧美日韩| 欧美午夜不卡视频| 日本麻豆一区二区三区视频| 欧美成人vps| 国产精品亚洲人在线观看| 欧美激情在线一区二区三区| aaa国产一区| 亚洲综合无码一区二区| 欧美军同video69gay| 毛片一区二区三区| 国产情人综合久久777777| 福利电影一区二区三区| 亚洲精品乱码久久久久久久久 | 色狠狠色狠狠综合| 亚洲国产精品久久艾草纯爱| 日韩亚洲欧美在线观看| 国产精品亚洲一区二区三区妖精 | 国产不卡免费视频| 久久久久国色av免费看影院| 成人av网址在线| 亚洲一区二区中文在线| 精品国产凹凸成av人导航| 成人av电影在线网| 一区二区在线观看av| 亚洲综合在线电影| 老司机精品视频一区二区三区| 欧美影视一区二区三区| 亚洲精品ww久久久久久p站| 成人高清免费在线播放| 久久久久久久性| 国产伦精品一区二区三区在线观看| 欧美一级生活片| 日本成人在线网站| 91精品国产免费久久综合| 亚洲第一成人在线| 欧美日韩久久久| 爽好久久久欧美精品| 337p亚洲精品色噜噜噜| 天天色天天操综合| 7777精品伊人久久久大香线蕉完整版 | 午夜精品久久久久久| 色综合久久综合中文综合网| 亚洲欧美一区二区在线观看| 99在线精品一区二区三区| 亚洲三级电影全部在线观看高清| 99麻豆久久久国产精品免费优播| 中文字幕一区二区不卡| 色综合天天综合| 亚洲国产cao| 欧美精品第1页| 精一区二区三区| www国产成人| 91香蕉国产在线观看软件| 亚洲专区一二三| 日韩美女一区二区三区四区| 国产一区二区成人久久免费影院| 欧美激情在线看| 91麻豆精品秘密| 日韩av电影免费观看高清完整版 | 国产一区二三区| 国产精品理伦片| 欧美怡红院视频| 蜜桃视频一区二区| 国产精品天干天干在观线| 色综合天天综合网天天看片| 天堂在线一区二区| 国产亚洲精品资源在线26u| av激情综合网| 天使萌一区二区三区免费观看| 美女网站在线免费欧美精品| 欧美色成人综合| 韩国毛片一区二区三区| 亚洲视频图片小说| 欧美一级片在线| av资源网一区| 秋霞成人午夜伦在线观看| 中文字幕一区二区三区av| 91精品国产免费| 91成人国产精品| 国产成人综合网站| 日本怡春院一区二区| 亚洲同性同志一二三专区| 91精品国产综合久久久久久| 99九九99九九九视频精品| 老司机精品视频在线| 亚洲一区免费视频| 国产精品沙发午睡系列990531| 在线综合+亚洲+欧美中文字幕| 99在线精品视频| 国产一区二区三区| 首页综合国产亚洲丝袜| 亚洲欧美一区二区三区久本道91| 久久综合九色综合欧美就去吻| 欧美日韩一区二区三区四区五区 | 国产精品久久久久久一区二区三区 | 99精品国产热久久91蜜凸| 精品在线观看视频| 爽爽淫人综合网网站| 亚洲一区在线播放| 亚洲欧美视频一区| 国产不卡视频在线播放| 国产丝袜在线精品| 久久影视一区二区| 日韩一区二区视频在线观看| 欧美在线小视频| 色94色欧美sute亚洲线路一ni| 成人免费视频免费观看| 黑人巨大精品欧美一区| 美日韩一区二区| 免费日韩伦理电影| 美女久久久精品| 老司机精品视频在线| 久久丁香综合五月国产三级网站| 天堂久久一区二区三区| 日韩精品久久理论片| 天堂av在线一区| 美女免费视频一区| 国产在线观看一区二区| 久久激情综合网| 国产高清精品网站| 成人av在线电影| 色综合视频一区二区三区高清| 色婷婷国产精品综合在线观看| 91一区二区三区在线播放| 欧美午夜影院一区| 欧美区在线观看| 日韩亚洲欧美成人一区| 精品理论电影在线| 国产精品久久久久久久裸模| 综合久久综合久久| 丝袜亚洲另类丝袜在线| 久久精品99国产国产精| 成人性生交大片| 日本韩国欧美在线| 欧美一区二区女人| 国产午夜精品福利| 一区二区欧美在线观看| 五月天欧美精品| 国产麻豆成人传媒免费观看| av在线不卡免费看| 欧美肥妇free| 国产清纯白嫩初高生在线观看91 | 亚洲综合一区在线| 麻豆中文一区二区| av福利精品导航| 91麻豆精品国产91久久久资源速度| 精品久久久久久久一区二区蜜臀| 国产女人水真多18毛片18精品视频 | 日韩精品中文字幕在线不卡尤物 | 日韩欧美在线123| 亚洲国产精品v| 成人丝袜视频网| 色噜噜久久综合| 精品福利一区二区三区免费视频| 一色桃子久久精品亚洲| 蜜桃视频一区二区三区在线观看| 成人av在线网站| 久久综合色综合88|