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


Java Display.setDisplayMode方法代碼示例

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


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

示例1: main

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void main(String... args){
    System.setProperty("org.lwjgl.librarypath", new File("native/"+(System.getProperties().getProperty("os.name").split(" ")[0]).toLowerCase()).getAbsolutePath());

    FreeWorld.getFreeWorld();

    try {
        Display.setTitle(FreeWorld.getFreeWorld().getTitle());
        Display.setDisplayMode(new DisplayMode(720, 480));
        Display.setResizable(true);
        Display.create();
    }catch (LWJGLException e){
        e.printStackTrace();
    }

    //TODO: Provisoire
    glClearColor(0.2f, 0.7f, 0.7f, 1.0f);

    FreeWorld.getFreeWorld().start();
}
 
開發者ID:Vinetos,項目名稱:FreeWorld,代碼行數:20,代碼來源:FreeWorld.java

示例2: BeginSession

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void BeginSession(){
	Display.setTitle(TITLE);
	try {
		Display.setDisplayMode(new DisplayMode(WIDTH + MENU_WIDTH, HEIGHT));
		Display.create();
	} catch (LWJGLException e) {
		e.printStackTrace();
	}
	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, WIDTH + MENU_WIDTH, HEIGHT, 0, 1, -1);
	glMatrixMode(GL_MODELVIEW);
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
 
開發者ID:imaTowan,項目名稱:Towan,代碼行數:18,代碼來源:Artist.java

示例3: createDisplay

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void createDisplay() {
	try {
		Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
		ContextAttribs attribs = new ContextAttribs(3, 2).withProfileCore(true).withForwardCompatible(true);
		Display.create(new PixelFormat().withDepthBits(24).withSamples(4), attribs);
		Display.setTitle(TITLE);
		Display.setInitialBackground(1, 1, 1);
		GL11.glEnable(GL13.GL_MULTISAMPLE);
	} catch (LWJGLException e) {
		e.printStackTrace();
		System.err.println("Couldn't create display!");
		System.exit(-1);
	}
	GL11.glViewport(0, 0, WIDTH, HEIGHT);
	lastFrameTime = getCurrentTime();
}
 
開發者ID:TheThinMatrix,項目名稱:OpenGL-Animation,代碼行數:17,代碼來源:DisplayManager.java

示例4: resizeIfNeeded

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
 * Resizes the window and the Minecraft rendering if necessary. Set renderWidth and renderHeight first.
 */
