private unsafe void ImplSetRenderSurface(RenderSurface surface) { if (vertex_index > 0) { Submit(); } if (surface != null) { current_render_pass++; if (current_render_pass > max_render_pass) { max_render_pass = current_render_pass; } } else { surface = render_surfaces[0]; current_render_pass = 0; } Matrix4x4 projection = surface.Projection; gfx.SetRenderTarget(current_render_pass, surface.RenderTarget); gfx.SetClearColor(current_render_pass, surface != render_surfaces[0] ? Color.Transparent : Color.Black); gfx.SetViewport(current_render_pass, 0, 0, surface.Width, surface.Height); gfx.SetProjection(current_render_pass, &projection.M11); }
private unsafe void ImplDrawSurface(RenderSurface surface, int index) { var vertex_buffer = new TransientVertexBuffer(4, Vertex2DLayout); fixed(void *v = surface.Vertices) { Unsafe.CopyBlock((void *)vertex_buffer.Data, v, (uint)(4 * Vertex2D.Stride)); } var pass = (byte)(max_render_pass + index + 1); gfx.SetViewport(pass, 0, 0, Game.Instance.ScreenSize.W, Game.Instance.ScreenSize.H); var proj = screen_projection; gfx.SetProjection(pass, &proj.M11); //gfx.SetClearColor(pass, Color.Blue); Bgfx.SetTexture(0, current_shader_program.Samplers[0], surface.RenderTarget.NativeTexture, TextureFlags.FilterPoint | TextureFlags.ClampUVW); Bgfx.SetRenderState(render_state); Bgfx.SetIndexBuffer(index_buffer, 0, 6); Bgfx.SetVertexBuffer(0, vertex_buffer, 0, vertex_index); Bgfx.Submit(pass, surface.Shader?.Program ?? current_shader_program.Program); }
public RenderSurface AddSurface(Rect area, string name = "Surface") { var surface = new RenderSurface(area); surface.Name = name; render_surfaces[overlay_surface_idx++] = surface; return(surface); }
public void SetRenderSurface(RenderSurface surface) { ImplSetRenderSurface(surface); }