本文整理匯總了Java中org.lwjgl.opengl.Display.isCloseRequested方法的典型用法代碼示例。如果您正苦於以下問題:Java Display.isCloseRequested方法的具體用法?Java Display.isCloseRequested怎麽用?Java Display.isCloseRequested使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.opengl.Display
的用法示例。
在下文中一共展示了Display.isCloseRequested方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
* Start the test
*/
public void start() {
initGL(800,600);
init();
while (true) {
update();
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
render();
Display.update();
Display.sync(100);
if (Display.isCloseRequested()) {
System.exit(0);
}
}
}
示例2: 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);
}
示例3: AltBoot
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public AltBoot() {
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, BlockType.STONE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 640, 480, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
while (!Display.isCloseRequested()) {
// Render Code here
glClear(GL_COLOR_BUFFER_BIT);
input();
grid.draw();
Display.update();
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
示例4: main
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void main(String[] args) throws FileNotFoundException {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("OpenAL Demo");
Display.create();
AL.create();
} catch (LWJGLException e) {
e.printStackTrace();
Display.destroy();
AL.destroy();
System.exit(1);
}
WaveData data = WaveData.create(new BufferedInputStream(new FileInputStream("res" + File.separatorChar +
"sounds" + File.separatorChar + "thump.wav")));
int buffer = alGenBuffers();
alBufferData(buffer, data.format, data.data, data.samplerate);
data.dispose();
int source = alGenSources();
alSourcei(source, AL_BUFFER, buffer);
while (!Display.isCloseRequested()) {
while (Keyboard.next()) {
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
alSourcePlay(source);
}
}
Display.update();
Display.sync(60);
}
alDeleteBuffers(buffer);
AL.destroy();
Display.destroy();
System.exit(0);
}
示例5: 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);
}
示例6: TimersAndBasicAnimation
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private TimersAndBasicAnimation() {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("Timer");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
int x = 100;
int y = 100;
int dx = 3;
int dy = 3;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 640, 480, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
lastFrame = getTime();
while (!Display.isCloseRequested()) {
// Render Code here
glClear(GL_COLOR_BUFFER_BIT);
int delta = getDelta();
x += delta * dx * 0.1;
y += delta * dy * 0.1;
glRecti(x, y, x + 30, y + 30);
Display.update();
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
示例7: isCloseRequested
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public boolean isCloseRequested() {
return Display.isCloseRequested();
}
示例8: main
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void main(String[] args) {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("I don't get it");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
Display.destroy();
// exit code 1 : failure
System.exit(1);
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 640, 480, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
while (!Display.isCloseRequested()) {
// Clears a 2D Canvas.
glClear(GL_COLOR_BUFFER_BIT);
/* ">>" denotes a possibly modified piece of OpenGL documentation (http://www.opengl.org/sdk/docs/man/)
>> glBegin and glEnd delimit the vertices that define a primitive or a group of like primitives.
>> glBegin accepts a single argument that specifies how the vertices are interpreted.
All upcoming vertex calls will be taken as points of a quadrilateral until glEnd is called. Since
this primitive requires four vertices, we will have to call glVertex four times. */
// glBegin() takes an integer as a parameter.
// all of the set commands are constants
// GL_POINTS, GL_LINES, GL_TRIANGLES, GL_QUADS, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, and GL_POLYGONS
// Don't use GL_QUADS or GL_POLYGONS, as they have been deprecated.
glBegin(GL_QUADS);
// >> glVertex commands are used within glBegin/glEnd pairs to specify point, line, and polygon vertices.
// >> glColor sets the current color. (All subsequent calls to glVertex will be assigned this color)
// >> The number after 'glVertex'/'glColor' indicates the amount of components. (xyzw/rgba)
// >> The character after the number indicates the type of arguments.
// >> (for 'glVertex' = d: Double, f: Float, i: Integer)
// >> (for 'glColor' = d: Double, f: Float, b: Signed Byte, ub: Unsigned Byte)
// glVertex() takes its parameters as its location.
// glColor() takes its parameters and makes it a color.
glColor3f(1.0f, 0.0f, 0.0f); // Pure Green
glVertex2i(0, 0); // Upper-left
glColor3b((byte)0, (byte)127, (byte)0); // Pure Red
glVertex2d(640, 0); // Upper-right
glColor3ub((byte)255, (byte)0, (byte)255); // Purple
glVertex2f(640.0f, 480.0f); // Bottom-right
glColor3d(0, 0, 1); // Pure Blue
glVertex2i(0, 480); // Bottom-left
glEnd();
// refresh display and poll input
Display.update();
// Maintain a 60fps frame rate
Display.sync(60);
}
Display.destroy();
// exit code 0 : success!
System.exit(0);
}
示例9: main
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void main(String[] args) {
RenderEngine engine = RenderEngine.init();
SceneLoader loader = SceneLoaderFactory.createSceneLoader();
Scene scene = loader.loadScene(new MyFile(LoaderSettings.RES_FOLDER, "Socuwan Scene"));
engine.renderEnvironmentMap(scene.getEnvironmentMap(), scene, new Vector3f(0, 2, 0));
MyFile flareFolder = new MyFile("res", "lensFlare");
//loading textures for lens flare
Texture texture1 = Texture.newTexture(new MyFile(flareFolder, "tex1.png")).normalMipMap().create();
Texture texture2 = Texture.newTexture(new MyFile(flareFolder, "tex2.png")).normalMipMap().create();
Texture texture3 = Texture.newTexture(new MyFile(flareFolder, "tex3.png")).normalMipMap().create();
Texture texture4 = Texture.newTexture(new MyFile(flareFolder, "tex4.png")).normalMipMap().create();
Texture texture5 = Texture.newTexture(new MyFile(flareFolder, "tex5.png")).normalMipMap().create();
Texture texture6 = Texture.newTexture(new MyFile(flareFolder, "tex6.png")).normalMipMap().create();
Texture texture7 = Texture.newTexture(new MyFile(flareFolder, "tex7.png")).normalMipMap().create();
Texture texture8 = Texture.newTexture(new MyFile(flareFolder, "tex8.png")).normalMipMap().create();
Texture texture9 = Texture.newTexture(new MyFile(flareFolder, "tex9.png")).normalMipMap().create();
Texture sun = Texture.newTexture(new MyFile(flareFolder, "sun.png")).normalMipMap().create();
//set up lens flare
FlareManager lensFlare = new FlareManager(0.16f, new FlareTexture(texture6, 1f),
new FlareTexture(texture4, 0.46f), new FlareTexture(texture2, 0.2f), new FlareTexture(texture7, 0.1f), new FlareTexture(texture1, 0.04f),
new FlareTexture(texture3, 0.12f), new FlareTexture(texture9, 0.24f), new FlareTexture(texture5, 0.14f), new FlareTexture(texture1, 0.024f), new FlareTexture(texture7, 0.4f),
new FlareTexture(texture9, 0.2f), new FlareTexture(texture3, 0.14f), new FlareTexture(texture5, 0.6f), new FlareTexture(texture4, 0.8f),
new FlareTexture(texture8, 1.2f));
//init sun and set sun direction
Sun theSun = new Sun(sun, 40);
SunRenderer sunRenderer = new SunRenderer();
theSun.setDirection(WorldSettings.LIGHT_DIR);
while (!Display.isCloseRequested()) {
((Camera) scene.getCamera()).move();
engine.renderScene(scene);
sunRenderer.render(theSun, scene.getCamera());
lensFlare.render(scene.getCamera(), theSun.getWorldPosition(scene.getCamera().getPosition()));
engine.update();
}
lensFlare.cleanUp();
sunRenderer.cleanUp();
scene.delete();
engine.close();
}
示例10: isCloseRequested
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public boolean isCloseRequested() {
return Display.isCloseRequested();
}
示例11: 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);
}
示例12: main
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void main(String[] args) {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("Coordinate Systems");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
Display.destroy();
System.exit(1);
}
// Initialization code OpenGL
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(1, 1, 1, 1, 1, -1);
// glOrtho(left, right, bottom, top, zNear, zFar)
// left = left edge
// right = offset between right and left edges (NOT PIXELS, UNITS)
// bottom = offset between top and bottom edges (NOT PIXELS, UNITS)
// up = top edge
// zNear, zFar = depth for z-axis // Set to 1, -1 for 2D things
glMatrixMode(GL_MODELVIEW);
while (!Display.isCloseRequested()) {
// Render
glClear(GL_COLOR_BUFFER_BIT);
glPointSize(10);
glBegin(GL_POINTS);
glColor3d(0.0, 1.0, 0.0); // Color : GREEN
glVertex2f(0, 0); // spaces away from center
glColor3d(1.0, 0.0, 0.0); // Color : RED
glVertex2f(-1, 0); // spaces away from center
glVertex2f(1, 0); // spaces away from center
glVertex2f(-1, 0); // spaces away from center
glVertex2f(0, 1); // spaces away from center
glVertex2f(0, -1); // spaces away from center
glColor3d(0.0, 1.0, 1.0); // Color : CYAN
glVertex2f(1, 1); // spaces away from center
glVertex2f(-1, 1); // spaces away from center
glVertex2f(-1, -1); // spaces away from center
glVertex2f(1, -1); // spaces away from center
glEnd();
Display.update();
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
示例13: 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);
}
示例14: main
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static void main(String[] args) {
try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.setTitle("Input");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
Display.destroy();
// exit code 1 : failure
System.exit(1);
}
shapes.add(new Box(15, 15));
shapes.add(new Box(150, 150));
shapes.add(new Box(5, 15));
shapes.add(new Box(10, 150));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
while (!Display.isCloseRequested()) {
// Render Data
glClear(GL_COLOR_BUFFER_BIT);
if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
Display.destroy();
System.exit(0);
}
for (final Box box : shapes) {
if (Mouse.isButtonDown(0) && box.inBounds(Mouse.getX(), 480 - Mouse.getY()) && !somethingIsSelected) {
somethingIsSelected = true;
box.selected = true;
}
if (Mouse.isButtonDown(2) && box.inBounds(Mouse.getX(), 480 - Mouse.getY()) && !somethingIsSelected) {
if ((System.currentTimeMillis() - lastColourChange) >= 200) {
box.randomizeColors();
lastColourChange = System.currentTimeMillis();
}
}
if (Mouse.isButtonDown(1)) {
box.selected = false;
somethingIsSelected = false;
}
if (box.selected) {
box.update(Mouse.getDX(), -Mouse.getDY());
}
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);
}