public virtual void OnDraw() { for (int i = 0; i < m_Children.Count; i++) { GUIWidget <T> child = m_Children[i]; if (child.Visible) { GetRenderer().PushTransform(); //Affine transform = GetRenderer().GetTransform(); //transform *= child.GetTransform(); IAffineTransformMatrix <T> transform = GetRenderer().GetTransform(); transform = MatrixFactory <T> .CreateAffine(transform.Multiply(child.GetTransform())); //transform *= child.GetTransform(); GetRenderer().SetTransform(transform); child.OnDraw(); #if false if (Focused) { RoundedRect rect = new RoundedRect(-5, -5, 5, 5, 0); GetRenderer().Render(rect, new RGBA_Bytes(1.0, 0, 0, .5)); } #endif GetRenderer().PopTransform(); } } }
public static void glBegin(int mode) { //m_CurAccumulatedMatrix.Multiply(m_ModelviewMatrix, m_ProjectionMatrix); m_CurAccumulatedMatrix = (IAffineTransformMatrix <T>)m_CurAccumulatedMatrix.Multiply(m_ModelviewMatrix); m_CurAccumulatedMatrix = (IAffineTransformMatrix <T>)m_CurAccumulatedMatrix.Multiply(m_ProjectionMatrix); switch (mode) { case GL_TRIANGLES: s_BeginMode = GL_TRIANGLES; break; case GL_QUADS: s_BeginMode = GL_QUADS; break; default: throw new System.NotImplementedException(); } }
public override void OnDraw() { //typedef agg::renderer_base<pixfmt> renderer_base; //typedef agg::renderer_base<pixfmt_pre> renderer_base_pre; #if SourceDepth24 pixfmt_alpha_blend_rgb pixf = new pixfmt_alpha_blend_rgb(rbuf_window(), new blender_bgr()); pixfmt_alpha_blend_rgb pixf_pre = new pixfmt_alpha_blend_rgb(rbuf_window(), new blender_bgr_pre()); #else FormatRGBA pixf = new FormatRGBA(rbuf_window(), new BlenderBGRA()); FormatRGBA pixf_pre = new FormatRGBA(rbuf_window(), new BlenderPreMultBGRA()); #endif FormatClippingProxy clippingProxy = new FormatClippingProxy(pixf); FormatClippingProxy clippingProxy_pre = new FormatClippingProxy(pixf_pre); clippingProxy.Clear(new RGBA_Doubles(1.0, 1.0, 1.0)); IAffineTransformMatrix <T> src_mtx = MatrixFactory <T> .NewIdentity(VectorDimension.Two); src_mtx.Translate(MatrixFactory <T> .CreateVector2D(initial_width().Negative().Divide(2).Subtract(10), initial_height().Negative().Divide(2).Subtract(30))); src_mtx.RotateAlong(MatrixFactory <T> .CreateVector2D(0, 0), m_angle.value().Multiply(Math.PI / 180.0).ToDouble()); src_mtx.Scale(m_scale.value()); src_mtx.Translate(MatrixFactory <T> .CreateVector2D(initial_width().Divide(2), initial_height().Divide(2).Add(20))); src_mtx.Multiply(trans_affine_resizing()); IAffineTransformMatrix <T> img_mtx = MatrixFactory <T> .NewIdentity(VectorDimension.Two); img_mtx.Translate(MatrixFactory <T> .CreateVector2D(initial_width().Negative().Divide(2).Add(10), initial_height().Negative().Divide(2).Add(30))); img_mtx.RotateAlong(MatrixFactory <T> .CreateVector2D(0, 0), m_angle.value().Multiply(Math.PI / 180.0).ToDouble()); img_mtx.Scale(m_scale.value()); img_mtx.Translate(MatrixFactory <T> .CreateVector2D(initial_width().Divide(2), initial_height().Divide(2).Add(20))); img_mtx.Multiply(trans_affine_resizing()); img_mtx = img_mtx.Inverse; AGG.SpanAllocator sa = new SpanAllocator(); SpanInterpolatorLinear <T> interpolator = new SpanInterpolatorLinear <T>(img_mtx); #if SourceDepth24 pixfmt_alpha_blend_rgb img_pixf = new pixfmt_alpha_blend_rgb(rbuf_img(0), new blender_bgr()); #else FormatRGBA img_pixf = new FormatRGBA(rbuf_img(0), new BlenderBGRA()); #endif #if SourceDepth24 span_image_filter_rgb_bilinear_clip sg; sg = new span_image_filter_rgb_bilinear_clip(img_pixf, rgba.rgba_pre(0, 0.4, 0, 0.5), interpolator); #else SpanImageFilterRgbaBilinearClip <T> sg; RasterBufferAccessorClip source = new RasterBufferAccessorClip(img_pixf, RGBA_Doubles.RgbaPre(0, 0, 0, 0)); sg = new SpanImageFilterRgbaBilinearClip <T>(source, RGBA_Doubles.RgbaPre(0, 0.4, 0, 0.5), interpolator); #endif RasterizerScanlineAA <T> ras = new RasterizerScanlineAA <T>(); ras.SetVectorClipBox(M.Zero <T>(), M.Zero <T>(), width(), height()); //agg.scanline_packed_8 sl = new scanline_packed_8(); ScanlineUnpacked8 sl = new ScanlineUnpacked8(); T r = initial_width(); if (initial_height().Subtract(60).LessThan(r)) { r = initial_height().Subtract(60); } Ellipse <T> ell = new Ellipse <T>(initial_width().Divide(2.0).Add(10), initial_height().Divide(2.0).Add(30), r.Divide(2.0).Add(16.0), r.Divide(2.0).Add(16.0), 200); ConvTransform <T> tr = new ConvTransform <T>(ell, src_mtx); ras.AddPath(tr); #if use_timers for (uint j = 0; j < 10; j++) { Renderer.GenerateAndRender(ras, sl, clippingProxy_pre, sa, sg); } AllTimer.Start(); image1_100_Times.Start(); for (uint i = 0; i < 500; i++) { #endif //clippingProxy_pre.SetClippingBox(30, 0, (int)width(), (int)height()); //clippingProxy.SetClippingBox(30, 0, (int)width(), (int)height()); Renderer <T> .GenerateAndRender(ras, sl, clippingProxy_pre, sa, sg); #if use_timers } image1_100_Times.Stop(); #endif //m_angle.SetTransform(trans_affine_resizing()); //m_scale.SetTransform(trans_affine_resizing()); #if use_timers AllTimer.Stop(); CExecutionTimer.Instance.AppendResultsToFile("TimingTest.txt", AllTimer.GetTotalSeconds()); CExecutionTimer.Instance.Reset(); #endif base.OnDraw(); }