public void FillTriangles(MultiPartTessResult multipartTessResult, int index, Drawing.Color color) { SetCurrent(); CheckViewMatrix(); //-------------------------------------------- u_solidColor.SetValue((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, (float)color.A / 255f); //-------------------------------------------- //note (A): //from https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glVertexAttribPointer.xml //... If a non-zero named buffer object is bound to the GL_ARRAY_BUFFER target (see glBindBuffer) //while a generic vertex attribute array is specified, //pointer is treated as **a byte offset** into the buffer object's data store. VertexBufferObject vbo = multipartTessResult.GetVBO(); int subPathCount = multipartTessResult.PartCount; vbo.Bind(); PartRange p = multipartTessResult.GetPartRange(index); a_position.LoadLatest(p.beginVertexAt * 4); //*4 => see note (A) above, so offset => beginVertexAt * sizeof(float) GL.DrawElements(BeginMode.Triangles, p.elemCount, DrawElementsType.UnsignedShort, p.beginElemIndexAt * 2); //*2 => see note (A) above, so offset=> beginElemIndexAt *sizeof(ushort) vbo.UnBind(); }
/// <summary> /// tess and read result as triangle list index array (for GLES draw element) /// </summary> /// <param name="tessTool"></param> /// <param name="vertex2dCoords"></param> /// <param name="contourEndPoints"></param> /// <param name="outputCoords"></param> /// <param name="vertexCount"></param> /// <returns></returns> internal static void TessAndAddToMultiPartResult(this TessTool tessTool, float[] vertex2dCoords, int[] contourEndPoints, MultiPartTessResult multipartTessResult, out int vertexCount) { if (!tessTool.TessPolygon(vertex2dCoords, contourEndPoints)) { vertexCount = 0; return; } //----------------------------- //results //1. List <ushort> indexList = tessTool.TessIndexList; //2. List <TessTempVertex> tempVertexList = tessTool.TempVertexList; //3. vertexCount = indexList.Count; //----------------------------- multipartTessResult.BeginPart(); multipartTessResult.AddTessCoords(vertex2dCoords); //append with newly create vertex(from tempVertList) int tempVertListCount = tempVertexList.Count; for (int i = 0; i < tempVertListCount; ++i) { TessTempVertex v = tempVertexList[i]; multipartTessResult.AddTessCoord((float)v.m_X, (float)v.m_Y); } multipartTessResult.AddVertexIndexList(indexList); multipartTessResult.EndPart(); }
public void DrawTriangleStrips(MultiPartTessResult multipartTessResult, int index, PixelFarm.Drawing.Color color) { ////note (A): ////from https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glVertexAttribPointer.xml ////... If a non-zero named buffer object is bound to the GL_ARRAY_BUFFER target (see glBindBuffer) ////while a generic vertex attribute array is specified, ////pointer is treated as **a byte offset** into the buffer object's data store. SetCurrent(); CheckViewMatrix(); //-------------------- u_solidColor.SetValue((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, (float)color.A / 255f); _shareRes.AssignStrokeColorToVar(u_solidColor); //because original stroke width is the width of both side of //the line, but u_linewidth is the half of the strokeWidth u_linewidth.SetValue(_shareRes._strokeWidth / 2f); //-------------------- VertexBufferObject borderVBO = multipartTessResult.GetBorderVBO(); borderVBO.Bind(); BorderPart p = multipartTessResult.GetBorderPartRange(index); //get part range from border part int borderSetIndex = p.beginAtBorderSetIndex; for (int i = 0; i < p.count; ++i) { PartRange borderset = multipartTessResult.GetSmoothBorderPartRange(borderSetIndex + i); a_position.LoadLatest(borderset.beginVertexAt * 4); GL.DrawArrays(BeginMode.TriangleStrip, 0, borderset.elemCount); } borderVBO.UnBind(); //unbind }
public MultiPartTessResult CreateMultiPartTessResult(MultiPartPolygon multipartPolygon) { //store internal gfx path inside render vx MultiPartTessResult multipartTessResult = new MultiPartTessResult(); _igfxPathBuilder.CreateGraphicsPathForMultiPartRenderVx(multipartPolygon, multipartTessResult, _glsx.GetTessTool(), _glsx.GetSmoothBorderBuilder()); // return(multipartTessResult); }
public void dbugDrawTriangleStrips(MultiPartTessResult multipartTessResult) { ////backup //System.Collections.Generic.List<SmoothBorderSet> borderSets = multipartTessResult.GetAllSmoothBorderSet(); //int j = borderSets.Count; //for (int i = 0; i < j; ++i) //{ // SmoothBorderSet borderSet = borderSets[i]; // DrawTriangleStrips( // borderSet.smoothBorderArr, // borderSet.vertexStripCount); //} }
void FillGfxPath(Drawing.Color color, MultiPartTessResult multipartTessResult, int index) { switch (SmoothMode) { case SmoothMode.No: { float saved_Width = StrokeWidth; Drawing.Color saved_Color = StrokeColor; //temp set stroke width to 2 amd stroke color //to the same as bg color (for smooth border). //and it will be set back later. // StrokeColor = color; StrokeWidth = 1.2f; //TODO: review this *** basicFillShader.FillTriangles(multipartTessResult, index, color); //restore stroke width and color StrokeWidth = saved_Width; //restore back StrokeColor = saved_Color; } break; case SmoothMode.Smooth: { float saved_Width = StrokeWidth; Drawing.Color saved_Color = StrokeColor; //temp set stroke width to 2 amd stroke color //to the same as bg color (for smooth border). //and it will be set back later. // StrokeColor = color; StrokeWidth = 1.2f; //TODO: review this *** basicFillShader.FillTriangles(multipartTessResult, index, color); //add smooth border smoothLineShader.DrawTriangleStrips(multipartTessResult, index, color); //restore stroke width and color StrokeWidth = saved_Width; //restore back StrokeColor = saved_Color; } break; } }
internal void CreateGraphicsPathForMultiPartRenderVx( MultiPartPolygon multipartPolygon, MultiPartTessResult multipartTessResult, TessTool tessTool, SmoothBorderBuilder borderBuilder) { //a multipart polygon contains a list of expand coord (x,y) set. List <float[]> expandCoordsList = multipartPolygon.expandCoordsList; List <int[]> endPointList = multipartPolygon.contourEndPoints; int listCount = expandCoordsList.Count; for (int i = 0; i < listCount; ++i) { //expand x,y float[] expandCoords = expandCoordsList[i]; int[] endPoints = endPointList[i]; //area int localVertexCount; tessTool.TessAndAddToMultiPartResult(expandCoords, endPoints, multipartTessResult, out localVertexCount); //borders //build smooth border int m = endPoints.Length; int latest_endPoint = 0; multipartTessResult.BeginBorderPart(); for (int n = 0; n < m; ++n) { int endPoint = endPoints[n]; //'x' , not include 'y' int len = (endPoint - latest_endPoint) + 1; //so len we add +1 for 'y' int borderTriangleStripCount; //expand coords for draw array float[] smoothBorderXYs = borderBuilder.BuildSmoothBorders(expandCoords, latest_endPoint, len, out borderTriangleStripCount); latest_endPoint += len + 2; multipartTessResult.AddSmoothBorders(smoothBorderXYs, borderTriangleStripCount); } multipartTessResult.EndBorderPart(); } }
public void DrawTriangleStrips(MultiPartTessResult multipartTessResult) { throw new NotSupportedException(); }
public GLRenderVx(MultiPartTessResult multipartTessResult) { this.multipartTessResult = multipartTessResult; }
internal InternalGraphicsPath(MultiPartTessResult _mutltiPartTess) { this._figure = null; this.figures = null; this._mutltiPartTess = _mutltiPartTess; }
internal InternalGraphicsPath(Figure fig) { this.figures = null; this._mutltiPartTess = null; _figure = fig; }
internal InternalGraphicsPath(List <Figure> figures) { _figure = null; _mutltiPartTess = null; this.figures = figures; }
public void FillRenderVx(Drawing.Color color, MultiPartTessResult multiPartTessResult, int index) { FillGfxPath(color, multiPartTessResult, index); }