// Demonstrate buffer feedback AND geo shader add vertex/dump vertex protected override void OnLoad(EventArgs e) { base.OnLoad(e); Closed += ShaderTest_Closed; gl3dcontroller = new Controller3D(); gl3dcontroller.PaintObjects = ControllerDraw; gl3dcontroller.ZoomDistance = 100F; gl3dcontroller.MatrixCalc.PerspectiveNearZDistance = 0.1f; glwfc.BackColor = Color.FromArgb(0, 0, 60); gl3dcontroller.Start(glwfc, new Vector3(0, 0, 0), new Vector3(120f, 0, 0f), 1F); gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) => { return((float)ms / 20.0f); }; IGLTexture array2d = items.Add(new GLTexture2DArray(new Bitmap[] { Properties.Resources.mipmap, Properties.Resources.mipmap2, Properties.Resources.mipmap3, Properties.Resources.mipmap4 }, SizedInternalFormat.Rgba8, 9), "2DArray2"); if (true) { items.Add(new GLMultipleTexturedBlended(false, 2), "ShaderPos"); items.Shader("ShaderPos").StartAction += (s, m) => { array2d.Bind(1); }; Vector4[] instancepositions = new Vector4[4]; instancepositions[0] = new Vector4(-25, 0, -40, 0); // last is image index.. instancepositions[1] = new Vector4(-25, 0, 0, 0); instancepositions[2] = new Vector4(-25, 0, 40, 2); instancepositions[3] = new Vector4(-25, 0, 80, 2); GLRenderState rt = GLRenderState.Tri(cullface: false); rObjects.Add(items.Shader("ShaderPos"), GLRenderableItem.CreateVector4Vector2Vector4(items, PrimitiveType.Triangles, rt, GLSphereObjectFactory.CreateTexturedSphereFromTriangles(3, 20.0f), instancepositions, ic: 4, separbuf: true )); } // Shader MAT if (true) { IGLProgramShader smat = items.Add(new GLMultipleTexturedBlended(true, 2), "ShaderMat"); smat.StartAction += (s, m) => { array2d.Bind(1); }; Matrix4[] pos2 = new Matrix4[3]; pos2[0] = Matrix4.CreateRotationY(-80f.Radians()); pos2[0] *= Matrix4.CreateTranslation(new Vector3(25, 0, -40)); pos2[0].M44 = 0; // this is the image number pos2[1] = Matrix4.CreateRotationY(-70f.Radians()); pos2[1] *= Matrix4.CreateTranslation(new Vector3(25, 0, 0)); pos2[1].M44 = 2; // this is the image number pos2[2] = Matrix4.CreateRotationZ(-60f.Radians()); pos2[2] *= Matrix4.CreateTranslation(new Vector3(25, 0, 40)); pos2[2].M44 = 0; // this is the image number GLRenderState rq = GLRenderState.Quads(cullface: false); rObjects.Add(items.Shader("ShaderMat"), GLRenderableItem.CreateVector4Vector2Matrix4(items, PrimitiveType.Quads, rq, GLShapeObjectFactory.CreateQuad(20.0f, 20.0f, new Vector3(-90f.Radians(), 0, 0)), GLShapeObjectFactory.TexQuadCW, pos2, ic: 3, separbuf: false )); } items.Add(new GLMatrixCalcUniformBlock(), "MCUB"); // def binding of 0 }