コード例 #1
0
 public RendererOpenGL()
 {
     TextPath     = new gsv_text();
     StrockedText = new conv_stroke(TextPath);
     int[] bounds = new int[4];
     Gl.glGetIntegerv(Gl.GL_VIEWPORT, bounds);
 }
コード例 #2
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

#if SourceDepthFloat
            ImageClippingProxyFloat clippingProxy = new ImageClippingProxyFloat(graphics2D.DestImageFloat);

            clippingProxy.clear(new RGBA_Floats(1.0, 1.0, 1.0));
            clippingProxy.CopyFrom(m_TempDestImage, new RectangleInt(0, 0, (int)Width, (int)Height), 110, 35);
#else
            ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage);

            clippingProxy.clear(new ColorF(1.0, 1.0, 1.0));
            clippingProxy.CopyFrom(m_TempDestImage, new RectangleInt(0, 0, (int)Width, (int)Height), 110, 35);
#endif

            string   buf = string.Format("NSteps={0:F0}", m_num_steps);
            gsv_text t   = new gsv_text();
            t.start_point(200.0, 430);
            t.SetFontSize(10.0);
            t.text(buf);

            Stroke pt = new Stroke(t);
            pt.Width = 1.5;

            m_Rasterizer.add_path(pt);
#if SourceDepthFloat
            RGBA_Floats colorBlack = new RGBA_Floats(0, 0, 0);
#else
            Color colorBlack = new Color(0, 0, 0);
#endif
            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
            scanlineRenderer.RenderSolid(clippingProxy, m_Rasterizer, m_ScanlinePacked, colorBlack);

            if (m_time1 != m_time2 && m_num_pix > 0.0)
            {
                buf = string.Format("{0:F2} Kpix/sec", m_num_pix / (m_time2 - m_time1));
                t.start_point(200.0, 450);
                t.text(buf);
                m_Rasterizer.add_path(pt);
                scanlineRenderer.RenderSolid(clippingProxy, m_Rasterizer, m_ScanlinePacked, colorBlack);
            }

            if (filterSelectionButtons.SelectedIndex >= 14)
            {
                m_radius.Visible = true;
            }
            else
            {
                m_radius.Visible = true;
            }

            base.OnDraw(graphics2D);
        }
コード例 #3
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            if (!didInit)
            {
                didInit = true;
                OnInitialize();
            }

            if (m_gamma.Value != m_old_gamma)
            {
                m_gamma_lut.SetGamma(m_gamma.Value);
                ImageIO.LoadImageData("spheres.bmp", m_SourceImage);
                //m_SourceImage.apply_gamma_dir(m_gamma_lut);
                m_old_gamma = m_gamma.Value;
            }

            ImageBuffer pixf = new ImageBuffer();

            switch (widgetsSubImage.BitDepth)
            {
            case 24:
                pixf.Attach(widgetsSubImage, new BlenderBGR());
                break;

            case 32:
                pixf.Attach(widgetsSubImage, new BlenderBGRA());
                break;

            default:
                throw new NotImplementedException();
            }

            ImageClippingProxy clippingProxy = new ImageClippingProxy(pixf);

            clippingProxy.clear(new ColorF(1, 1, 1));

            if (m_trans_type.SelectedIndex < 2)
            {
                // For the affine parallelogram transformations we
                // calculate the 4-th (implicit) point of the parallelogram
                m_quad.SetXN(3, m_quad.GetXN(0) + (m_quad.GetXN(2) - m_quad.GetXN(1)));
                m_quad.SetYN(3, m_quad.GetYN(0) + (m_quad.GetYN(2) - m_quad.GetYN(1)));
            }

            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
            // draw a background to show how the alpha is working
            int RectWidth = 70;
            int xoffset   = 50;
            int yoffset   = 50;

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if ((i + j) % 2 != 0)
                    {
                        VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset,
                                                                                     (i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2);
                        rect.normalize_radius();

                        g_rasterizer.add_path(rect);
                        scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new Color(.2, .2, .2));
                    }
                }
            }

            //--------------------------
            // Render the "quad" tool and controls
            g_rasterizer.add_path(m_quad);
            scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new Color(0, 0.3, 0.5, 0.1));

            // Prepare the polygon to rasterize. Here we need to fill
            // the destination (transformed) polygon.
            g_rasterizer.SetVectorClipBox(0, 0, Width, Height);
            g_rasterizer.reset();
            int b = 0;

            g_rasterizer.move_to_d(m_quad.GetXN(0) - b, m_quad.GetYN(0) - b);
            g_rasterizer.line_to_d(m_quad.GetXN(1) + b, m_quad.GetYN(1) - b);
            g_rasterizer.line_to_d(m_quad.GetXN(2) + b, m_quad.GetYN(2) + b);
            g_rasterizer.line_to_d(m_quad.GetXN(3) - b, m_quad.GetYN(3) + b);

            //typedef agg::span_allocator<color_type> span_alloc_type;
            span_allocator         sa            = new span_allocator();
            image_filter_bilinear  filter_kernel = new image_filter_bilinear();
            ImageFilterLookUpTable filter        = new ImageFilterLookUpTable(filter_kernel, true);

            ImageBufferAccessorClamp source = new ImageBufferAccessorClamp(m_SourceImage);

            stopwatch.Restart();

            switch (m_trans_type.SelectedIndex)
            {
            case 0:
            {
                /*
                 *              agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *
                 *              typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
                 *              interpolator_type interpolator(tr);
                 *
                 *              typedef image_filter_2x2_type<source_type,
                 *                                                                        interpolator_type> span_gen_type;
                 *              span_gen_type sg(source, interpolator, filter);
                 *              agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 */
                break;
            }

            case 1:
            {
                /*
                 *              agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *
                 *              typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
                 *              typedef image_resample_affine_type<source_type> span_gen_type;
                 *
                 *              interpolator_type interpolator(tr);
                 *              span_gen_type sg(source, interpolator, filter);
                 *              sg.blur(m_blur.Value);
                 *              agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 */
                break;
            }

            case 2:
            {
                /*
                 *              agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              if(tr.is_valid())
                 *              {
                 *                      typedef agg::span_interpolator_linear_subdiv<agg::trans_perspective> interpolator_type;
                 *                      interpolator_type interpolator(tr);
                 *
                 *                      typedef image_filter_2x2_type<source_type,
                 *                                                                                interpolator_type> span_gen_type;
                 *                      span_gen_type sg(source, interpolator, filter);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }

            case 3:
            {
                /*
                 *              agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              if(tr.is_valid())
                 *              {
                 *                      typedef agg::span_interpolator_trans<agg::trans_perspective> interpolator_type;
                 *                      interpolator_type interpolator(tr);
                 *
                 *                      typedef image_filter_2x2_type<source_type,
                 *                                                                                interpolator_type> span_gen_type;
                 *                      span_gen_type sg(source, interpolator, filter);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }

            case 4:
            {
                //typedef agg::span_interpolator_persp_lerp<> interpolator_type;
                //typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type;

                span_interpolator_persp_lerp interpolator   = new span_interpolator_persp_lerp(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                span_subdiv_adaptor          subdiv_adaptor = new span_subdiv_adaptor(interpolator);

                span_image_resample sg = null;
                if (interpolator.is_valid())
                {
                    switch (source.SourceImage.BitDepth)
                    {
                    case 24:
                        sg = new span_image_resample_rgb(source, subdiv_adaptor, filter);
                        break;

                    case 32:
                        sg = new span_image_resample_rgba(source, subdiv_adaptor, filter);
                        break;
                    }

                    sg.blur(m_blur.Value);
                    scanlineRenderer.GenerateAndRender(g_rasterizer, g_scanline, clippingProxy, sa, sg);
                }
                break;
            }

            case 5:
            {
                /*
                 *              typedef agg::span_interpolator_persp_exact<> interpolator_type;
                 *              typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type;
                 *
                 *              interpolator_type interpolator(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);
                 *              subdiv_adaptor_type subdiv_adaptor(interpolator);
                 *
                 *              if(interpolator.is_valid())
                 *              {
                 *                      typedef image_resample_type<source_type,
                 *                                                                              subdiv_adaptor_type> span_gen_type;
                 *                      span_gen_type sg(source, subdiv_adaptor, filter);
                 *                      sg.blur(m_blur.Value);
                 *                      agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg);
                 *              }
                 */
                break;
            }
            }

            double tm = stopwatch.ElapsedMilliseconds;
            //pixf.apply_gamma_inv(m_gamma_lut);

            gsv_text t = new gsv_text();

            t.SetFontSize(10.0);

            Stroke pt = new Stroke(t);

            pt.Width = 1.5;

            string buf = string.Format("{0:F2} ms", tm);

            t.start_point(10.0, 70.0);
            t.text(buf);

            g_rasterizer.add_path(pt);
            scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new Color(0, 0, 0));

            //--------------------------
            //m_trans_type.Render(g_rasterizer, g_scanline, clippingProxy);
            //m_gamma.Render(g_rasterizer, g_scanline, clippingProxy);
            //m_blur.Render(g_rasterizer, g_scanline, clippingProxy);
            base.OnDraw(graphics2D);
        }
