private void replaceGeometryValue(GLDrawContext context, int pos, float value) throws IllegalBufferException { bfr.rewind(); bfr.putFloat(value); context.updateGeometryAt(geometry, pos*4, bfr); }
private void updateMapType(MapDrawContext context, int x, int y) throws IllegalBufferException { int bfr_pos = y*bufferWidth+x; if(mapInvalid.get(bfr_pos)) { mapInvalid.clear(bfr_pos); shape_update_bfr.rewind(); addTrianglesToGeometry(context, shape_update_bfr, x, y); context.getGl().updateGeometryAt(shapeHandle, bfr_pos * BYTES_PER_FIELD_SHAPE, shape_update_bfr); } }
public static SharedGeometryHandle addGeometry(GLDrawContext dc, float[] data) throws IllegalBufferException { if(staticdc == null) staticdc = dc; int sgeometryIndex = 0; while(true) { // create an instance if needed if(geometries.size() == sgeometryIndex) geometries.add(new SharedGeometry(dc, ++maxIndex)); SharedGeometry geometry = geometries.get(sgeometryIndex); // generate it geometry.validate(dc); // skip if we wont fit if (geometry.size < CAPACITY) { // add it to our vbo generate_buffer.asFloatBuffer().put(data); dc.updateGeometryAt(geometry.geometry, QUAD_SIZE*geometry.size, generate_buffer); generate_buffer.rewind(); geometry.size++; return new SharedGeometryHandle(geometry); } sgeometryIndex++; } }
private void generateGeometry(MapDrawContext context) throws IllegalBufferException { int vertices = bufferWidth*bufferHeight*3*2; shapeHandle = context.getGl().generateGeometry(vertices, EGeometryFormatType.Texture3D, false, "background-shape"); colorHandle = context.getGl().generateGeometry(vertices, EGeometryFormatType.ColorOnly, true, "background-color"); ByteBuffer shape_bfr = ByteBuffer.allocateDirect(BYTES_PER_FIELD_SHAPE*bufferWidth).order(ByteOrder.nativeOrder()); ByteBuffer color_bfr = ByteBuffer.allocateDirect(BYTES_PER_FIELD_COLOR*bufferWidth).order(ByteOrder.nativeOrder()); for(int y = 0;y != bufferHeight;y++) { for(int x = 0; x != bufferWidth;x++) { addTrianglesToGeometry(context, shape_bfr, x, y); } context.getGl().updateGeometryAt(shapeHandle, BYTES_PER_FIELD_SHAPE*bufferWidth*y, shape_bfr); shape_bfr.rewind(); } for(int y = 0;y != bufferHeight;y++) { int line_bfr4 = y*bufferWidth*4; for(int x = 0; x != bufferWidth;x++) { addColorTrianglesToGeometry(context, color_bfr, x, y, line_bfr4+x*4); } context.getGl().updateGeometryAt(colorHandle, BYTES_PER_FIELD_COLOR*bufferWidth*y, color_bfr); color_bfr.rewind(); } }
gl.updateGeometryAt(buildHandle, 0, buildBfr); gl.draw2D(buildHandle, texture, EGeometryType.Triangle, 0, 3, left, top, 0, 1, 1, 1, null, color); } catch (IllegalBufferException e) {
context.updateGeometryAt(lineGeometry, 0, lineBfr);
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); }
dimFogOfWarBuffer(context, bfr_pos4+3, x + 1, y + 1); addColorTrianglesToGeometry(context, color_update_bfr, x, y, bfr_pos4); context.getGl().updateGeometryAt(colorHandle, bfr_pos * BYTES_PER_FIELD_COLOR, color_update_bfr);