@Override public int getHeight() { return element.getHeight(); }
/** Kindly borrowed from PlayN. **/ protected int getRelativeY(MouseEvent e, HTMLCanvasElement target) { float yScaleRatio = target.getHeight() * 1f / target.getClientHeight(); return Math.round(yScaleRatio * (e.getClientY() - target.getAbsoluteTop() + target.getScrollTop() + target.getOwnerDocument() .getScrollTop())); } /*
private void step() { graphics.update(); graphics.frameId++; listener.resize(canvas.getWidth(), canvas.getHeight()); listener.render(); input.reset(); delayedStep(); }
private void startGdx() { canvas = config.getCanvas(); graphics = new TeaVMGraphics(canvas, config); files = new TeaVMFiles(); audio = new TeaVMAudio(); input = new TeaVMInput(canvas); Gdx.app = this; Gdx.graphics = graphics; Gdx.gl = graphics.getGL20(); Gdx.gl20 = graphics.getGL20(); Gdx.files = files; Gdx.audio = audio; Gdx.input = input; listener.create(); listener.resize(canvas.getWidth(), canvas.getHeight()); delayedStep(); }
public TeaVMGraphics(HTMLCanvasElement element, TeaVMApplicationConfig config) { this.element = element; this.config = config; WebGLContextAttributes attr = WebGLContextAttributes.create(); attr.setAlpha(config.isAlphaEnabled()); attr.setAntialias(config.isAntialiasEnabled()); attr.setStencil(config.isStencilEnabled()); attr.setPremultipliedAlpha(config.isPremultipliedAlpha()); attr.setPreserveDrawingBuffer(config.isDrawingBufferPreserved()); context = (WebGLRenderingContext)element.getContext("webgl"); context.viewport(0, 0, element.getWidth(), element.getHeight()); gl20 = new TeaVMGL20(context); }