protected override void OnLoad(EventArgs e) { GL.ClearColor(.1f, .1f, .1f, 1.0f); GL.Enable(EnableCap.DepthTest); // ################################## Shader Setup this._shader = new Shader(ResourcePath + "Shaders\\shader.vert", ResourcePath + "Shaders\\shader.frag"); this._postProcessingShaderNoEffect = new PostProcessingShader(ResourcePath + "Shaders\\postprocessNoEffect.vert", ResourcePath + "Shaders\\postprocessNoEffect.frag"); this._postProcessingShader = new PostProcessingShader(ResourcePath + "Shaders\\postprocess.vert", ResourcePath + "Shaders\\postprocess.frag"); this._shader.Use(); // ################################## Font Setup FontManager.LoadFonts(ResourcePath + "Fonts"); this.ka1 = new Font(FontManager.GetFontFamilyByName("Karmatic Arcade"), 24); renderer = new TextRenderer(Width, Height); this.renderer.Clear(Color.Transparent); // ################################## Screen Setup this.Buffer = FrameBuffer.Create(new Size(this.Width, this.Height)); this._camera = new Camera(Vector3.UnitZ * 3, this.Width / (float)this.Height) { zFar = 1000f }; // ################################## Scene Setup //this._mainBuffer = new ArrayBuffer( ref this._vertices, ref this._indices ); //this._mainBuffer.ShaderSetup( ref this._shader, new[] { ( "aPosition", 3 ), ( "aTexCoord", 2 ) } ); //this._mainBuffer.TextureSetupSetup( new[] { ResourcePath + "Resources\\container.png", ResourcePath + "Resources\\awesomeface.png" } ); //Random r = new Random(); // //for ( int i = 0; i < this._objectBuffers.Length; i++ ) { // this._objectBuffers[i] = new ArrayBuffer( ref this._vertices, ref this._indices ); // this._objectBuffers[i].TransformationsMatrix *= Matrix4.CreateTranslation( r.Next( 0, 20 ), r.Next( 0, 20 ), r.Next( 0, 20 ) ); // this._objectBuffers[i].ShaderSetup( ref this._shader, new[] { ( "aPosition", 3 ), ( "aTexCoord", 2 ) } ); // this._objectBuffers[i].TextureSetupSetup( new[] { ResourcePath + "Resources\\container.png", ResourcePath + "Resources\\awesomeface.png" } ); //} var bf = new BinaryFormatter(); var fs = File.Open(@"C:\Users\admin\Desktop\untitled.bmf", FileMode.Open); SceneData sd = (SceneData)bf.Deserialize(fs); fs.Close(); List <ArrayBuffer> buffers = new List <ArrayBuffer>(); foreach (var bufferInfo in sd.Meshes1) { var vt = bufferInfo.Data; var id = bufferInfo.Indices; ArrayBuffer buf = new ArrayBuffer(ref vt, ref id); buf.TransformationsMatrix = sd.TransFormMatrix; buf.ShaderSetup(ref this._shader, new[] { ("aPosition", 3), ("aTexCoord", 2) });
// aplicar efeitos de acordo com os estados ativos public void Render(float time) { PostProcessingShader.Use(); PostProcessingShader.SetFloat("time", time); PostProcessingShader.SetInteger("chaos", Chaos ? 1 : 0); PostProcessingShader.SetInteger("confuse", Confuse ? 1 : 0); PostProcessingShader.SetInteger("shake", Shake ? 1 : 0); GL.ActiveTexture(TextureUnit.Texture0); Texture.Bind(); GL.BindVertexArray(VAO); GL.DrawArrays(PrimitiveType.Triangles, 0, 6); GL.BindVertexArray(0); }