当前位置: 首页>>代码示例>>Java>>正文


Java ContextAttribs类代码示例

本文整理汇总了Java中org.lwjgl.opengl.ContextAttribs的典型用法代码示例。如果您正苦于以下问题:Java ContextAttribs类的具体用法?Java ContextAttribs怎么用?Java ContextAttribs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContextAttribs类属于org.lwjgl.opengl包,在下文中一共展示了ContextAttribs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDisplay

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay() {
	
	ContextAttribs attribs = new ContextAttribs(3, 2)
			.withForwardCompatible(true)
			.withProfileCore(true);
	
	try {
		Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
		Display.create(new PixelFormat(), attribs);
		Display.setTitle("MRCEngine");
	} catch (LWJGLException e) {
		e.printStackTrace();
	}
	
	GL11.glViewport(0, 0, WIDTH, HEIGHT);
	lastFrameTime = getCurrentTime();
	
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:19,代码来源:DisplayManager.java

示例2: createDisplay

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay() {
	// OpenGL version used
	ContextAttribs attribs = new ContextAttribs(3, 2)
			.withForwardCompatible(true)
			.withProfileCore(true);

	try {
		Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
		Display.create(new PixelFormat(), attribs);
		Display.setTitle(TITLE);
	} catch (LWJGLException e) {
		e.printStackTrace();
	}

	GL11.glViewport(0, 0, WIDTH, HEIGHT);
}
 
开发者ID:DevipriyaSarkar,项目名称:Terrain,代码行数:17,代码来源:DisplayManager.java

示例3: createDisplay

import org.lwjgl.opengl.ContextAttribs; //导入依赖的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: createDisplay

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay() {
    ContextAttribs attribs = new ContextAttribs(3, 3)
            .withForwardCompatible(true)
            .withProfileCore(true);
    try {
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.create(new PixelFormat(), attribs);
        Display.setTitle("Our First Display!");
        GL11.glEnable(GL13.GL_MULTISAMPLE);
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    GL11.glViewport(0, 0, WIDTH, HEIGHT);
    lastFrameTime = getCurrentTime();
}
 
开发者ID:MrManiacc,项目名称:3d-Engine,代码行数:17,代码来源:DisplayManager.java

示例5: init

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public void init() throws Exception {
    try {
        System.setProperty("org.lwjgl.opengl.Display.noinput", "true");
        PixelFormat pixFormat = new PixelFormat();
        ContextAttribs contextAttribs = new ContextAttribs(3, 2)
            .withForwardCompatible(true)
            .withProfileCore(true);
        Display.setResizable(true);
        Display.setParent(glCanvas);
        Display.create(pixFormat, contextAttribs);
        // TODO: Find the reason why this hack is necessary and fix it
        // Without this, the menu bar will be below the canvas and isMouseInsideWindow
        // will return false unless it left and re-entered the frame once
        SwingUtilities.invokeLater(() -> {
            Component root = SwingUtilities.getRoot(glCanvas);
            root.setSize(root.getWidth(), root.getHeight() + 1);
            root.setSize(root.getWidth(), root.getHeight() - 1);
        });
        initGL();
    } catch (LWJGLException e) {
        log.log(Level.SEVERE, "Couldn't create display: " + e.getMessage(), e);
        throw e;
    }

    lastFPSReport = game.getTimeMillis();
}
 
开发者ID:necr0potenc3,项目名称:uosl,代码行数:27,代码来源:GameView.java

示例6: setupOpenGL

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
private void setupOpenGL() {
    // Setup an OpenGL context with API version 3.2
    try {
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
            .withForwardCompatible(true)
            .withProfileCore(true);
         
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.setTitle(WINDOW_TITLE);
        Display.create(pixelFormat, contextAtrributes);
         
        GL11.glViewport(0, 0, WIDTH, HEIGHT);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }
     
    // Setup an XNA like background color
    GL11.glClearColor(0.4f, 0.6f, 0.9f, 0f);
     
    // Map the internal OpenGL coordinate system to the entire screen
    GL11.glViewport(0, 0, WIDTH, HEIGHT);
     
    this.exitOnGLError("setupOpenGL");
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:27,代码来源:OpenGL3_TheQuadTextured.java

示例7: create

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
@Override
public void create() {
	try {
		// Get the desktop display mode
		final DisplayMode mode = Display.getDesktopDisplayMode();
		// Create the pixel format
		final PixelFormat format = new PixelFormat(mode.getBitsPerPixel(), 8, 8, 0, 0);
		// Create the context attrib
		ContextAttribs attribs = new ContextAttribs(getGLVersion().getMajor(), getGLVersion().getMinor());
		attribs = attribs.withProfileCore(true);
		attribs = attribs.withDebug(true);
		// Create the display
		Display.create(format, attribs);
		super.create();
	} catch (LWJGLException ex) {
		throw new IllegalStateException("Unable to create display!", ex);
	}
	setWindowTitle("Fusion Engine | Version: " + Engine.ENGINE_VERSION);
	setClearColour(0.0f, 0.35f, 0.75f);
	setWindowSize(800, 600);
	enableVSync(true);
}
 
开发者ID:thehutch,项目名称:Fusion,代码行数:23,代码来源:OpenGL30Context.java

示例8: create

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
@Override
public void create(String title) {
    setTitle(title);
    enableResize(true);

    PixelFormat pixelFormat = new PixelFormat();
    ContextAttribs contextAtrributes = new ContextAttribs(3, 2)
            .withForwardCompatible(true)
            .withProfileCore(true);

    try {
        Display.setDisplayMode(new DisplayMode(getWidth(), getHeight()));
        Display.create(pixelFormat, contextAtrributes);
        Keyboard.create();
        Mouse.create();
        AL.create();
        drawBuffer = glGetInteger(GL_DRAW_BUFFER);
        readBuffer = glGetInteger(GL_READ_BUFFER);
    } catch (LWJGLException e) {
        LOGGER.error("Error setting up input and window", e);
    }
}
 
开发者ID:achtern,项目名称:AchternEngine,代码行数:23,代码来源:LWJGLWindow.java

示例9: create

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
/**
 * Creates the OpenGL context window with the given parameters. <br>
 * <i>Note: the QuadEngine runs on OpenGL 3.2</i>
 * 
 * @param width The width of the window.
 * @param height The height of the window.
 * @param title The title of the game.
 */
public static void create(int width, int height, String title) {

    ContextAttribs attribs = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
    desktop = Display.getDesktopDisplayMode();
    refreshRate = desktop.getFrequency();
    try {
        Display.setDisplayMode(new DisplayMode(width, height));
        Display.create(new PixelFormat(), attribs);
        Display.setTitle(title);
        Keyboard.create();
        Mouse.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    GL11.glViewport(0, 0, width, height);
    lastFrameTime = Util.getTime();
}
 
开发者ID:RedThirdDivision,项目名称:QuadEngine,代码行数:27,代码来源:Window.java

示例10: createDisplay

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay() {
	ContextAttribs attribs = new ContextAttribs(3, 3).withForwardCompatible(true).withProfileCore(true);

	try {
		//Display.setResizable(true); // whether our window is resizable
		Display.setDisplayMode(new DisplayMode(Settings.WINDOW_WIDTH, Settings.WINDOW_HEIGHT));
		Display.setVSyncEnabled(Settings.VSYNC); // whether hardware VSync
													// is enabled
		Display.setFullscreen(Settings.FULL_SCREEN); // whether fullscreen
														// is
														// enabled
		if (Settings.ENABLE_ANTIALIASING) {
			Display.create(new PixelFormat().withDepthBits(24), attribs);
			System.out.println(GL11.glGetInteger(GL11.GL_DEPTH_BITS));
			GL11.glEnable(GL13.GL_MULTISAMPLE);
		} else {
			Display.create(new PixelFormat(), attribs);
		}
		Display.setTitle(WINDOWNAME);
	} catch (LWJGLException e) {
		e.printStackTrace();
	}

	GL11.glViewport(0, 0, Settings.WINDOW_WIDTH, Settings.WINDOW_HEIGHT);
	lastFrameTime = getCurrentTime();
	lastFPS = lastFrameTime;
}
 
开发者ID:Radseq,项目名称:Mystic-Bastion,代码行数:28,代码来源:DisplayManager.java

示例11: createDisplay

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay() {
	ContextAttribs attribs = new ContextAttribs(3,2).withForwardCompatible(true).withProfileCore(true);
	
	try {
		Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
		Display.create(new PixelFormat(), attribs);
		Display.setTitle("Our first display!");
	} catch (LWJGLException e) {
		e.printStackTrace();
	}
	
	GL11.glViewport(0, 0, WIDTH, HEIGHT);
	lastFrameTime = getCurrentTime();
}
 
开发者ID:LudgerHW,项目名称:Gamemaker,代码行数:15,代码来源:DisplayManager.java

示例12: run

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public final void run(PixelFormat format, ContextAttribs attribs) {
	try {
		Display.create(format, attribs);
	} catch(Exception exc) {
		exc.printStackTrace();
		System.exit(1);
	}
	
	gameLoop();
}
 
开发者ID:ra4king,项目名称:LWJGL-OpenGL-Utils,代码行数:11,代码来源:GLProgram.java

示例13: createDisplay

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
public static void createDisplay(int width, int height) {
  ContextAttribs attribs = new ContextAttribs(4, 1).withForwardCompatible(true).withProfileCore(true);
  try {
    Display.setDisplayMode(new DisplayMode(width, height));
    Display.create(new PixelFormat(), attribs);
    Display.setTitle("MRL LWJGL GUI");
  } catch (LWJGLException e) {
    e.printStackTrace();
  }
  GL11.glViewport(0, 0, width, height);
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:12,代码来源:DisplayManager.java

示例14: initDisplay

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
private void initDisplay(boolean core) {

    try {
        PixelFormat pixelFormat = new PixelFormat();
        ContextAttribs contextAtrributes = new ContextAttribs(3, 3).withForwardCompatible(true).withProfileCompatibility(true);
        if (core) contextAtrributes = contextAtrributes.withProfileCore(true);

        Display.setDisplayMode(new DisplayMode(game.getSettings().getWidth(), game.getSettings().getHeight()));
        ClientHelper.setDisplaySize(new Vec2i(game.getSettings().getWidth(), game.getSettings().getHeight()));
        Display.setResizable(true);
        Display.create(pixelFormat, contextAtrributes);

        GLHelper.checkForErrors();

        int vao = GL30.glGenVertexArrays();
        GL30.glBindVertexArray(vao);
        
        initGL();

        GLHelper.checkForErrors();
    } catch (Exception ex) {
        if (!core) {
            initDisplay(true);
        } else {
            new KatamaException("Could not init display!").printStackTrace();
            System.exit(-1);
        }
    }
}
 
开发者ID:KatamaStudios,项目名称:KatamaEngine,代码行数:31,代码来源:CoreEngine.java

示例15: run

import org.lwjgl.opengl.ContextAttribs; //导入依赖的package包/类
/**
 * Initializes the context with its attributes and PixelFormat supplied.
 * 
 * This method does not return until the game loop ends.
 * 
 * @param format The PixelFormat specifying the buffers.
 * @param attribs The context attributes.
 */
public final void run(PixelFormat format, ContextAttribs attribs) {
	try {
		Display.create(format, attribs);
	} catch(Exception exc) {
		exc.printStackTrace();
		System.exit(1);
	}
	
	gameLoop();
}
 
开发者ID:ra4king,项目名称:LWJGL-OpenGL-Tutorials,代码行数:19,代码来源:GLProgram.java


注:本文中的org.lwjgl.opengl.ContextAttribs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。