Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

c++ - graphics library

Hi,

I have to generate few lines, circles and rectangles and connect them by lines. Please suggest me any graphics library that I can use with VC++ 2012.

I checked SDL and it looks very complicated to draw even a single line. Please  suggest me any library that I can use for my work or which is easy to use.

Thanks
0
josephm67
Asked:
josephm67
  • 2
  • 2
3 Solutions
 
Pasha KravtsovCommented:
There probably (guaranteed) won't be any libraries that are just 'easy' to use for C++. I recommend starting to learn DirectX8/9/10/11 or OpenGL
http://www.directxtutorial.com/LessonList.aspx?listid=9

Have fun and good luck.
0
 
jkrCommented:
For this task you can just go with GDI+ which comes with VC++ (OpenGL and DirectX are overkill here, with all due respect). See the technical dos and reference at http://msdn.microsoft.com/en-us/library/windows/desktop/ms533798%28v=vs.85%29.aspx ("GDI+") and a tutorial at http://www.codeproject.com/Articles/1112/Starting-with-GDI ("Starting with GDI+"). Drawinf a rectangle then can be as simple as

CPaintDC dc(this); // Creates a device context for the client area, which
                   // also erases the area to be drawn.

CPen MyPen, * pOldPen;
CBrush MyBrush, * pOldBrush;
// A red pen, one pixel wide
MyPen.Create(1, PS_SOLID, RGB(255,0,0));

// Selecting an object returns the old one
// we need to catch and return it to avoid memory leaks
pOldPen = dc.SelectObject(&MyPen);       
                                          
// A Blue brush                                         
MyBrush.CreateSolidBrush(RGB(0, 0, 255)); 
pOldBrush = dc.SelectObject(&MyBrush);

// Finally, we have our device context set up with our pen and brush and can
// use them to draw.
//Draws a rectangle that is red on the outside, filled in blue 
dc.Rectangle(0, 0, 200, 200); 
dc.SelectObject(pOldPen);
dc.SelectObject(pOldBrush);

Open in new window

0
 
Pasha KravtsovCommented:
Dang I totally forgot about GDI+, I might use this too here soon thanks jkr.
0
 
jkrCommented:
Do you have any other questions regarding this issue?
0
 
josephm67Author Commented:
thx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now