本文整理汇总了Java中org.lwjgl.opengl.Display类的典型用法代码示例。如果您正苦于以下问题:Java Display类的具体用法?Java Display怎么用?Java Display使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Display类属于org.lwjgl.opengl包,在下文中一共展示了Display类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startLWJGL
import org.lwjgl.opengl.Display; //导入依赖的package包/类
/**
* Start a thread to run LWJGL in
*/
public void startLWJGL() {
if (gameThread != null) {
return;
}
gameThread = new Thread() {
public void run() {
try {
canvas.start();
}
catch (Exception e) {
e.printStackTrace();
if (Display.isCreated()) {
Display.destroy();
}
displayParent.setVisible(false);//removeAll();
add(new ConsolePanel(e));
validate();
}
}
};
gameThread.start();
}
示例2: checkWindowResize
import org.lwjgl.opengl.Display; //导入依赖的package包/类
protected void checkWindowResize() {
if (!this.fullscreen && Display.wasResized()) {
int i = this.displayWidth;
int j = this.displayHeight;
this.displayWidth = Display.getWidth();
this.displayHeight = Display.getHeight();
if (this.displayWidth != i || this.displayHeight != j) {
if (this.displayWidth <= 0) {
this.displayWidth = 1;
}
if (this.displayHeight <= 0) {
this.displayHeight = 1;
}
this.resize(this.displayWidth, this.displayHeight);
}
}
}
示例3: setIngameFocus
import org.lwjgl.opengl.Display; //导入依赖的package包/类
/**
* Will set the focus to ingame if the Minecraft window is the active with focus. Also clears any GUI screen
* currently displayed
*/
public void setIngameFocus()
{
if (Display.isActive())
{
if (!this.inGameHasFocus)
{
if (!IS_RUNNING_ON_MAC)
{
KeyBinding.updateKeyBindState();
}
this.inGameHasFocus = true;
this.mouseHelper.grabMouseCursor();
this.displayGuiScreen((GuiScreen)null);
this.leftClickCounter = 10000;
}
}
}
示例4: init
import org.lwjgl.opengl.Display; //导入依赖的package包/类
/**
* Initialise the PBuffer that will be used to render to
*
* @throws SlickException
*/
private void init() throws SlickException {
try {
Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);
// Initialise state of the pbuffer context.
pbuffer.makeCurrent();
initGL();
GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
image.draw(0,0);
image.setTexture(tex);
Display.makeCurrent();
} catch (Exception e) {
Log.error(e);
throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
}
}
示例5: disable
import org.lwjgl.opengl.Display; //导入依赖的package包/类
/**
* @see org.newdawn.slick.Graphics#disable()
*/
protected void disable() {
// Bind the texture after rendering.
GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID());
GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0,
image.getTexture().getTextureWidth(),
image.getTexture().getTextureHeight(), 0);
try {
Display.makeCurrent();
} catch (LWJGLException e) {
Log.error(e);
}
SlickCallable.leaveSafeBlock();
}
示例6: update
import org.lwjgl.opengl.Display; //导入依赖的package包/类
public void update(GameContainer container, int delta)
throws SlickException {
if (!paused) {
ypos += delta * 0.002 * systemMove;
if (ypos > 300) {
ypos = -300;
}
if (ypos < -300) {
ypos = 300;
}
for (int i = 0; i < emitters.size(); i++) {
((ConfigurableEmitter) emitters.get(i)).replayCheck();
}
for (int i = 0; i < delta; i++) {
system.update(1);
}
}
Display.sync(100);
}
示例7: getProjection
import org.lwjgl.opengl.Display; //导入依赖的package包/类
protected Matrix4f getProjection(){
Renderer r=getRenderer();
if(r!=null) return r.getProjection();
float farPlane=1000,nearPlane=0.1F;
float aspectRatio=(float)Display.getWidth()/(float)Display.getHeight();
float y_scale=(float)(1f/Math.tan(Math.toRadians(60/2f))*aspectRatio);
float x_scale=y_scale/aspectRatio;
float frustum_length=farPlane-nearPlane;
NULL_PROJECTION.setIdentity();
NULL_PROJECTION.m00=x_scale;
NULL_PROJECTION.m11=y_scale;
NULL_PROJECTION.m22=-((farPlane+nearPlane)/frustum_length);
NULL_PROJECTION.m23=-1;
NULL_PROJECTION.m32=-(2*nearPlane*farPlane/frustum_length);
NULL_PROJECTION.m33=0;
return NULL_PROJECTION;
}
示例8: addServerStatsToSnooper
import org.lwjgl.opengl.Display; //导入依赖的package包/类
public void addServerStatsToSnooper(Snooper playerSnooper)
{
playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
playerSnooper.addClientStat("current_action", this.getCurrentAction());
playerSnooper.addClientStat("language", this.gameSettings.language == null ? "en_us" : this.gameSettings.language);
String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
playerSnooper.addClientStat("endianness", s);
playerSnooper.addClientStat("subtitles", Boolean.valueOf(this.gameSettings.showSubtitles));
playerSnooper.addClientStat("touch", this.gameSettings.touchscreen ? "touch" : "mouse");
playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
int i = 0;
for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
{
playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
}
if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
{
playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
}
}
示例9: shutdownMinecraftApplet
import org.lwjgl.opengl.Display; //导入依赖的package包/类
/**
* Shuts down the minecraft applet by stopping the resource downloads, and
* clearing up GL stuff; called when the application (or web page) is exited.
*/
public void shutdownMinecraftApplet() {
try {
this.stream.shutdownStream();
logger.info("Stopping!");
Client.getClient().onDisable();
try {
this.loadWorld((WorldClient) null);
} catch (Throwable var5) {
;
}
this.mcSoundHandler.unloadSounds();
} finally {
Display.destroy();
if (!this.hasCrashed) {
System.exit(0);
}
}
System.gc();
}
示例10: 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);
}
示例11: setFullscreen
import org.lwjgl.opengl.Display; //导入依赖的package包/类
/**
* Indicate whether we want to be in fullscreen mode. Note that the current
* display mode must be valid as a fullscreen mode for this to work
*
* @param fullscreen True if we want to be in fullscreen mode
* @throws SlickException Indicates we failed to change the display mode
*/
public void setFullscreen(boolean fullscreen) throws SlickException {
if (isFullscreen() == fullscreen) {
return;
}
if (!fullscreen) {
try {
Display.setFullscreen(fullscreen);
} catch (LWJGLException e) {
throw new SlickException("Unable to set fullscreen="+fullscreen, e);
}
} else {
setDisplayMode(width, height, fullscreen);
}
getDelta();
}
示例12: disable
import org.lwjgl.opengl.Display; //导入依赖的package包/类
/**
* @see org.newdawn.slick.Graphics#disable()
*/
protected void disable() {
GL.flush();
// Bind the texture after rendering.
GL.glBindTexture(GL11.GL_TEXTURE_2D, image.getTexture().getTextureID());
pbuffer.bindTexImage(Pbuffer.FRONT_LEFT_BUFFER);
try {
Display.makeCurrent();
} catch (LWJGLException e) {
Log.error(e);
}
SlickCallable.leaveSafeBlock();
}
示例13: checkWindowResize
import org.lwjgl.opengl.Display; //导入依赖的package包/类
protected void checkWindowResize()
{
if (!this.fullscreen && Display.wasResized())
{
int i = this.displayWidth;
int j = this.displayHeight;
this.displayWidth = Display.getWidth();
this.displayHeight = Display.getHeight();
if (this.displayWidth != i || this.displayHeight != j)
{
if (this.displayWidth <= 0)
{
this.displayWidth = 1;
}
if (this.displayHeight <= 0)
{
this.displayHeight = 1;
}
this.resize(this.displayWidth, this.displayHeight);
}
}
}
示例14: getFrameRate
import org.lwjgl.opengl.Display; //导入依赖的package包/类
protected int getFrameRate() {
int frameRate = Display.isActive() ? this.graphics.config.foregroundFPS : this.graphics.config.backgroundFPS;
if (frameRate == -1) {
frameRate = 10;
}
if (frameRate == 0) {
frameRate = this.graphics.config.backgroundFPS;
}
if (frameRate == 0) {
frameRate = 30;
}
return frameRate;
}
示例15: addServerStatsToSnooper
import org.lwjgl.opengl.Display; //导入依赖的package包/类
public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper)
{
playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
playerSnooper.addClientStat("current_action", this.func_181538_aA());
String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
playerSnooper.addClientStat("endianness", s);
playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
int i = 0;
for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
{
playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
}
if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
{
playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
}
}