Ejemplo n.º 1
0
        public void Render(ShaderBlob toRender, UniformValues uniforms, Size s)
        {
            Gl.Viewport(0, 0, s.Width, s.Height);
            Gl.Clear(ClearBufferMask.ColorBufferBit);

            // Select the program for drawing
            Gl.UseProgram(toRender.Program.ProgramName);

            Gl.UseProgram(toRender.Program.ProgramName);

            SetUniforms(toRender.Program.UniformLocations, uniforms);

            if (toRender.CreationArguments.Type.UseTexture)
            {
                Gl.BindTexture(TextureTarget.Texture2d, toRender.TextureName);
            }

            // Use the vertex array
            Gl.BindVertexArray(toRender.VertexArray.ArrayName);
            GlErrorLogger.Check();
            // Draw triangle
            if (toRender.CreationArguments.Type.UseIndexing)
            {
                Gl.DrawElements(PrimitiveType.Triangles, toRender.VertexArray.Count, DrawElementsType.UnsignedInt, IntPtr.Zero);
            }
            else
            {
                Gl.DrawArrays(PrimitiveType.Triangles, 0, toRender.VertexArray.Count);
            }
            GlErrorLogger.Check();
        }
Ejemplo n.º 2
0
        public ShaderBlob BuildProgram(ShaderCreationArguments args)
        {
            if (BadShader == null)
            {
                BadShader = BuildProgramInternal(this.badShaderArguments);
            }

            return(BuildProgramInternal(args));
        }
Ejemplo n.º 3
0
        private ShaderBlob LoadNewShaderFromSelection(ShaderBlob currentShader)
        {
            ShaderBlob selectedShader = (ShaderBlob)ShaderSelector.SelectedItem;

            if (currentShader != selectedShader)
            {
                this.StartTime = DateTime.UtcNow;
                ErrorBox.Text  = currentShader.ErrorMessage;
                ErrorBox.Refresh();
            }

            return(selectedShader);
        }
Ejemplo n.º 4
0
        private void LoadInitialShaders()
        {
            StaticLogger.Logger.Debug("Loading Intitial Shaders.");

            watcher.LoadAll();

            foreach (var shaderBlob in ShaderZoo.BuildZoo())
            {
                ShaderBlobs.Add(builder.BuildProgram(shaderBlob));
            }

            StaticLogger.Logger.Debug("Done Loading Initial Shaders.");

            this.CurrentShader = ShaderBlobs.Last();
        }
Ejemplo n.º 5
0
        private void Loop()
        {
            //if (FrameTracker.frameCount % 1000 == 0 && FrameTracker.frameCount != 0)
            //{
            //    StaticLogger.Logger.Debug("Regenerating.");
            //    RegenerateGlControl();
            //}

            if (this.configuration.WorkflowMode == UrielWorkflowMode.EditorMode)
            {
                CreateNewShaderAndSelect();
                this.CurrentShader = LoadNewShaderFromSelection(this.CurrentShader);
            }

            this.FrameTracker.StartFrame();

            double time = (DateTime.UtcNow - StartTime).TotalSeconds;

            if (this.CurrentShader.CreationArguments.Type.Uniforms.Contains(KnownFragmentShaderUniform.CursorPosition) ||
                this.CurrentShader.CreationArguments.Type.Uniforms.Contains(KnownFragmentShaderUniform.CursorMovement))
            {
                UpdateKeys();
            }

            Vertex2f resolution = new Vertex2f(this.Size.Width, this.Size.Height);

            UniformValues uniforms = new UniformValues()
            {
                Resolution     = resolution,
                Time           = time,
                CursorMovement = this.tks.Movement,
                CursorPosition = this.tks.Position
            };

            renderLoop.Render(this.CurrentShader, uniforms, this.RenderControl.Size);

            this.FrameTracker.EndFrame();
            if (this.configuration.WorkflowMode == UrielWorkflowMode.EditorMode)
            {
                StatusStrip_Update(time);
            }
        }
Ejemplo n.º 6
0
        private void ContextCreated(uint multisampleBits)
        {
            GlErrorLogger.Check();
            // Uses multisampling, if available
            if (Gl.CurrentVersion != null && Gl.CurrentVersion.Api == KhronosVersion.ApiGl && multisampleBits > 0)
            {
                Gl.Enable(EnableCap.Multisample);
            }

            if (this.configuration.WorkflowMode == UrielWorkflowMode.EditorMode)
            {
                LoadInitialShaders();
            }
            else
            {
                this.CurrentShader = builder.BuildProgram(ShaderLoader.LoadFromFile(this.configuration.MovieModeShaderFileName));
            }

            StartTime = DateTime.UtcNow;
        }