public RenderTexture(int width, int height)
 {
     view          = new View(new Viewport(0, height, width, 0), new Vector2(0, 0), new Vector2(width, height));
     depthBuffer   = new DepthBuffer(width, height);
     framebuffer   = new Framebuffer();
     deviceTexture = new DeviceTexture(DefaultShader.DEFFAULT_TEXTURE_UNIFORM_NAME, width, height, false);
     deviceTexture.Bind();
     framebuffer.Bind();
     deviceTexture.CopyRawData(IntPtr.Zero, 0);
     framebuffer.AttachDepthBuffer(depthBuffer);
     framebuffer.AttachTexture(deviceTexture);
     deviceTexture.Unbind();
     framebuffer.Use();
     framebuffer.Check();
     texture = Texture.FromDeviceTexture(deviceTexture);
     framebuffer.Unbind();
 }
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);
        }
Beispiel #3
0
 public void Set(ShaderPipeline pipeline)
 {
     deviceTexture.Bind();
     deviceTexture.Set(pipeline);
     deviceTexture.Unbind();
 }
Beispiel #4
0
 protected Texture(int width, int height, byte[] data, bool repeated = false)
 {
     deviceTexture = new DeviceTexture(DefaultShader.DEFFAULT_TEXTURE_UNIFORM_NAME, width, height, true, repeated);
     deviceTexture.Bind();
     deviceTexture.CopyData(data);
 }