    private void doRendering() {
        mFramesDone++;
        mCanRender = false;
        if (webglCheck() == 1) {
            mNumVertices = 0;
            String label = "";
            int vertexStyle;
            int edgeStyle;
            double edgeThickness = 6;
            float[] highlightColour = DrawingConstants.YELLOW;
            if(mZoom <= EDGE_ZOOM_LIMIT) edgeThickness = edgeThickness*mZoom; 
            mVerticesList.clear();
            mIndicesList.clear();
            mColorsList.clear();
            if (!mWebglReady)
                setUpWebGL();
            for (EdgeDrawable thisEdge : mEdgesToDraw) {
                mCurrentPolygon = thisEdge.getPolygon();
                double startX = (thisEdge.getStartX() + mOffsetX) * mZoom;
                double startY = (thisEdge.getStartY() + mOffsetY) * mZoom;
                double endX = (thisEdge.getEndX() + mOffsetX) * mZoom;
                double endY = (thisEdge.getEndY() + mOffsetY) * mZoom;
                int weight = thisEdge.getWeight();
                float[] edgeColour = DrawingConstants.BLACK;
                float[] textColour = DrawingConstants.BLACK;
                int strokeThickness = 4;
                edgeStyle = 100;
                if (thisEdge.isHilighted()){
                    edgeStyle = -edgeStyle;
                    edgeColour = DrawingConstants.YELLOW;
                }
                if(thisEdge.needsToFromArrow()){
                    if (thisEdge.isHilighted()){
                        addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", highlightColour, textColour);
                        addEdge(startX, startY, endX, endY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,"", edgeColour, textColour);
                    }else{
                        addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", edgeColour, textColour);
                    }
                } else if(thisEdge.needsToFromArrow()){
                    if (thisEdge.isHilighted()){
                        addEdge(endX, endY, startX, startY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", highlightColour, textColour);
                        addEdge(endX, endY, startX, startY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,"", edgeColour, textColour);
                    }else{
                        addEdge(endX, endY, startX, startY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", edgeColour, textColour);
                    }
                } else {
                    if (thisEdge.isHilighted()){
                        addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", highlightColour, textColour);
                        addEdge(startX, startY, endX, endY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,"", edgeColour, textColour);
                    }else{
                        addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", edgeColour, textColour);
                    }
                }
            }
            if (mShowUILine) {
                addEdge((mUIline[0]+ mOffsetX)*mZoom, (mUIline[1]+ mOffsetY)*mZoom, 
                        (mUIline[2]+ mOffsetX)*mZoom, (mUIline[3]+ mOffsetY)*mZoom,
                        edgeThickness, true,false,edgeThickness*5,edgeThickness*5,"", DrawingConstants.GREY, DrawingConstants.BLACK);
            }
            for (VertexDrawable thisVertex : mVerticesToDraw) {
                mNumVertices++;
                double centreX = (thisVertex.getCenterX() + mOffsetX) * mZoom;
                double centreY = (thisVertex.getCenterY() + mOffsetY) * mZoom;
                double width = (thisVertex.getWidth()) * mZoom;
                double height = (thisVertex.getHeight()) * mZoom;
                label = thisVertex.getLabel();
                vertexStyle = thisVertex.getStyle();
                float[] customColor = { 0, 0, 0, 1};
                switch (vertexStyle) {
                    case VertexDrawable.STROKED_TERM_STYLE:
                        if (thisVertex.isHilighted()) {
                            addTerm(centreX, centreY,width,height, DrawingConstants.YELLOW);
                            addTerm(centreX, centreY,width-4,height-4, DrawingConstants.GREY);
                        } else {
                            addTerm(centreX, centreY,width,height, DrawingConstants.BLACK);
                            addTerm(centreX, centreY,width-4,height-4, DrawingConstants.GREY);
                        }
                        addStringBox(centreX, centreY, width-height,height, label, DrawingConstants.BLACK);
                        break;
                    case VertexDrawable.STROKED_SQUARE_STYLE:
                        if (thisVertex.isHilighted()) {
                            addSquare(centreX, centreY,width,height, DrawingConstants.YELLOW);
                            addSquare(centreX, centreY,width-4,height-4, DrawingConstants.GREY);
                        } else {
                            addSquare(centreX, centreY,width,height, DrawingConstants.BLACK);
                            addSquare(centreX, centreY,width-4,height-4, DrawingConstants.GREY);
                        }
                        addStringBox(centreX, centreY, width,height, label, DrawingConstants.BLACK);
                        break;
                    case VertexDrawable.STROKED_DIAMOND_STYLE:
                        if (thisVertex.isHilighted()) {
                            addDiamondStroke(centreX, centreY, width,height,DrawingConstants.GREY,
                                    2,DrawingConstants.YELLOW);
                        } else {
                            addDiamondStroke(centreX, centreY, width,height,DrawingConstants.GREY,
                                    2,DrawingConstants.BLACK);
                        }
                        addStringCircle(centreX, centreY, width/2, label, DrawingConstants.BLACK);
                        break;
                    case VertexDrawable.COLORED_FILLED_CIRCLE:
                        customColor = thisVertex.getColor();
                        addCircle(centreX, centreY, width, customColor);
                        break; 
                    default:
                        if (thisVertex.isHilighted()) {
                            addCircle(centreX, centreY, width, highlightColour);
                            addCircle(centreX, centreY, width - 4, DrawingConstants.YELLOW);
                        } else {
                            addCircle(centreX, centreY, width, DrawingConstants.BLACK);
                        }
                        break;
                }
            }
            renderGraph();
            mCanRender = true;
        } else {
            renderGraph2d(m2dCanvas, mEdgesToDraw, mVerticesToDraw);
        }
    }

    private void doRendering() {
        mFramesDone++;
        mCanRender = false;
        if (webglCheck() == 1) {
            mNumVertices = 0;
            String label = "";
            int vertexStyle;
            int edgeStyle;
            double edgeThickness = 6;
            float[] highlightColour = DrawingConstants.YELLOW;
            if(mZoom <= EDGE_ZOOM_LIMIT) edgeThickness = edgeThickness*mZoom; 
            mVerticesList.clear();
            mIndicesList.clear();
            mColorsList.clear();
            if (!mWebglReady)
                setUpWebGL();
            for (EdgeDrawable thisEdge : mEdgesToDraw) {
                mCurrentPolygon = thisEdge.getPolygon();
                double startX = (thisEdge.getStartX() + mOffsetX) * mZoom;
                double startY = (thisEdge.getStartY() + mOffsetY) * mZoom;
                double endX = (thisEdge.getEndX() + mOffsetX) * mZoom;
                double endY = (thisEdge.getEndY() + mOffsetY) * mZoom;
                int weight = thisEdge.getWeight();
                float[] edgeColour = DrawingConstants.BLACK;
                float[] textColour = DrawingConstants.BLACK;
                int strokeThickness = 4;
                edgeStyle = 100;
                if (thisEdge.isHilighted()){
                    edgeStyle = -edgeStyle;
                    edgeColour = DrawingConstants.YELLOW;
                }
                if(thisEdge.needsToFromArrow()){
                    if (thisEdge.isHilighted()){
                        addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", highlightColour, textColour);
                        addEdge(startX, startY, endX, endY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,"", highlightColour, textColour);
                    }else{
                        addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", edgeColour, textColour);
                    }
                } else if(thisEdge.needsToFromArrow()){
                    if (thisEdge.isHilighted()){
                        addEdge(endX, endY, startX, startY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", highlightColour, textColour);
                        addEdge(endX, endY, startX, startY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,"", highlightColour, textColour);
                    }else{
                        addEdge(endX, endY, startX, startY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", edgeColour, textColour);
                    }
                } else {
                    if (thisEdge.isHilighted()){
                        addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", highlightColour, textColour);
                        addEdge(startX, startY, endX, endY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,"", highlightColour, textColour);
                    }else{
                        addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+"", edgeColour, textColour);
                    }
                }
            }
            if (mShowUILine) {
                addEdge((mUIline[0]+ mOffsetX)*mZoom, (mUIline[1]+ mOffsetY)*mZoom, 
                        (mUIline[2]+ mOffsetX)*mZoom, (mUIline[3]+ mOffsetY)*mZoom,
                        edgeThickness, true,false,edgeThickness*5,edgeThickness*5,"", DrawingConstants.GREY, DrawingConstants.BLACK);
            }
            for (VertexDrawable thisVertex : mVerticesToDraw) {
                mNumVertices++;
                double centreX = (thisVertex.getCenterX() + mOffsetX) * mZoom;
                double centreY = (thisVertex.getCenterY() + mOffsetY) * mZoom;
                double width = (thisVertex.getWidth()) * mZoom;
                double height = (thisVertex.getHeight()) * mZoom;
                label = thisVertex.getLabel();
                vertexStyle = thisVertex.getStyle();
                float[] customColor = { 0, 0, 0, 1};
                switch (vertexStyle) {
                    case VertexDrawable.STROKED_TERM_STYLE:
                        if (thisVertex.isHilighted()) {
                            addTerm(centreX, centreY,width,height, DrawingConstants.YELLOW);
                            addTerm(centreX, centreY,width-4,height-4, DrawingConstants.GREY);
                        } else {
                            addTerm(centreX, centreY,width,height, DrawingConstants.BLACK);
                            addTerm(centreX, centreY,width-4,height-4, DrawingConstants.GREY);
                        }
                        addStringBox(centreX, centreY, width-height,height, label, DrawingConstants.BLACK);
                        break;
                    case VertexDrawable.STROKED_SQUARE_STYLE:
                        if (thisVertex.isHilighted()) {
                            addSquare(centreX, centreY,width,height, DrawingConstants.YELLOW);
                            addSquare(centreX, centreY,width-4,height-4, DrawingConstants.GREY);
                        } else {
                            addSquare(centreX, centreY,width,height, DrawingConstants.BLACK);
                            addSquare(centreX, centreY,width-4,height-4, DrawingConstants.GREY);
                        }
                        addStringBox(centreX, centreY, width,height, label, DrawingConstants.BLACK);
                        break;
                    case VertexDrawable.STROKED_DIAMOND_STYLE:
                        if (thisVertex.isHilighted()) {
                            addDiamondStroke(centreX, centreY, width,height,DrawingConstants.GREY,
                                    2,DrawingConstants.YELLOW);
                        } else {
                            addDiamondStroke(centreX, centreY, width,height,DrawingConstants.GREY,
                                    2,DrawingConstants.BLACK);
                        }
                        addStringCircle(centreX, centreY, width/2, label, DrawingConstants.BLACK);
                        break;
                    case VertexDrawable.COLORED_FILLED_CIRCLE:
                        customColor = thisVertex.getColor();
                        addCircle(centreX, centreY, width, customColor);
                        break; 
                    default:
                        if (thisVertex.isHilighted()) {
                            addCircle(centreX, centreY, width, highlightColour);
                            addCircle(centreX, centreY, width - 4, highlightColour);
                        } else {
                            addCircle(centreX, centreY, width, DrawingConstants.BLACK);
                        }
                        break;
                }
            }
            renderGraph();
            mCanRender = true;
        } else {
            renderGraph2d(m2dCanvas, mEdgesToDraw, mVerticesToDraw);
        }
    }
