Beispiel #1
0
        private static void Render(Mesh mesh)
        {
            using (GraphicsWindow window = Device.CreateWindow(1, 1))
                using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context))
                    using (ShaderProgram sp = Device.CreateShaderProgram(ShaderSources.PassThroughVertexShader(), ShaderSources.PassThroughFragmentShader()))
                        using (VertexArray va = window.Context.CreateVertexArray(mesh, sp.VertexAttributes, BufferHint.StaticDraw))
                        {
                            window.Context.Framebuffer = framebuffer;
                            window.Context.Clear(new ClearState());
                            window.Context.Draw(PrimitiveType.Triangles, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState());

                            TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 0, 0);
                        }
        }
Beispiel #2
0
        public void CreateTexturesParallel()
        {
            using (var thread0Window = Device.CreateWindow(1, 1))
                using (var thread1Window = Device.CreateWindow(1, 1))
                    using (var window = Device.CreateWindow(1, 1))
                    {
                        TextureFactory factory0 = new TextureFactory(thread0Window.Context, new BlittableRGBA(Color.FromArgb(0, 255, 0, 0)));
                        TextureFactory factory1 = new TextureFactory(thread1Window.Context, new BlittableRGBA(Color.FromArgb(0, 0, 255, 0)));

                        Thread t0 = new Thread(factory0.Create);
                        Thread t1 = new Thread(factory1.Create);

                        t0.Start();
                        t1.Start();

                        t0.Join();
                        t1.Join();

                        ///////////////////////////////////////////////////////////////////

                        TestUtility.ValidateColor(factory0.Texture, 255, 0, 0);
                        TestUtility.ValidateColor(factory1.Texture, 0, 255, 0);

                        using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context))
                            using (ShaderProgram sp = Device.CreateShaderProgram(ShaderSources.PassThroughVertexShader(), ShaderSources.MultitextureFragmentShader()))
                                using (VertexArray va = TestUtility.CreateVertexArray(window.Context, sp.VertexAttributes["position"].Location))
                                {
                                    window.Context.TextureUnits[0].Texture        = factory0.Texture;
                                    window.Context.TextureUnits[0].TextureSampler = Device.TextureSamplers.NearestClamp;
                                    window.Context.TextureUnits[1].Texture        = factory1.Texture;
                                    window.Context.TextureUnits[1].TextureSampler = Device.TextureSamplers.NearestClamp;
                                    window.Context.Framebuffer = framebuffer;
                                    window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState());

                                    TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 255, 0);
                                }
                    }
        }
Beispiel #3
0
 public void Reset()
 {
     ShaderSources.Clear();
     StreamInitializers.Clear();
     Streams.Clear();
 }
        public void CreateShaderProgramParallel()
        {
            using (var thread0Window = Device.CreateWindow(1, 1))
                using (var thread1Window = Device.CreateWindow(1, 1))
                    using (var window = Device.CreateWindow(1, 1))
                        using (ShaderProgramFactory factory0 = new ShaderProgramFactory(thread0Window.Context, ShaderSources.PassThroughVertexShader(), ShaderSources.PassThroughFragmentShader()))
                            using (ShaderProgramFactory factory1 = new ShaderProgramFactory(thread1Window.Context, ShaderSources.PassThroughVertexShader(), ShaderSources.PassThroughFragmentShader()))
                            {
                                Thread t0 = new Thread(factory0.Create);
                                t0.Start();

                                Thread t1 = new Thread(factory1.Create);
                                t1.Start();

                                t0.Join();
                                t1.Join();

                                using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context))
                                    using (VertexArray va = TestUtility.CreateVertexArray(window.Context, factory0.ShaderProgram.VertexAttributes["position"].Location))
                                    {
                                        window.Context.Framebuffer = framebuffer;
                                        window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), factory0.ShaderProgram, va), new SceneState());
                                        TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 0, 0);

                                        window.Context.Clear(new ClearState());
                                        window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), factory1.ShaderProgram, va), new SceneState());
                                        TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 0, 0);
                                    }
                            }
        }