本文整理匯總了Java中org.lwjgl.opengl.Display.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java Display.getWidth方法的具體用法?Java Display.getWidth怎麽用?Java Display.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.opengl.Display
的用法示例。
在下文中一共展示了Display.getWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例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: 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);
}
}
}
示例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);
}
示例5: createProjectionMatrix
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private void createProjectionMatrix() {
float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))) * aspectRatio);
float x_scale = y_scale / aspectRatio;
float frustum_lenght = FAR_PLANE - NEAR_PLANE;
projectionMatrix = new Matrix4f();
projectionMatrix.m00 = x_scale;
projectionMatrix.m11 = y_scale;
projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_lenght);
projectionMatrix.m23 = -1;
projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_lenght);
projectionMatrix.m33 = 0;
}
示例6: createProjectionMatrix
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private void createProjectionMatrix() {
float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
float yScale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))) * aspectRatio);
float xScale = yScale / aspectRatio;
float frustumLength = FAR_PLANE - NEAR_PLANE;
projectionMatrix = new Matrix4f();
projectionMatrix.m00 = xScale;
projectionMatrix.m11 = yScale;
projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustumLength);
projectionMatrix.m23 = -1;
projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustumLength);
projectionMatrix.m33 = 0;
}
示例7: createProjectionMatrix
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private static Matrix4f createProjectionMatrix() {
Matrix4f projectionMatrix = new Matrix4f();
float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))));
float x_scale = y_scale / aspectRatio;
float frustum_length = FAR_PLANE - NEAR_PLANE;
projectionMatrix.m00 = x_scale;
projectionMatrix.m11 = y_scale;
projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_length);
projectionMatrix.m23 = -1;
projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length);
projectionMatrix.m33 = 0;
return projectionMatrix;
}
示例8: createProjectionMatrix
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private static Matrix4f createProjectionMatrix(){
Matrix4f projectionMatrix = new Matrix4f();
float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))));
float x_scale = y_scale / aspectRatio;
float frustum_length = FAR_PLANE - NEAR_PLANE;
projectionMatrix.m00 = x_scale;
projectionMatrix.m11 = y_scale;
projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_length);
projectionMatrix.m23 = -1;
projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length);
projectionMatrix.m33 = 0;
return projectionMatrix;
}
示例9: createProjectionMatrix
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private static Matrix4f createProjectionMatrix() {
Matrix4f projectionMatrix = new Matrix4f();
float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))));
float x_scale = y_scale / aspectRatio;
float frustum_length = FAR_PLANE - NEAR_PLANE;
projectionMatrix.m00 = x_scale;
projectionMatrix.m11 = y_scale;
projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_length);
projectionMatrix.m23 = -1;
projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length);
projectionMatrix.m33 = 0;
return projectionMatrix;
}
示例10: getDisplayWidth_scaled
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static int getDisplayWidth_scaled() {
ScaledResolution scaledResolution = new ScaledResolution(Wrapper.getMinecraft(), Display.getWidth(),
Display.getHeight());
return scaledResolution.func_78326_a();
}
示例11: getDisplayHeight_scaled
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static int getDisplayHeight_scaled() {
ScaledResolution scaledResolution = new ScaledResolution(Wrapper.getMinecraft(), Display.getWidth(),
Display.getHeight());
return scaledResolution.func_78328_b();
}
示例12: getScaleFactor
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static int getScaleFactor() {
ScaledResolution scaledResolution = new ScaledResolution(Wrapper.getMinecraft(), Display.getWidth(),
Display.getHeight());
return scaledResolution.func_78325_e();
}
示例13: getDisplayScreenWidth
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
protected int getDisplayScreenWidth() {
return Display.getWidth();
}
示例14: update
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public static final void update(final PlayerInventory inventory) {
final float mx = MouseInput.getX();
final float my = MouseInput.getY();
inventory.input(mx, my);
if (GameStateGuis.mouseImage.recalc) {
GameStateGuis.mouseImage.remove();
GameStateGuis.mouseImage = new GuiImage(0f, 0f, 0f, .075f, mouseTexture);
GameStateGuis.mouseImage.add();
}
if (GameStateGuis.minimapImage.recalc) {
minimapImage.remove();
minimapImage = new GuiImage(-.75f, .55f, 0f, .4f, new Texture(Minimap.texture));
minimapImage.flipYAxis = true;
minimapImage.add();
}
if (GameStateGuis.inventory.recalc) {
GameStateGuis.inventory.remove();
GameStateGuis.inventory = new GuiImage(0, 0, (float) PlayerInventory.background.getWidth() / (float) Display.getWidth(), (float) PlayerInventory.background.getHeight() / (float) Display.getHeight(), null);
GameStateGuis.inventory.add();
}
}
示例15: renderFlare
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
* Renders a single flare texture to the screen on a textured 2D quad.
*
* The texture for this flare is first bound to texture unit 0. The x and y
* scale of the quad is then determined. The x scale is simply the scale
* value in the FlareTexture instance, and then the y scale is calculated by
* multiplying that by the aspect ratio of the display. This ensures that
* the quad is a square, and not a rectangle.
*
* The position and scale is then loaded up the the shader. Finally, the
* quad is rendered using glDrawArrays (no index buffer used), and using
* GL_TRIANGLE_STRIP. This allows the quad to be specified using only 4
* vertex positions, instead of having to specify the 6 vertex positions for
* the 2 triangles. See GUI tutorial for more info.
*
* @param flare
* - The flare to be rendered.
*/
private void renderFlare(FlareTexture flare) {
flare.getTexture().bindToUnit(0);
float xScale = flare.getScale();
float yScale = xScale * (float) Display.getWidth() / Display.getHeight();
Vector2f centerPos = flare.getScreenPos();
shader.transform.loadVec4(centerPos.x, centerPos.y, xScale, yScale);
GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4);
}