Ejemplo n.º 1
0
 public void RenderFrame(FrameEventArgs e)
 {
     // Buffer vertex normal if shader supports it
     if (shaderProgram.GetAttribute("vNormal") != -1 && model.Normals.Length > 0)
     {
         GL.BindBuffer(BufferTarget.ArrayBuffer, shaderProgram.GetBuffer("vNormal"));
         GL.BufferData <Vector3>(BufferTarget.ArrayBuffer,
                                 (IntPtr)(model.Normals.Length * Vector3.SizeInBytes),
                                 model.Normals, BufferUsageHint.StaticDraw);
         GL.VertexAttribPointer(shaderProgram.GetAttribute("vNormal"), 3, VertexAttribPointerType.Float, true, 0, 0);
     }
 }
Ejemplo n.º 2
0
        public virtual void RenderFrame(FrameEventArgs e)
        {
            GL.UseProgram(ShaderProgram.ProgramID);

            GL.BindBuffer(BufferTarget.ArrayBuffer, ShaderProgram.GetBuffer("vPosition"));
            GL.BufferData(BufferTarget.ArrayBuffer,
                          (IntPtr)(Model.Vertices.Length * Vector3.SizeInBytes),
                          Model.Vertices, BufferUsageHint.StaticDraw);

            GL.VertexAttribPointer(ShaderProgram.GetAttribute("vPosition"), 3, VertexAttribPointerType.Float, false, 0, 0);


            ShaderProgram.EnableVertexAttribArrays();
            Matrix4 mvp = Model.WorldViewProjectionMatrix;

            GL.UniformMatrix4(ShaderProgram.GetUniform("modelview"), false, ref mvp);


            GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBufferID);
            GL.BufferData(BufferTarget.ElementArrayBuffer,
                          (IntPtr)(Model.Indices.Length * sizeof(int)),
                          Model.Indices, BufferUsageHint.StaticDraw);
            foreach (var r in featureRenderers)
            {
                r.RenderFrame(e);
            }

            GL.DrawElements(Model.DrawMode, Model.Indices.Length, DrawElementsType.UnsignedInt, 0);
        }
Ejemplo n.º 3
0
 public void RenderFrame(FrameEventArgs e)
 {
     // Buffer texture coordinates if shader supports it
     if (shaderProgram.GetAttribute("vTexcoord") != -1 && model.TextureCoords.Length > 0)
     {
         GL.BindBuffer(BufferTarget.ArrayBuffer, shaderProgram.GetBuffer("vTexcoord"));
         GL.BufferData <Vector2>(BufferTarget.ArrayBuffer,
                                 (IntPtr)(model.TextureCoords.Length * Vector2.SizeInBytes),
                                 model.TextureCoords, BufferUsageHint.StaticDraw);
         GL.VertexAttribPointer(shaderProgram.GetAttribute("vTexcoord"), 2, VertexAttribPointerType.Float, true, 0, 0);
     }
     GL.BindTexture(TextureTarget.Texture2D, model.TextureID);
     if (shaderProgram.GetAttribute("maintexture") != -1)
     {
         GL.Uniform1(shaderProgram.GetAttribute("maintexture"), model.TextureID);
     }
 }