/// <summary> Called by render list and executes the operation </summary> public override void Execute(GLMatrixCalc c) { TransformFeedback.Bind(); // bind this transformfeedback to target transform feedback GLStatics.Check(); // bind these buffer at offset/set and binding index starting at 0 for (int i = 0; i < VaryingBuffers.Length; i++) { //System.Diagnostics.Debug.WriteLine($"TF {TransformFeedback.Id} bp {i} to buf {VaryingBuffers[i].Id}"); VaryingBuffers[i].BindTransformFeedback(i, TransformFeedback.Id, Offsets == null ? 0 : Offsets[i], Sizes == null ? 0 : Sizes[i]); } GLStatics.Check(); GLTransformFeedback.Begin(PrimitiveType); // and start GLStatics.Check(); }
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 }