예제 #1
0
        private void DatagridVertexDescriptions_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (!bolDataGridReady)
            {
                return;
            }
            DataGridViewRow rowData           = datagridVertexDescriptions.Rows[e.RowIndex];
            clsVertexDescriptionComponent vrt = rowData.Tag as clsVertexDescriptionComponent;

            if (vrt == null)
            {
                return;
            }
            vrt.Index         = int.Parse(rowData.Cells["columnIndex"].Value.ToString());
            vrt.Name          = (string)rowData.Cells["columnComponentName"].Value;
            vrt.ElementGLType = (VertexAttribPointerType)Enum.Parse(typeof(VertexAttribPointerType), rowData.Cells["columnElementType"].Value.ToString());
            vrt.ElementCount  = int.Parse(rowData.Cells["columnElementCount"].Value.ToString());
            for (int itrRow = 0; itrRow < datagridVertexDescriptions.Rows.Count; itrRow++)
            {
                DataGridViewRow rowItr = datagridVertexDescriptions.Rows[itrRow];
                clsVertexDescriptionComponent vrtItr = rowItr.Tag as clsVertexDescriptionComponent;
                if (vrtItr != null)
                {
                    rowItr.Cells["columnIndex"].Value = vrtItr.Index.ToString();
                }
            }
        }
        private void glRender_Render()
        {
            propsVertexDescriptionComponentItem itmBuff = lstPositionAttr.SelectedItem as propsVertexDescriptionComponentItem;

            if (itmBuff != null)
            {
                bool bolRendered = glRender.GLRender(new Action(() =>
                {
                    clsVertexDescriptionComponent comp = itmBuff.Component;
                    GL.Enable(EnableCap.Blend);
                    GL.Enable(EnableCap.ProgramPointSize);
                    GL.Enable(EnableCap.PointSmooth);
                    GL.PointSize(16);
                    GL.LineWidth(2);
                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadMatrix(ref matxProjection);
                    GL.MatrixMode(MatrixMode.Modelview);
                    GL.LoadIdentity();
                    if (itmBuff.Component.ElementCount >= 3)
                    {
                        GL.LoadMatrix(ref matxView);
                    }
                    GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.DstColor);
                    GL.EnableClientState(ArrayCap.VertexArray);
                    GL.EnableClientState(ArrayCap.IndexArray);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, Geometry.glBuffers[comp.Index]);
                    GL.VertexPointer(comp.ElementCount, clsVertexDescriptionComponent.VertexPointerTypes[comp.ElementGLType], comp.ComponentSize, 0);
                    GL.BindBuffer(BufferTarget.ElementArrayBuffer, Geometry.glIndexBuffer);
                    GL.Color4(Color.FromArgb(96, glRender.ForeColor));
                    GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                    GL.DrawElements(PrimitiveType.Triangles, Geometry.Triangles.Indices.Length, DrawElementsType.UnsignedInt, 0);
                    GL.Color4(Color.FromArgb(108, glRender.ForeColor));
                    GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
                    GL.DrawElements(PrimitiveType.Triangles, Geometry.Triangles.Indices.Length, DrawElementsType.UnsignedInt, 0);
                    GL.Color4(Color.FromArgb(128, glRender.ForeColor));
                    GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Point);
                    GL.DrawElements(PrimitiveType.Triangles, Geometry.Triangles.Indices.Length, DrawElementsType.UnsignedInt, 0);
                    GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                }));
                if (bolRendered)
                {
                    if (tsRender != null)
                    {
                        tsRender.SampleFrame(glRender.RenderResult.RenderTime);
                    }
                    if (glRender.RenderResult.GLResult != 0)
                    {
                        Console.WriteLine(glRender.RenderResult.GLResult);
                    }
                }
            }
        }
예제 #3
0
        private void DatagridVertexDescriptions_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            if (!bolDataGridReady)
            {
                return;
            }
            bolDataGridReady = false;
            clsVertexDescriptionComponent compNew = VertexDescription.Add(VertexAttribPointerType.Byte, "", 1, (object)0);
            DataGridViewRow rowNew = datagridVertexDescriptions.Rows[e.RowIndex - 1];

            rowNew.Tag = compNew;
            rowNew.Cells["columnIndex"].Value        = compNew.Index.ToString();
            rowNew.Cells["columnElementType"].Value  = compNew.ElementGLType.ToString();
            rowNew.Cells["columnElementCount"].Value = compNew.ElementCount.ToString();
            bolDataGridReady = true;
        }
 public propsVertexDescriptionComponentItem(clsVertexDescriptionComponent itm)
 {
     Component = itm;
 }