/** * Creates a {@link Canvas} with the specified display unit size. */ public Canvas createCanvas (float width, float height) { return createCanvasImpl(scale, scale.scaledCeil(width), scale.scaledCeil(height)); }
/** * Creates a {@link Canvas} with the specified display unit size. */ public Canvas createCanvas (float width, float height) { return createCanvasImpl(scale, scale.scaledCeil(width), scale.scaledCeil(height)); }
private void updateViewport (Scale scale, float displayWidth, float displayHeight) { scaleChanged(scale); viewportChanged(scale.scaledCeil(displayWidth), scale.scaledCeil(displayHeight)); } }
@Override public Canvas createCanvas (float width, float height) { Scale scale = canvasScaleFunc.computeScale(width, height, scale()); return createCanvasImpl(scale, scale.scaledCeil(width), scale.scaledCeil(height)); }
/** * Creates an empty texture into which one can render. The supplied width and height are in * display units and will be converted to pixels based on the current scale factor. */ public Texture createTexture (float width, float height, Texture.Config config) { int texWidth = config.toTexWidth(scale.scaledCeil(width)); int texHeight = config.toTexHeight(scale.scaledCeil(height)); if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException( "Invalid texture size: " + texWidth + "x" + texHeight); int id = createTexture(config); gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); return new Texture(this, id, config, texWidth, texHeight, scale, width, height); }
/** * Creates an empty texture into which one can render. The supplied width and height are in * display units and will be converted to pixels based on the current scale factor. */ public Texture createTexture (float width, float height, Texture.Config config) { int texWidth = config.toTexWidth(scale.scaledCeil(width)); int texHeight = config.toTexHeight(scale.scaledCeil(height)); if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException( "Invalid texture size: " + texWidth + "x" + texHeight); int id = createTexture(config); gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); return new Texture(this, id, config, texWidth, texHeight, scale, width, height); }
int width = plat.graphics().scale().scaledCeil(config.width); int height = plat.graphics().scale().scaledCeil(config.height); canvas.setPreferredSize(new Dimension(width, height)); _frame.getContentPane().add(canvas);
void boundsChanged(CGRect bounds) { viewportChanged(scale().scaledCeil((float)bounds.getWidth()), scale().scaledCeil((float)bounds.getHeight())); orientDetailM.update(toOrientationDetail(UIDevice.getCurrentDevice().getOrientation())); }
/** * Sizes or resizes the root element that contains the game view. This is specified in pixels as * understood by page elements. If the page is actually being dispalyed on a HiDPI (Retina) * device, the actual framebuffer may be 2x (or larger) the specified size. */ public void setSize (int width, int height) { rootElement.getStyle().setWidth(width, Unit.PX); rootElement.getStyle().setHeight(height, Unit.PX); // the frame buffer may be larger (or smaller) than the logical size, depending on whether // we're on a HiDPI display, or how the game has configured things (maybe they're scaling down // from native resolution to improve performance) Scale fbScale = new Scale(frameBufferPixelRatio); canvas.setWidth(fbScale.scaledCeil(width)); canvas.setHeight(fbScale.scaledCeil(height)); // set the canvas's CSS size to the logical size; the browser works in logical pixels canvas.getStyle().setWidth(width, Style.Unit.PX); canvas.getStyle().setHeight(height, Style.Unit.PX); viewportChanged(canvas.getWidth(), canvas.getHeight()); }
/** * Sizes or resizes the root element that contains the game view. This is specified in pixels as * understood by page elements. If the page is actually being dispalyed on a HiDPI (Retina) * device, the actual framebuffer may be 2x (or larger) the specified size. */ public void setSize (int width, int height) { rootElement.getStyle().setWidth(width, Unit.PX); rootElement.getStyle().setHeight(height, Unit.PX); // the frame buffer may be larger (or smaller) than the logical size, depending on whether // we're on a HiDPI display, or how the game has configured things (maybe they're scaling down // from native resolution to improve performance) Scale fbScale = new Scale(frameBufferPixelRatio); canvas.setWidth(fbScale.scaledCeil(width)); canvas.setHeight(fbScale.scaledCeil(height)); // set the canvas's CSS size to the logical size; the browser works in logical pixels canvas.getStyle().setWidth(width, Style.Unit.PX); canvas.getStyle().setHeight(height, Style.Unit.PX); viewportChanged(canvas.getWidth(), canvas.getHeight()); }