コード例 #1
0
ファイル: GLController.cs プロジェクト: vitya-v7/sharpgl
        private void AddData(OpenGL gl)
        {
            NMPBufferGroup group = new NMPBufferGroup(gl);

            var verts   = MyTrefoilKnot.Vertices.SelectMany(x => x.to_array()).ToArray();
            var normals = MyTrefoilKnot.Normals.SelectMany(x => x.to_array()).ToArray();

            group.BufferData(gl, MyTrefoilKnot.Indices, verts, normals, new mat4[] { mat4.identity() },
                             new Material[] { new Material(new ColorF(255, 150, 50, 50), new ColorF(255, 10, 100, 10), new ColorF(255, 225, 225, 225), null, 100f) });
            group.PrepareVAO(gl, NmpProgram);

            NmpProgram.AddBufferGroup(group);
            NMPBufferGroup groupCube = new NMPBufferGroup(gl);

            var vertsCube   = FlatShadedCube.Vertices.SelectMany(x => x.to_array()).ToArray();
            var normalsCube = FlatShadedCube.Normals.SelectMany(x => x.to_array()).ToArray();


            groupCube.BufferData(gl, FlatShadedCube.Indices, vertsCube, normalsCube,
                                 new mat4[]
            {
                mat4.identity(),
                glm.translate(mat4.identity(), new vec3(1, 2, 3))
            },
                                 new Material[]
            {
                new Material(new ColorF(1f, 0.3f, 1, 0), new ColorF(1f, 1f, 0.5f, 0), new ColorF(1f, 1, 0, 1), null, 100f),
                new Material(new ColorF(1f, 0, 1, 0.3f), new ColorF(1f, 1f, 0.5f, 1), new ColorF(1f, 1, 0.3f, 0.3f), null, 100f)
            });
            groupCube.PrepareVAO(gl, NmpProgram);

            NmpProgram.AddBufferGroup(groupCube);
        }
コード例 #2
0
ファイル: GLController.cs プロジェクト: vitya-v7/sharpgl
        public void Draw(object sender, OpenGLEventArgs args)
        {
            GL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);


            // Add gradient background.
            SetVerticalGradientBackground(GL, new ColorF(255, 146, 134, 188), new ColorF(1f, 0, 1, 0));

            NmpProgram.BindAll(GL);
        }