Ejemplo n.º 1
0
        public void Bind()
        {
            GLProg.Bind();
            GL.BindVertexArray(ID);

            if (Tex != null)
            {
                if (GLProg.SetUniform("TEX", Tex))
                {
                    Tex.Bind();
                }
            }
            if (Tex2 != null)
            {
                if (GLProg.SetUniform("TEX2", Tex2))
                {
                    Tex2.Bind();
                }
            }

            GLProg.SetUniform("u_modelview", ref ModelMatrix);
            GLProg.SetUniform("u_projection", ref Camera.Projection);
            GLProg.SetUniform("u_view", ref Camera.View);
            GLProg.SetUniform("u_viewrot", ref Camera.Rotation);
            GLProg.SetUniform("Time", (float)Program.SWatch.ElapsedMilliseconds / 1000);
            GLProg.SetUniform("Resolution", Camera.ScreenRes);
            GLProg.SetUniform("Settings", new Vector4(Settings.FXAA ? 1 : 0, Settings.Wireframe ? 1 : 0, 0, 0));

            Indices.Bind();
            Verts.Bind();
            Colors.BindOnAttrib(GLProg.Attrib("Color"));
            UVs.BindOnAttrib(GLProg.Attrib("UV"));
            BlockData.BindOnAttrib(GLProg.Attrib("Data"));
        }
Ejemplo n.º 2
0
        public VertexArray(Prog GLProgram, Matrix4 MViewMat,
                           Vector3[] Vert, uint[] Inds = null, Vector3[] Cols = null, Vector2[] UV = null, Vector4[] BlockInds = null)
        {
            ID = GL.GenVertexArray();
            GL.BindVertexArray(ID);

            ModelMatrix = MViewMat;
            GLProg      = GLProgram;

            Indices = new VertexBuffer <uint>(BufferTarget.ElementArrayBuffer, BufferUsageHint.StaticDraw);
            Verts   = new VertexBuffer <Vector3>(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw);
            Verts.SetAttribute(GLProg.Attrib("Position"));
            Colors    = new VertexBuffer <Vector3>(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw);
            UVs       = new VertexBuffer <Vector2>(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw);
            BlockData = new VertexBuffer <Vector4>(BufferTarget.ArrayBuffer, BufferUsageHint.StaticDraw);

            Set(Vert, Inds, Cols, UV, BlockInds);
        }