//ok public void Render_SceneToLayer(Layer layer, bool usecam = true) { core.SetData(); fbo.Use(layer.t); if (usecam) { shader_plain.SetVariable("cam_pos", game.camera.GetXPixels(), game.camera.GetYPixels(), game.camera.GetZoomX(), game.camera.GetZoomY()); } else { shader_plain.SetVariable("cam_pos", 0, 0, 1, 1); } shader_plain.SetVariable("screen_size_half", width / 2, height / 2); GL.Viewport(0, 0, layer.w, layer.h); Shader.Bind(shader_plain); GL.BindTexture(TextureTarget.Texture2D, texture); GL.Clear(ClearBufferMask.ColorBufferBit); core.Render(); fbo.DeUse(); GL.Viewport(0, 0, width, height); }
//ok public void END(Tortoise2d m) { Shader.Bind(null); core.ClearData(); //GL.Flush(); //GL.Finish(); m.SwapBuffers(); }
//ok public void RenderLayer(Layer layer) { core.ClearData(); core.AddSprite(0, 0, width, height); core.SetData(); shader_merge.SetVariable("cam_pos", 1, 1, 1, 1); shader_merge.SetVariable("screen_size_half", width / 2, height / 2); Shader.Bind(shader_merge); GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); BindTexture(layer.t); core.Render(); core.ClearData(); }
//ok public void Render_MergeLayers(Layer[] scene_layer, Layer[] effect_layer) { core.ClearData(); core.AddSprite(0, 0, width, height); core.SetData(); shader_merge.SetVariable("cam_pos", 1, 1, 1, 1); shader_merge.SetVariable("screen_size_half", width / 2, height / 2); Shader.Bind(shader_merge); GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); for (int i = 0; i < scene_layer.Length; i++) { BindTexture(scene_layer[i].t); core.Render(); } core.ClearData(); core.AddSprite(0, 0, width, height); core.SetData(); shader_merge_effect.SetVariable("brightness", 1f); shader_merge_effect.SetVariable("screen_size_half", width / 2, height / 2); shader_merge_effect.SetVariable("cam_pos", 0, 0, 1, 1); Shader.Bind(shader_merge_effect); GL.BlendEquationSeparate(BlendEquationMode.FuncAdd, BlendEquationMode.FuncAdd); GL.BlendFuncSeparate(BlendingFactorSrc.DstColor, BlendingFactorDest.Zero, BlendingFactorSrc.DstAlpha, BlendingFactorDest.Zero); for (int i = 0; i < effect_layer.Length; i++) { BindTexture(effect_layer[i].t); core.Render(); } }