Archived

This topic is now archived and is closed to further replies.

bozkosko

graphics with C++

Recommended Posts

HI, i am pretty new to programming. I have been following the book: "teach yourself C++." I understand the basic idea of OOP, i have all the loops under my belt, i am familiar with pointers, references, simple classes - all the beginers stuff. Now i would like to try some simple graphics. I just want to be able to draw a rectangle, a circle, a line in C++ just like it was easy back in 80''s with Basic. Tell where to start please. Is DirectX the answer for me? If so where can i get good understanding of it or if you have some good book, please give me the name of it. I want to see some shapes and pixcels on my screen, not just numbers and characters. Where is the begining of graphics with c++?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you want something simple and easy to use, you DON''T want the things you have with VC++. With VC++ is MFC 4(?) (powerful, but requires quite a bit of understanding of the organization) and DirectX3 (fast, but dirty setup code, no simple primatives). Use Allegro if you want something easy, as suggested.

Share this post


Link to post
Share on other sites
You can use the windows API, but that is very confusing and you can end up with some ugly code (I''ve been programming with it for over a year and I''m still hacking with it).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
He said something simple like lines or rectangles using VC++. I would think a sufficiently obvious suggestion would be basic GDI. The simplicity of such tasks is near that of old BASIC code, the caveat being that you must first understand how to setup basic WinMain and WndProc functions, which isn''t particularly hard. Read Petzold or find a tutorial on the web. You can do a few neat graphics tricks with GDI if you''re creative.

Share this post


Link to post
Share on other sites
if you want the easiest route use mfc
file\new create a new workspace mfc appwizzard(exe) type in the project name "myprogram" click ok ,check the single document and click finish
then your workspace will appear in the dialog on your left click on fileview and click on source files and double click on the file "myprogramView" and locate the function OnDraw()
void myprogramView::OnDraw(CDC* pDC)
{
CmyprogramDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
add this line of code where it states // TODO: add draw code for native data here
Rectangle( 10, 10, 60, 60);
check out all the drawing functions under cdc
then click the button ! which executes the program

since you want the easiest way you might as well learn mfc
as far as books "visual c++ in record time by sybex" for the generalwindows and "programming vc++ 5th or 6th edition by microsoft press" for the indepth coverage.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Same Anon Poster again.

The reason I would suggest you do not use MFC is not that I don''t like it. I do like MFC; it''s just that I have seen beginner programmers use it and get frustrated. Similarlly, beginner programmers get frustraded with Windows programming (because they are the same thing under the hood).

If you do what jstoll said you will run into the following problem:
You can''t have "Frame based" animation, unless each frame involves covering up the window and then selecting it again.
This can be resolved with by constantly faking being covered up by calling a function called "InvalidateRect" (causing flickering) or by using a graphics feature called "Double Buffering", both of which I bet you don''t want to deal with.

So you probably want to get a library that does all the graphics stuff for you so you can practice the logic and learn to code. Later, you can use the Win32 APIs (by then it might be the Win64 API) and see it really isn''t all that bad.

There might be some other easy to use libraries on the web and http://directory.google.com/Top/Computers/Programming/Games/Libraries/?tc=1 appears to be a good starting point.

Share this post


Link to post
Share on other sites