Solved

c++ - graphics library

Posted on 2014-04-04
5
298 Views
Last Modified: 2014-04-22
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
Comment
Question by:josephm67
  • 2
  • 2
5 Comments
 
LVL 5

Assisted Solution

by:Pasha Kravtsov
Pasha Kravtsov earned 166 total points
Comment Utility
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
 
LVL 86

Accepted Solution

by:
jkr earned 334 total points
Comment Utility
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
 
LVL 5

Expert Comment

by:Pasha Kravtsov
Comment Utility
Dang I totally forgot about GDI+, I might use this too here soon thanks jkr.
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 334 total points
Comment Utility
Do you have any other questions regarding this issue?
0
 

Author Closing Comment

by:josephm67
Comment Utility
thx
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now