本文整理汇总了Java中org.lwjgl.opengl.Display.create方法的典型用法代码示例。如果您正苦于以下问题:Java Display.create方法的具体用法?Java Display.create怎么用?Java Display.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.opengl.Display
的用法示例。
在下文中一共展示了Display.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDisplay
import org.lwjgl.opengl.Display; //导入方法依赖的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);
}
示例2: main
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("Display Test");
Display.create();
// create() throws LWJGLException
} catch (LWJGLException e) {
System.err.println("Display wasn't initialized correctly.");
// Throws an exit code of 1
System.exit(1);
}
// While nobody is trying to close the window
while (!Display.isCloseRequested()) {
Display.update();
// FPS is the parameter
Display.sync(60);
}
}
示例3: 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();
}
示例4: main
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("A Fresh New Display");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
Display.destroy();
System.exit(1);
}
while (!Display.isCloseRequested()) {
// render code
// input handling code
// refresh display and poll input
Display.update();
// Maintain a 60fps frame rate
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
示例5: Window
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
protected Window(Context context, WindowBuilder settings) {
this.fpsCap = settings.getFpsCap();
try {
getSuitableFullScreenModes();
DisplayMode resolution = getStartResolution(settings);
Display.setInitialBackground(0f, 0f, 0f);
this.aspectRatio = (float) resolution.getWidth() / resolution.getHeight();
setResolution(resolution, settings.isFullScreen());
if (settings.hasIcon()) {
Display.setIcon(settings.getIcon());
}
Display.setVSyncEnabled(settings.isvSync());
Display.setTitle(settings.getTitle());
Display.create(new PixelFormat().withDepthBits(24).withSamples(4), context.getAttribs());
GL11.glViewport(0, 0, resolution.getWidth(), resolution.getHeight());
} catch (LWJGLException e) {
e.printStackTrace();
}
}
示例6: createDisplay
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
private void createDisplay() throws LWJGLException {
Display.setResizable(true);
Display.setTitle("Minecraft 1.8.8");
try {
Display.create((new PixelFormat()).withDepthBits(24));
} catch (LWJGLException lwjglexception) {
logger.error((String) "Couldn\'t set pixel format", (Throwable) lwjglexception);
try {
Thread.sleep(1000L);
} catch (InterruptedException var3) {
;
}
if (this.fullscreen) {
this.updateDisplayMode();
}
Display.create();
}
}
示例7: 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();
}
示例8: createDisplay
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
/**
* Create the LWJGL display
*
* @throws Exception Failure to create display
*/
private void createDisplay() throws Exception {
try {
// create display with alpha
Display.create(new PixelFormat(8,8,GameContainer.stencil ? 8 : 0));
alphaSupport = true;
} catch (Exception e) {
// if we couldn't get alpha, let us know
alphaSupport = false;
Display.destroy();
// create display without alpha
Display.create();
}
}
示例9: main
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
System.out.println("OpenGL version is: " + GL11.glGetString(GL11.GL_VERSION));
Display.destroy();
}
示例10: createDisplay
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
private void createDisplay() throws LWJGLException
{
Display.setResizable(true);
Display.setTitle("Minecraft 1.8.8");
try
{
Display.create((new PixelFormat()).withDepthBits(24));
}
catch (LWJGLException lwjglexception)
{
logger.error((String)"Couldn\'t set pixel format", (Throwable)lwjglexception);
try
{
Thread.sleep(1000L);
}
catch (InterruptedException var3)
{
;
}
if (this.fullscreen)
{
this.updateDisplayMode();
}
Display.create();
}
}
示例11: createDisplay
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
private void createDisplay() throws LWJGLException
{
Display.setResizable(true);
Display.setTitle("Minecraft 1.10.2");
try
{
Display.create((new PixelFormat()).withDepthBits(24));
}
catch (LWJGLException lwjglexception)
{
LOGGER.error((String)"Couldn\'t set pixel format", (Throwable)lwjglexception);
try
{
Thread.sleep(1000L);
}
catch (InterruptedException var3)
{
;
}
if (this.fullscreen)
{
this.updateDisplayMode();
}
Display.create();
}
}
示例12: Boot
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public Boot() {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("Minecraft 2D");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
grid = new BlockGrid();
grid.setAt(10, 10, selection);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 640, 480, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
while (!Display.isCloseRequested()) {
// Render Code here
glClear(GL_COLOR_BUFFER_BIT);
input();
grid.draw();
drawSelectionBox();
Display.update();
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
示例13: createDisplay
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
private void createDisplay() throws LWJGLException
{
Display.setResizable(true);
Display.setTitle(Client.CLIENT_NAME + " v" + Client.CLIENT_VERSION);
try
{
Display.create((new PixelFormat()).withDepthBits(24));
}
catch (LWJGLException lwjglexception)
{
LOGGER.error((String)"Couldn\'t set pixel format", (Throwable)lwjglexception);
try
{
Thread.sleep(1000L);
}
catch (InterruptedException var3)
{
;
}
if (this.fullscreen)
{
this.updateDisplayMode();
}
Display.create();
}
}
示例14: UsingEntities
import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public UsingEntities() {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("LWJGL Template");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
// init entities
MoveableEntity box = new Box(100, 100, 50, 50);
Entity point = new Point(10, 10);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 640, 480, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
lastFrame = getTime();
while (!Display.isCloseRequested()) {
// Render Code here
point.setLocation(Mouse.getX(), 480 - Mouse.getY() - 1);
glClear(GL_COLOR_BUFFER_BIT);
int delta = getDelta();
box.update(delta);
point.update(delta);
if (box.intersects(point)) {
box.setDX(0.2);
}
point.draw();
box.draw();
Display.update();
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
示例15: 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);
}