CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    Nov 2005
    Posts
    16

    Exclamation 2D rendering engine

    Hello,

    I am looking for a C++ 2d(lines, circles, font, anti aliasing) rendering engine to implement into my project. I am looking for something just like GDI+, but not GDI+. GDI+ seems way too low for what I need. It would be nice if it is free, and implementation into my current Win32 C++ project is easy. I would like to thank you very much in advance.


    Sincerely,
    Tiberiu Brasov

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: 2D rendering engine

    [ moved thread ]
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: 2D rendering engine

    Check out AntiGrain Geometry Library.
    Quote Originally Posted by AntiGrain
    Anti-Grain Geometry (AGG) is an Open Source, free of charge graphic library, written in industrially standard C++. AGG doesn't depend on any graphic API or technology. Basically, you can think of AGG as of a rendering engine that produces pixel images in memory from some vectorial data. But of course, AGG can do much more than that. The ideas and the philosophy of AGG are:
    • Anti-Aliasing.
    • Subpixel Accuracy.
    • The highest possible quality.
    • High performance.
    • Platform independence and compatibility.
    • Flexibility and extensibility.
    • Lightweight design.
    • Reliability and stability (including numerical stability).
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  4. #4
    Join Date
    Dec 2005
    Posts
    9

    Re: 2D rendering engine

    hmmm... check out Allegro (http://alleg.sourceforge.net i think).

  5. #5
    Join Date
    Nov 2005
    Posts
    16

    Re: 2D rendering engine

    Hello guys,


    thank you very much for your help. Anti Grain looks very good! I am really interested in implementing this into my Win32 API app. The only problem is that I tried, and I get linking errors, specifically a Win32 error. Do you guys know if there is a tutorial to implement Anti Grain in my current Win32 project? pretty much to draw on the HDC.

    Thank you very much in advance.

    Sincerely,
    Tiberiu

  6. #6
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: 2D rendering engine

    Can you post some code?
    The AntiGrain library works on the principle of simply including the correct headers and source files into your own project and that's it.

    So you probably forget to include the correct .cpp files into your project for a feature you are using.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  7. #7
    Join Date
    Nov 2005
    Posts
    16

    Re: 2D rendering engine

    Marc,

    I am looking at creating the simplest Win32 APP that draws a simple 2d shape(line). I have tried making my own, but I have no clue as to setting up the headers/cpp files and what functions to call in order to draw on the HDC.

    Tiberiu

  8. #8
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: 2D rendering engine

    The AntiGrain library is very powerful, but unfortunately the documentation is rather small. I use AGG myself but by far don't know everything of it.

    I would start by reading and playing with the example code.

    Basically, you should create your pixel buffer, attach it to an AGG rendering buffer, draw on it with AGG and at the end blit the pixels to the HDC. Something like:
    Code:
    int iWidth = 640;
    int iHeight = 480;
    
    // Create our bitmap
    BITMAPINFO binf = {0};
    binf.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    binf.bmiHeader.biWidth = iWidth;
    binf.bmiHeader.biHeight = -iHeight;
    binf.bmiHeader.biPlanes = 1;
    binf.bmiHeader.biBitCount = 32;
    binf.bmiHeader.biCompression = BI_RGB;
    binf.bmiHeader.biSizeImage = 0;
    void* pBmpBits = NULL;  // Will be freed by DeleteObject(hBmp)
    HBITMAP hBmp = CreateDIBSection(NULL, &binf, DIB_RGB_COLORS, &pBmpBits, NULL, NULL);
    if (!hBmp)
    {
      AfxMessageBox(_T("Error while create DIBSection in " __FUNCTION__ "."), MB_ICONWARNING);
      return;
    }
    
    // Attach it to an agg rendering buffer
    agg::rendering_buffer aggbuf((unsigned char*)pBmpBits, iWidth, iHeight, iWidth * 4);
    
    // Start drawing on the aggbuf, see other agg examples
    ...
    
    // Blit the hBmp to your target HDC
    ...
    
    // Cleanup the bitmap
    DeleteObject(hBmp);
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  9. #9
    Join Date
    Nov 2005
    Posts
    162

    Re: 2D rendering engine

    For high quality 2d drawing engine,I think you should try XD++,it draws the GDI+ with GDI method,and works very fast,can be found with:
    http://www.********.net/index.htm

    Hope it is useful to you.

    Cindy

  10. #10
    Join Date
    Nov 2005
    Posts
    16

    Re: 2D rendering engine

    Hello,

    Thanks fot your help. I have been looking around the code, but I can't find an example of using primitive shapes like lines, rectangles, ellipses, arcs, etc. I found the regular ones, but I want to anti alias them. I think that Anti Grain calls it differently, but I want to use Anti-Aliasing on the shapes.

    Also, how would I rotate them? In GDI+ there is RotateTransform. Is there such a thing here?

    Thanks,
    Tiberiu

  11. #11
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: 2D rendering engine

    There are quite some example at http://www.antigrain.com/demo/index.html
    Also, if you want to get more information or have question about AntiGrain, I think you should subscribe to their mailinglist.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  12. #12
    Join Date
    Jan 2006
    Posts
    13

    Re: 2D rendering engine

    I have looked carefully at Anti-Grain Geometry. It looks very interesting, but I regret I couldn't find a VERY simple example that would just draw a line...

    Did some of you have the opportunity to test the AGG performance? Is it faster or slower than GDI+?
    In addition, I couldn't find any clipping function, do you know if they exist?

    Thanks for any help !!
    Rocky

  13. #13
    Join Date
    Nov 2005
    Posts
    16

    Re: 2D rendering engine

    Quote Originally Posted by Marc G
    There are quite some example at http://www.antigrain.com/demo/index.html
    Also, if you want to get more information or have question about AntiGrain, I think you should subscribe to their mailinglist.

    Marc,

    I looked at the examples. What I am trying to achieve ins't there. I got as far as drawling a line and an ellipse, but I have no clue as to choosing between a filled ellipse and just its outline. This is what I have so far:

    renb.clear(agg::rgba8(255, 255, 255));

    rasterizer_scanline_aa<> rasterizer;
    scanline_p8 sl;
    path_storage path;
    path.move_to(0, 0);
    path.line_to(150, 0);

    trans_affine mtx;
    mtx *= trans_affine_rotation(airspeed * PI / 180);
    mtx *= trans_affine_translation(100.0, 100.0);
    ellipse ell(50, 50, 100, 50);

    conv_transform<path_storage> trans(path, mtx);
    conv_transform<ellipse> transs(ell, mtx);


    conv_stroke<conv_transform<path_storage> >stroke(trans);

    conv_stroke<conv_transform<ellipse> >strokes(transs);

    ren.color(rgba8(255, 0, 0));
    rasterizer.add_path(stroke);

    rasterizer.add_path(strokes);
    render_scanlines(rasterizer, sl, ren);



    How would I draw an anti aliased the rectangle the same way?


    Tiberiu

  14. #14
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: 2D rendering engine

    The learning curve for AGG is indeed pretty steep
    The following piece of code will draw a blue line and an ellipse with solid blue color and 5 pixel width yellow outline.
    Code:
      // Set color
      ren.color(rgba8(255, 0, 0));
      // Add line
      rasterizer.add_path(stroke);
      // Add solid ellipse
      rasterizer.add_path(transs);
      render_scanlines(rasterizer, sl, ren);
    
      rasterizer.reset();
      // Set color
      ren.color(rgba8(0, 255, 255));
      // ellipse outline -> stroke the ellipse with a outline of 5 pixels
      strokes.width(5);
      rasterizer.add_path(strokes);
      render_scanlines(rasterizer, sl, ren);
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  15. #15
    Join Date
    Jan 2006
    Posts
    13

    Re: 2D rendering engine

    tiberiu11, may I ask you what you are trying to do with AGG?
    I mean, what use you plan to make?

    The last post you wrote makes me believe we're trying to do something similar ;-)

    Rocky

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured