|
-
December 28th, 2005, 01:33 PM
#1
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
-
December 29th, 2005, 03:49 AM
#2
-
December 29th, 2005, 03:51 AM
#3
Re: 2D rendering engine
Check out AntiGrain Geometry Library.
 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).
-
December 29th, 2005, 08:37 AM
#4
Re: 2D rendering engine
hmmm... check out Allegro (http://alleg.sourceforge.net i think).
-
December 29th, 2005, 10:12 AM
#5
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
-
December 30th, 2005, 03:07 AM
#6
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.
-
December 30th, 2005, 03:36 PM
#7
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
-
December 31st, 2005, 03:44 AM
#8
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);
-
January 2nd, 2006, 08:28 PM
#9
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
-
January 8th, 2006, 12:49 PM
#10
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
-
January 9th, 2006, 08:31 AM
#11
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.
-
January 11th, 2006, 12:16 PM
#12
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
-
January 11th, 2006, 02:58 PM
#13
Re: 2D rendering engine
 Originally Posted by Marc G
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
-
January 11th, 2006, 03:37 PM
#14
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);
-
January 11th, 2006, 05:34 PM
#15
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|