Esempio n. 1
0
        public Rectangle2D(Vector3 position, Vector3 scale, float rotation, Color color)
        {
            vertexArray     = new VertexArray();
            FillIndexBuffer = new IndexBuffer(FillIndices);
            vertexBuffer    = new Buffers.Buffer(Vertices, 3);

            vertexArray.AddBuffer(vertexBuffer, 0);

            Position = Matrix4.CreateTranslation(position);
            Scale    = Matrix4.CreateScale(scale);
            Rotation = Matrix4.CreateRotationZ(rotation);
            Color    = color;
        }
Esempio n. 2
0
    protected override void OnLoad(EventArgs e)
    {
        vertex = new float[8] {
            -0.5f, -0.5f,
            0.5f, -0.5f,
            0.5f, 0.5f,
            -0.5f, 0.5f
        };

        index = new uint[6]
        {
            0, 1, 2,
            2, 3, 0
        };

        vbo = new VertexBuffer <float>(vertex, vertex.Length * sizeof(float));

        vao = new VertexArray();

        VertexBufferLayout layout = new VertexBufferLayout();

        layout.Push(2, VertexAttribPointerType.Float);

        vao.AddBuffer(vbo, layout);

        ibo = new IndexBuffer(index, index.Length);

        shader = new Shader("Standard");
        shader.Bind();

        shader.Uniform4("u_Color", Color4.Teal);

        renderer = new Renderer();

        base.OnLoad(e);
    }
Esempio n. 3
0
        public CubeModel()
        {
            vao           = new VertexArray();
            shaderProgram = new ShaderProgram();
            shaderProgram.AddShader(ShaderType.VertexShader, VERT_SHADER);
            shaderProgram.AddShader(ShaderType.FragmentShader, FRAG_SHADER);
            shaderProgram.Link();
            tex = new Texture("fanera.jpg");

            Vertex[] data;
            UInt32[] indexes;

            var of = new ObjFile("cube.3dobj");

            of.GetGeometry(out data, out indexes);

            elementCount = indexes.Length;
            ibo          = new IndexBuffer(indexes);

            using (var vbo = new VertexBuffer(data))
            {
                vao.AddBuffer(vbo, shaderProgram, Vertex.Attributes);
            }
        }