示例#1
0
 /// <summary> Called by render list and executes the operation </summary>
 public override void Execute(GLMatrixCalc c)
 {
     GLTransformFeedback.End();
     for (int i = 0; i < TransformFeedbackOperation.VaryingBuffers.Length; i++)
     {
         //System.Diagnostics.Debug.WriteLine($"TF {TransformFeedbackOperation.Id} bp {i}");
         GLBuffer.UnbindTransformFeedback(i, TransformFeedbackOperation.Id);
     }
     GLStatics.Check();
     GLTransformFeedback.UnBind();
     GLStatics.Check();
 }
示例#2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Closed += ShaderTest_Closed;

            gl3dcontroller = new Controller3D();
            gl3dcontroller.PaintObjects = ControllerDraw;
            gl3dcontroller.MatrixCalc.PerspectiveNearZDistance = 1f;
            gl3dcontroller.MatrixCalc.PerspectiveFarZDistance  = 1000f;
            gl3dcontroller.ZoomDistance = 20F;
            gl3dcontroller.Start(glwfc, new Vector3(0, 0, 0), new Vector3(110f, 0, 0f), 1F);

            gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) =>
            {
                return((float)ms / 100.0f);
            };

            items.Add(new GLColorShaderWorld(), "COSW");

            var vs    = new GLPLVertexShaderColorModelObjectTranslation(new string[] { "modelpos" }, TransformFeedbackMode.InterleavedAttribs);
            var fs    = new GLPLFragmentShaderVSColor();
            var cosot = new GLShaderPipeline(vs, fs);

            items.Add(cosot, "COSOT");

            varyingbuffer       = new GLBuffer(10000, true, BufferUsageHint.DynamicCopy);
            cosot.StartAction  += (a, s) => { varyingbuffer.BindTransformFeedback(0); GLTransformFeedback.Begin(TransformFeedbackPrimitiveType.Triangles); };
            cosot.FinishAction += (s) => { GLTransformFeedback.End(); GLBuffer.UnbindTransformFeedback(0); };

            ts1 = new GLOperationQueryTimeStamp();
            ts2 = new GLOperationQueryTimeStamp();

            rObjects.Add(ts1);

            #region coloured lines

            GLRenderState def = new GLRenderState()
            {
                DepthTest = true
            };                                                                 // set up default state for fixed values - no depth test, rely on stencil

            #region Coloured triangles
            if (true)
            {
                GLRenderState rc = GLRenderState.Tri(def);
                rc.CullFace = true;

                shape = GLCubeObjectFactory.CreateSolidCubeFromTriangles(5f);
                rObjects.Add(cosot, "Tri1",
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Triangles, rc,
                                                                  shape,
                                                                  new Color4[] { Color4.Red, Color4.Red, Color4.Red, Color4.Red, Color4.Yellow, Color4.Yellow },
                                                                  new GLRenderDataTranslationRotation(new Vector3(10, 3, 20))
                                                                  ));
            }


            for (int i = 0; i < 1; i++)
            {
                GLRenderState lines = GLRenderState.Lines(def, 5);

                rObjects.Add(items.Shader("COSW"),
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, lines,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(-100, -0, -100), new Vector3(-100, -0, 100), new Vector3(10, 0, 0), 21),
                                                                  new Color4[] { Color.White, Color.Red, Color.DarkRed, Color.DarkRed })
                             );

                GLRenderState lines2 = GLRenderState.Lines(def, 1);

                rObjects.Add(items.Shader("COSW"),
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, lines2,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(-100, -0, -100), new Vector3(100, -0, -100), new Vector3(0, 0, 10), 21),
                                                                  new Color4[] { Color.Orange, Color.Blue, Color.DarkRed, Color.DarkRed }));

                rObjects.Add(items.Shader("COSW"),
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, lines2,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(-100, 10, -100), new Vector3(-100, 10, 100), new Vector3(10, 0, 0), 21),
                                                                  new Color4[] { Color.Yellow, Color.Orange, Color.Yellow, Color.Orange })
                             );

                rObjects.Add(items.Shader("COSW"),
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, lines2,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(-100, 10, -100), new Vector3(100, 10, -100), new Vector3(0, 0, 10), 21),
                                                                  new Color4[] { Color.Yellow, Color.Orange, Color.Yellow, Color.Orange })
                             );
            }

            rObjects.Add(ts2);

            #endregion


            #endregion

            #region Matrix Calc Uniform

            items.Add(new GLMatrixCalcUniformBlock(), "MCUB");     // def binding of 0

            #endregion
        }