当前位置: 首页>>代码示例>>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;未经允许,请勿转载。