private void drawViewMark(GLDrawContext context, float x, float y) { try { context.draw2D(lineGeometry, null, EGeometryType.LineLoop, 0, 6, x, y, 0, 1, 1, 1, null, 1); } catch (IllegalBufferException e) { e.printStackTrace(); } }
@Override public void drawOnlyImageAt(GLDrawContext gl, float x, float y, float z, Color torsoColor, float fow) { try { if(nullGeometry == null || !nullGeometry.isValid()) nullGeometry = gl.storeGeometry(nullData, EGeometryFormatType.VertexOnly2D, false, "placeholder/null"); gl.draw2D(nullGeometry, null, EGeometryType.Quad, 0, 4, x, y, z, 1, 1, 1, null, NULL_IMAGE_ALPHA); gl.draw2D(nullGeometry, null, EGeometryType.LineLoop, 0, 4, x, y, z, 1, 1, 1, Color.RED, 1); } catch (IllegalBufferException e) { e.printStackTrace(); } }
@Override public void drawImageAtRect(GLDrawContext gl, float x, float y, float width, float height) { try { checkStaticHandles(gl); gl.draw2D(rectHandle.geometry, texture, EGeometryType.Quad, rectHandle.index, 4, x, y, 0, twidth/this.width*width, theight/this.height*height, 0, null, 1); } catch (IllegalBufferException e) { handleIllegalBufferException(e); } }
@Override public void drawOnlyImageAt(GLDrawContext gl, float x, float y, float z, Color torsoColor, float fow) { try { checkHandles(gl); gl.draw2D(geometryIndex.geometry, texture, EGeometryType.Quad, geometryIndex.index, 4, x, y, z, 1, 1, 1, null, 1); } catch (IllegalBufferException e) { handleIllegalBufferException(e); } }
@Override public void drawOnlyImageAt(GLDrawContext gl, float x, float y, float z, Color torsoColor, float fow) { if(gl2Draw(gl, x, y, z, torsoColor, fow, true, false)) return; try { checkHandles(gl); gl.draw2D(geometryIndex.geometry, texture, EGeometryType.Quad, geometryIndex.index, 4, x, y, z, 1, 1, 1, null, fow); if(torso != null && torsoColor != null) { torso.checkHandles(gl); gl.draw2D(torso.geometryIndex.geometry, torso.texture, EGeometryType.Quad, torso.geometryIndex.index, 4, x, y, z, 1, 1, 1, torsoColor, fow); } } catch (IllegalBufferException e) { handleIllegalBufferException(e); } }
@Override public void drawOnlyImageAt(GLDrawContext gl, float x, float y, float z, Color torsoColor, float fow) { TextureHandle texture = map.getTexture(gl); try { if(settlerGeometry == null) { settlerGeometry = SharedGeometry.addGeometry(gl, settlerFloats); if(torsoFloats != null) torsoGeometry = SharedGeometry.addGeometry(gl, torsoFloats); } gl.draw2D(settlerGeometry.geometry, texture, EGeometryType.Quad, settlerGeometry.index, 4, x, y, z, 1, 1, 1, null, fow); if(torsoFloats == null || torsoColor == null) return; gl.draw2D(torsoGeometry.geometry, texture, EGeometryType.Quad, torsoGeometry.index, 4, x, y, z, 1, 1, 1, torsoColor, fow); } catch (IllegalBufferException e) { e.printStackTrace(); } }
private void draw(GLDrawContext gl, SharedGeometry.SharedGeometryHandle handle, float x, float y, float z, float sx, float sy, float sz, Color color, float fow) { try { if(handle == null) geometryIndex = handle = SharedGeometry.addGeometry(gl, geometry); gl.draw2D(handle.geometry, texture.getTextureIndex(gl), EGeometryType.Quad, handle.index, 4, x, y, z, sx, sy, sz, color, fow); } catch (IllegalBufferException e) { try { texture.recreateTexture(); gl.draw2D(handle.geometry, texture.getTextureIndex(gl), EGeometryType.Quad, handle.index, 4, x, y, z, sx, sy, sz, color, fow); } catch (IllegalBufferException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
@Override public void drawOnlyShadowAt(GLDrawContext gl, float x, float y, float z) { if(gl2Draw(gl, x, y, z, null, 0, false, true)) return; if(shadow != null) { try { shadow.checkHandles(gl); gl.draw2D(shadow.geometryIndex.geometry, shadow.texture, EGeometryType.Quad, shadow.geometryIndex.index, 4, x, y, z, 1, 1, 1, null, 1); } catch (IllegalBufferException e) { handleIllegalBufferException(e); } } }
gl.draw2D(buildHandle, texture, EGeometryType.Triangle, 0, 3, left, top, 0, 1, 1, 1, null, color); } catch (IllegalBufferException e) { handleIllegalBufferException(e);
@Override public void drawImageAtRect(GLDrawContext gl, float x, float y, float width, float height) { try { if(rectHandle == null) { rectHandle = SharedGeometry.addGeometry(gl, settlerRectFloats); settlerRectFloats = null; } gl.draw2D(rectHandle.geometry, map.getTexture(gl), EGeometryType.Quad, rectHandle.index, 4, x, y, 0, width, height, 0, null, 1); } catch (IllegalBufferException e) { handleIllegalBufferException(e); } }
@Override public void drawAt(GLDrawContext gl) { super.drawAt(gl); TextDrawer drawer = gl.getTextDrawer(EFontSize.NORMAL); float textHeight = drawer.getHeight(inputString.toString() + "X"); float y = getPosition().getCenterY() - textHeight / 2; float x = getPosition().getMinX() + 2; drawer.drawString(x, y, inputString.toString()); if(geometry == null || !geometry.isValid()) geometry = gl.storeGeometry(new float[] {0, 0, 0, 1}, EGeometryFormatType.VertexOnly2D, false, "uiinput-line"); float carretX = x + drawer.getWidth(inputString.substring(0, carret) + "X") - drawer.getWidth("X"); try { gl.draw2D(geometry, null, EGeometryType.LineStrip, 0, 2, carretX, y, 0, 0, textHeight, 0, null, 1); } catch (IllegalBufferException e) { e.printStackTrace(); } }
context.draw2D(geometry, texture, EGeometryType.Quad, 0, 4, x, y, 0, 1, 1, 1, null, 1);
private void drawSelectionHint(GLDrawContext gl) { if (this.currentSelectionAreaStart != null && this.currentSelectionAreaEnd != null) { if(selectionArea == null || !selectionArea.isValid()) { selectionArea = gl.generateGeometry(4, EGeometryFormatType.VertexOnly2D, true, "selection-area"); } if(updateSelectionArea) { updateSelectionArea(); try { gl.updateGeometryAt(selectionArea, 0, selectionAreaBuffer); } catch (IllegalBufferException e) { e.printStackTrace(); } updateSelectionArea = false; } try { gl.draw2D(selectionArea, null, EGeometryType.LineLoop, 0, 4, 0, 0, 0, 1, 1, 1, null, 1); } catch (IllegalBufferException e) { e.printStackTrace(); } } }
@Override public void drawAt(GLDrawContext gl) { FloatRectangle position = getPosition(); float fillX = barFillPercentage < .01f ? 0 : barFillPercentage > .99f ? 1 : EMPTY_X * (1 - barFillPercentage) + FULL_X * barFillPercentage; float maxX = position.getMinX() * (1 - fillX) + position.getMaxX() * fillX; try { if (geometry == null || !geometry.isValid()) geometry = gl.generateGeometry(4, EGeometryFormatType.VertexOnly2D, false, name); if (!position.equals(writtenPosition) || writtenMaxX != maxX) { writtenPosition = position; writtenMaxX = maxX; geometryBfr.asFloatBuffer().put(new float[]{ maxX, position.getMinY(), position.getMinX(), position.getMinY(), position.getMinX(), position.getMaxY(), maxX, position.getMaxY()}); gl.updateGeometryAt(geometry, 0, geometryBfr); } gl.draw2D(geometry, null, EGeometryType.Quad, 0, 4, 0, 0, 0, 1, 1, 1, barColor, 1); } catch(IllegalBufferException ex) { ex.printStackTrace(); } super.drawBackground(gl); }
private void drawDebugColors() { GLDrawContext gl = this.context.getGl(); if(shapeHandle == null || !shapeHandle.isValid()) shapeHandle = gl.storeGeometry(shape, EGeometryFormatType.VertexOnly2D, false, "debugshape"); int drawX = context.getOffsetX(); int drawY = context.getOffsetY(); context.getScreenArea().stream().filterBounds(width, height).forEach((x, y) -> { try { int argb = map.getDebugColorAt(x, y, debugColorMode); if (argb != 0) { int height = context.getHeight(x, y); float dx = drawX+context.getConverter().getViewX(x, y, height); float dy = drawY+context.getConverter().getViewY(x, y, height); gl.draw2D(shapeHandle, null, EGeometryType.Quad, 0, 4, dx, dy, .5f, 1, 1, 1, Color.fromShort((short) argb), 1); } } catch (IllegalBufferException e) { // TODO: Create a crash report // This should never happen since we only use texture 0 (no texture) } }); }