Beispiel #1
0
        protected AbstractDisplayList(uint vertexSize, ShaderPipeline pipeline = null, VertexAttributeDescription[] vertexAttributes = null)
        {
            this.pipeline = pipeline ?? new ShaderPipeline(
                DefaultShader.FromType(typeof(T), ShaderType.Vertex),
                DefaultShader.FromType(typeof(T), ShaderType.Fragment));

            this.vertexAttributes = vertexAttributes ?? DefaultVertexDefinition.FromType(typeof(T));
            this.vertexSize       = vertexSize;
        }
Beispiel #2
0
        protected void Setup()
        {
            var vs = DefaultShader.FromType(typeof(VertexPositionColorTexture), PlainCore.Graphics.Core.ShaderType.Vertex);
            var fs = DefaultShader.FromType(typeof(VertexPositionColorTexture), PlainCore.Graphics.Core.ShaderType.Fragment);

            pipeline    = new ShaderPipeline(vs, fs);
            buffer      = new VertexArrayBuffer <VertexPositionColorTexture>(32, OpenGL.BufferUsage.StaticDraw);
            indexBuffer = new IndexBuffer <VertexPositionColorTexture>(OpenGL.BufferUsage.StaticDraw);
            vao         = new VertexArrayObject <VertexPositionColorTexture>(buffer, pipeline,
                                                                             DefaultVertexDefinition.FromType(typeof(VertexPositionColorTexture)));
            texture            = new DeviceTexture(DefaultShader.DEFFAULT_TEXTURE_UNIFORM_NAME, 100, 100, true);
            defaultFramebuffer = Framebuffer.GetDefault();
            var imageData = Image.Load("Example.png").SavePixelData();

            texture.Bind();
            texture.CopyData(imageData);
            buffer.Bind();
            buffer.CopyData(_ArrayPosition);
            buffer.Unbind();
            indexBuffer.Bind();
            indexBuffer.CopyData(indexArray);
            indexBuffer.Unbind();
            worldMatrix = new Matrix4fUniform(DefaultShader.MVP_UNIFORM_NAME);
        }
        private void Setup()
        {
            pipeline      = new ShaderPipeline(DefaultShader.FromType(typeof(VertexPositionColor), ShaderType.Vertex), DefaultShader.FromType(typeof(VertexPositionColor), ShaderType.Fragment));
            vab           = new VertexArrayBuffer <VertexPositionColor>(VertexPositionColor.Size, OpenGL.BufferUsage.StaticDraw);
            vao           = new VertexArrayObject <VertexPositionColor>(vab, pipeline, DefaultVertexDefinition.FromType(typeof(VertexPositionColor)));
            renderTexture = new RenderTexture(400, 400);

            vab.Bind();
            vao.Bind();
            pipeline.Bind();
            vab.CopyData(vertices);
            worldMatrix = new Matrix4fUniform(DefaultShader.MVP_UNIFORM_NAME);
            pipeline.Unbind();
            vao.Unbind();
            vab.Unbind();

            spriteRenderer     = new SpriteRenderer();
            defaultFramebuffer = Framebuffer.GetDefault();
            spriteDisplayList  = new DynamicDisplayList <VertexPositionColorTexture>(VertexPositionColorTexture.Size);
            resourceSet        = new TextureResourceSet(window);
        }