private void resizeIfNeeded()
{
    // resize the window if we need to
    int oldRenderWidth = Display.getWidth(); 
    int oldRenderHeight = Display.getHeight();
    if( this.renderWidth == oldRenderWidth && this.renderHeight == oldRenderHeight )
        return;
    
    try {
        Display.setDisplayMode(new DisplayMode(this.renderWidth, this.renderHeight));
        System.out.println("Resized the window");
    } catch (LWJGLException e) {
        System.out.println("Failed to resize the window!");
        e.printStackTrace();
    }
    forceResize(this.renderWidth, this.renderHeight);
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:21,代碼來源:VideoHook.java

示例5: setResolution

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public void setResolution(DisplayMode resolution, boolean fullscreen) {
    try {
        Display.setDisplayMode(resolution);
        this.resolution = resolution;
        if (fullscreen && resolution.isFullscreenCapable()) {
            Display.setFullscreen(true);
            this.fullScreen = fullscreen;
        }
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
}
 
開發者ID:GryPLOfficial,項目名稱:EcoSystem-Official,代碼行數:13,代碼來源:Window.java

示例6: setInitialDisplayMode

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private void setInitialDisplayMode() throws LWJGLException
{
    if (this.fullscreen)
    {
        Display.setFullscreen(true);
        DisplayMode displaymode = Display.getDisplayMode();
        this.displayWidth = Math.max(1, displaymode.getWidth());
        this.displayHeight = Math.max(1, displaymode.getHeight());
    }
    else
    {
        Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight));
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:15,代碼來源:Minecraft.java

示例7: StateDemo

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private StateDemo() {
    
	try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Game States");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    while (!Display.isCloseRequested()) {
        // Render Code here
        glClear(GL_COLOR_BUFFER_BIT);
        
        render();
        checkInput();
        
        Display.update();
        Display.sync(60);
    }
    
    Display.destroy();
    System.exit(0);
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:30,代碼來源:StateDemo.java

示例8: setInitialDisplayMode

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private void setInitialDisplayMode() throws LWJGLException {
	if (this.fullscreen) {
		Display.setFullscreen(true);
		DisplayMode displaymode = Display.getDisplayMode();
		this.displayWidth = Math.max(1, displaymode.getWidth());
		this.displayHeight = Math.max(1, displaymode.getHeight());
	} else {
		Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight));
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:Minecraft.java

示例9: ShiftingCameraLaterally

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private ShiftingCameraLaterally() {
    
	try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("X Axis Camera Movement");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    
    float x_cam = 0;

    while (!Display.isCloseRequested()) {
        // Render Code here
        glClear(GL_COLOR_BUFFER_BIT);
        // Put a matrix that's a clone of the original into the matrix stock
        glPushMatrix();
        // Pushes screen laterally, depending on x_cam
        glTranslatef(x_cam, 0, 0);
        
        // Move screen with the Mouse speed
        // if the mouse is in the window and space is pressed
        if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)
        		&& Mouse.getX() > 0 && Mouse.getX() < 639) {
        	x_cam += Mouse.getDX();
        }
        // True coords of the mouse
        float mousex = Mouse.getX() - x_cam;
        float mousey = 480 - Mouse.getY() - 1;
        
        System.out.println(mousex + ", " + mousey);
        
        glBegin(GL_QUADS);
        	glVertex2i(400, 400);
        	glVertex2i(450, 400);
        	glVertex2i(450, 450);
        	glVertex2i(400, 450);
        glEnd();
        
        glBegin(GL_LINES);
        	glVertex2i(400, 400);
        	glVertex2i(400, 400);
        glEnd();
        
        // Disposes of translations made to the matrix
        glPopMatrix();
        
        Display.update();
        Display.sync(60);
    }
    Display.destroy();
    System.exit(0);
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:59,代碼來源:ShiftingCameraLaterally.java

示例10: toggleFullscreen

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
 * Toggles fullscreen mode.
 */
public void toggleFullscreen()
{
    try
    {
        this.fullscreen = !this.fullscreen;
        this.gameSettings.fullScreen = this.fullscreen;

        if (this.fullscreen)
        {
            this.updateDisplayMode();
            this.displayWidth = Display.getDisplayMode().getWidth();
            this.displayHeight = Display.getDisplayMode().getHeight();

            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }
        }
        else
        {
            Display.setDisplayMode(new DisplayMode(this.tempDisplayWidth, this.tempDisplayHeight));
            this.displayWidth = this.tempDisplayWidth;
            this.displayHeight = this.tempDisplayHeight;

            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }
        }

        if (this.currentScreen != null)
        {
            this.resize(this.displayWidth, this.displayHeight);
        }
        else
        {
            this.updateFramebufferSize();
        }

        Display.setFullscreen(this.fullscreen);
        Display.setVSyncEnabled(this.gameSettings.enableVsync);
        this.updateDisplay();
    }
    catch (Exception exception)
    {
        LOGGER.error((String)"Couldn\'t toggle fullscreen", (Throwable)exception);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:62,代碼來源:Minecraft.java

示例11: VertexBufferObject

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private VertexBufferObject() {
    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("VBO Rendering");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(1, 1, 1, 1, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    final int amountOfVertices = 3;
    final int vertexSize = 2;
    final int colorSize = 3;

    FloatBuffer vertexData = BufferUtils.createFloatBuffer(amountOfVertices * vertexSize);
    vertexData.put(new float[]{-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f});
    vertexData.flip();

    FloatBuffer colorData = BufferUtils.createFloatBuffer(amountOfVertices * colorSize);
    colorData.put(new float[]{-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f});
    colorData.flip();

    int vboVertexHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
    glBufferData(GL_ARRAY_BUFFER, vertexData, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    int vboColorHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, vboColorHandle);
    glBufferData(GL_ARRAY_BUFFER, colorData, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    while (!Display.isCloseRequested()) {
        glClear(GL_COLOR_BUFFER_BIT);

        glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
        glVertexPointer(vertexSize, GL_FLOAT, 0, 0L);

        glBindBuffer(GL_ARRAY_BUFFER, vboColorHandle);
        glVertexPointer(colorSize, GL_FLOAT, 0, 0L);

        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);
        glDrawArrays(GL_TRIANGLES, 0, 1);
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);

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

    }
    glDeleteBuffers(vboVertexHandle);
    glDeleteBuffers(vboColorHandle);

    Display.destroy();
    System.exit(0);
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:63,代碼來源:VertexBufferObject.java

示例12: VertexArrays

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private VertexArrays() {
    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Immediate Mode");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(1, 1, 1, 1, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    final int amountofVertices = 3;
    final int vertexSize = 2;
    final int colorSize = 3;

    FloatBuffer vertexData = BufferUtils.createFloatBuffer(amountofVertices * vertexSize);
    vertexData.put(new float[]{-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f});
    vertexData.flip();

    FloatBuffer colorData = BufferUtils.createFloatBuffer(amountofVertices * colorSize);
    colorData.put(new float[]{-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f});
    colorData.flip();

    while(!Display.isCloseRequested()) {
        glClear(GL_COLOR_BUFFER_BIT);

        // Allows usage of vertex and color arrays
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);

        // Shows OpenGL where to find our arrays
        glVertexPointer(vertexSize, 0, vertexData);
        glColorPointer(colorSize, 0, colorData);

        // Draws the arrays
        glDrawArrays(GL_TRIANGLES, 0, amountofVertices);

        // Closes it and disables it
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);

        Display.update();
        Display.sync(60);
    }
    Display.destroy();
    System.exit(0);
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:51,代碼來源:VertexArrays.java

示例13: checkDisplaySettings

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void checkDisplaySettings()
{
    int i = getAntialiasingLevel();

    if (i > 0)
    {
        DisplayMode displaymode = Display.getDisplayMode();
        dbg("FSAA Samples: " + i);

        try
        {
            Display.destroy();
            Display.setDisplayMode(displaymode);
            Display.create((new PixelFormat()).withDepthBits(24).withSamples(i));
            Display.setResizable(false);
            Display.setResizable(true);
        }
        catch (LWJGLException lwjglexception2)
        {
            warn("Error setting FSAA: " + i + "x");
            lwjglexception2.printStackTrace();

            try
            {
                Display.setDisplayMode(displaymode);
                Display.create((new PixelFormat()).withDepthBits(24));
                Display.setResizable(false);
                Display.setResizable(true);
            }
            catch (LWJGLException lwjglexception1)
            {
                lwjglexception1.printStackTrace();

                try
                {
                    Display.setDisplayMode(displaymode);
                    Display.create();
                    Display.setResizable(false);
                    Display.setResizable(true);
                }
                catch (LWJGLException lwjglexception)
                {
                    lwjglexception.printStackTrace();
                }
            }
        }

        if (!Minecraft.isRunningOnMac && getDefaultResourcePack() != null)
        {
            InputStream inputstream = null;
            InputStream inputstream1 = null;

            try
            {
                inputstream = getDefaultResourcePack().getInputStreamAssets(new ResourceLocation("icons/icon_16x16.png"));
                inputstream1 = getDefaultResourcePack().getInputStreamAssets(new ResourceLocation("icons/icon_32x32.png"));

                if (inputstream != null && inputstream1 != null)
                {
                    Display.setIcon(new ByteBuffer[] {readIconImage(inputstream), readIconImage(inputstream1)});
                }
            }
            catch (IOException ioexception)
            {
                warn("Error setting window icon: " + ioexception.getClass().getName() + ": " + ioexception.getMessage());
            }
            finally
            {
                IOUtils.closeQuietly(inputstream);
                IOUtils.closeQuietly(inputstream1);
            }
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:75,代碼來源:Config.java

示例14: SmoothTransitions

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private SmoothTransitions() {
       // Of course, the default State is INTRO.
       State state = State.INTRO;
	try {
           Display.setDisplayMode(new DisplayMode(640, 480));
           Display.setTitle("LWJGL Template");
           Display.setVSyncEnabled(true); // prevents tearing and choppy animation??
           Display.create();
       } catch (LWJGLException e) {
           System.err.println("Display failed to initialize.");
           System.exit(1);
       }
       
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(1, 1, 1, 1, 1, -1);
       glMatrixMode(GL_MODELVIEW);
       glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	// Fade in degrees (0 to 90)
	float fade = 0f;
	
	while (!Display.isCloseRequested()) {
		// Clear
		glClear(GL_COLOR_BUFFER_BIT);
		
		switch(state) {
			case FADING:
				if (fade < 90) {
					fade += 1.5f;
				} else {
					fade = 0;
					glColor3f(0.5f, 0.5f, 1);
					glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
					state = State.MAIN;
					System.out.println("State changed: " + state);
					break;
				}
				// Opacity = sin(fade)
				glColor4d(0.5, 0.5, 1f, Math.sin(Math.toRadians(fade)));
				// Draws rectangle
				glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
				break;
			case INTRO:
				break;
			case MAIN:
				// Draw the fully opaque rectangle
				glColor3f(0.5f, 0.5f, 1);
				glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
				break;
		}
		
		while (Keyboard.next()) {
			if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) {
				switch (state) {
					case FADING:
						fade = 0;
						state = State.MAIN;
						System.out.println("State changed: " + state);
						break;
					case INTRO:
						state = State.FADING;
						System.out.println("State changed: " + state);
						break;
					case MAIN:
						state = State.INTRO;
						System.out.println("State changed: " + state);
						break;
				}
			}
		}
		Display.update();
		Display.sync(60);
	}
	Display.destroy();
	System.exit(0);
}
 
開發者ID:nitrodragon,項目名稱:lwjgl_collection,代碼行數:79,代碼來源:SmoothTransitions.java

示例15: toggleFullscreen

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
 * Toggles fullscreen mode.
 */
public void toggleFullscreen() {
	try {
		this.fullscreen = !this.fullscreen;
		this.gameSettings.fullScreen = this.fullscreen;

		if (this.fullscreen) {
			this.updateDisplayMode();
			this.displayWidth = Display.getDisplayMode().getWidth();
			this.displayHeight = Display.getDisplayMode().getHeight();

			if (this.displayWidth <= 0) {
				this.displayWidth = 1;
			}

			if (this.displayHeight <= 0) {
				this.displayHeight = 1;
			}
		} else {
			Display.setDisplayMode(new DisplayMode(this.tempDisplayWidth, this.tempDisplayHeight));
			this.displayWidth = this.tempDisplayWidth;
			this.displayHeight = this.tempDisplayHeight;

			if (this.displayWidth <= 0) {
				this.displayWidth = 1;
			}

			if (this.displayHeight <= 0) {
				this.displayHeight = 1;
			}
		}

		if (this.currentScreen != null) {
			this.resize(this.displayWidth, this.displayHeight);
		} else {
			this.updateFramebufferSize();
		}

		Display.setFullscreen(this.fullscreen);
		Display.setVSyncEnabled(this.gameSettings.enableVsync);
		this.updateDisplay();
	} catch (Exception exception) {
		logger.error((String) "Couldn\'t toggle fullscreen", (Throwable) exception);
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:48,代碼來源:Minecraft.java


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