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 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(); }
public void FillTriangles(VertexBufferObject vbo, int nelements, Drawing.Color color) { SetCurrent(); CheckViewMatrix(); //-------------------------------------------- u_solidColor.SetValue((float)color.R / 255f, (float)color.G / 255f, (float)color.B / 255f, (float)color.A / 255f); vbo.Bind(); a_position.LoadLatest(); GL.DrawElements(BeginMode.Triangles, nelements, DrawElementsType.UnsignedShort, 0); vbo.UnBind(); //important, call unbind after finish call. }
public void Bind() { _vbo.Bind(); }