コード例 #4
0
 public RendererOpenGL()
 {
     TextPath = new gsv_text();
     StrockedText = new conv_stroke(TextPath);
     int[] bounds = new int[4];
     Gl.glGetIntegerv(Gl.GL_VIEWPORT, bounds);
 }
コード例 #5
0
 public RendererOpenGL(IPixelFormat PixelFormat, rasterizer_scanline_aa Rasterizer)
     : base(PixelFormat, Rasterizer)
 {
     TextPath = new gsv_text();
     StrockedText = new conv_stroke(TextPath);
 }
コード例 #6
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            IImageByte backBuffer = widgetsSubImage;

            IImageByte         destImage     = backBuffer;
            ImageClippingProxy clippingProxy = new ImageClippingProxy(destImage);

            clippingProxy.clear(new RGBA_Floats(0, 0, 0));

            ScanlineRasterizer  ras    = new ScanlineRasterizer();
            scanline_unpacked_8 sl     = new scanline_unpacked_8();
            scanline_bin        sl_bin = new scanline_bin();

            rasterizer_compound_aa rasc  = new rasterizer_compound_aa();
            span_allocator         alloc = new span_allocator();

            int            i;
            styles_gouraud styles = new styles_gouraud(m_mesh, m_gamma);

            stopwatch.Restart();
            rasc.reset();
            //rasc.clip_box(40, 40, width() - 40, height() - 40);
            for (i = 0; i < m_mesh.num_edges(); i++)
            {
                mesh_edge  e  = m_mesh.edge(i);
                mesh_point p1 = m_mesh.vertex(e.p1);
                mesh_point p2 = m_mesh.vertex(e.p2);
                rasc.styles(e.tl, e.tr);
                rasc.move_to_d(p1.x, p1.y);
                rasc.line_to_d(p2.x, p2.y);
            }

            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();

            scanlineRenderer.RenderCompound(rasc, sl, sl_bin, clippingProxy, alloc, styles);
            double tm = stopwatch.ElapsedMilliseconds;

            gsv_text t = new gsv_text();

            t.SetFontSize(10.0);

            Stroke pt = new Stroke(t);

            pt.width(1.5);
            pt.line_cap(LineCap.Round);
            pt.line_join(LineJoin.Round);

            string buf = string.Format("{0:F2} ms, {1} triangles, {2:F0} tri/sec",
                                       tm,
                                       m_mesh.num_triangles(),
                                       m_mesh.num_triangles() / tm * 1000.0);

            t.start_point(10.0, 10.0);
            t.text(buf);

            ras.add_path(pt);
            scanlineRenderer.RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(255, 255, 255));

            if (m_gamma.GetGamma() != 1.0)
            {
                ((ImageBuffer)destImage).apply_gamma_inv(m_gamma);
            }

            base.OnDraw(graphics2D);
        }
コード例 #7
0
ファイル: RenderBase.cs プロジェクト: Wiladams/NewTOAPIA
 public RendererBase()
 {
     TextPath = new gsv_text();
     StrockedText = new conv_stroke(TextPath);
     m_AffineTransformStack.Push(Affine.NewIdentity());
 }
コード例 #8
0
 public RendererOpenGL(IPixelFormat PixelFormat, rasterizer_scanline_aa Rasterizer)
     : base(PixelFormat, Rasterizer)
 {
     TextPath     = new gsv_text();
     StrockedText = new conv_stroke(TextPath);
 }