Graphic library in C++

Pages: 12
May 19, 2009 at 11:02am
Hi all,
I tried to include the graphic library in C++ as in C: #include <Graphics.h>, but got an error saying: "no such a file or directory".. How bad!
How the graphic library can be attached in C++ and use it to draw a line for example?
May 19, 2009 at 11:09am
you must be programming in turbo C++,, are you.. that blue one??
if thats the case, there is an option somewhere for directories in settings, add the path where your graphics.h is.. thats it.

if not then what platform/compiler you are using?
May 19, 2009 at 11:11am
I use Visual Studio 2008.
Should be included as in C? If yes, why doesn't work to me?!
Last edited on May 19, 2009 at 11:41am
May 19, 2009 at 1:14pm
there is no graphics.h in vc++.

so you mean when you create a c project in VS or vc++ you are able to find graphics.h file?
May 19, 2009 at 1:40pm
I want to create C++ project and not able to find graphics.h file. I think there is another way to do that in C++ but don't know how :(

For example in C# you define it like this:
g = this.CreateGraphics();
g contain all the functions like drawline, drawpixel etc.

Do you know how the syntax going in C++?
May 19, 2009 at 1:54pm
closed account (S6k9GNh0)
C++ has no graphics library.
C has no graphics library.
I didn't know C# had one but apparently it's part of the (.NET) Framework.

Of course you can just use an already made graphics library.
Last edited on May 19, 2009 at 1:55pm
May 19, 2009 at 2:27pm
The <graphics.h> is an old Borland library for DOS.

If your professor requires using it, you can use the WinBGIm library, which is the modern Win32 emulation of that old library.
http://codecutter.org/tools/winbgim/

It says that it is designed for use with the GCC [MinGW], but it works with BC++ and MSVC++ also...
http://www.cs.colorado.edu/~main/bgi/install.html

Hope this helps.
May 19, 2009 at 6:41pm
Thank you all..
Duoas, I don't have any professor yet :)
Learning this only to fill my time.
May 19, 2009 at 7:16pm
Ah, then I suggest you forget that old nonsense and get yourself a proper toolkit.

For games and the like, use SDL.
http://www.libsdl.org/
Get started here:
http://lazyfoo.net/SDL_tutorials/

If all you want is to draw lines and the like, use a regular toolkit like Win32, wxWidgets, GDI+, FLTK, etc.

My advice here is not pure gold -- it is only intended to help you think about your design goals...

Good luck!
May 20, 2009 at 7:47am
I may use SDL or OpenGL when reach a good advance of programming some algorithms I'm working on. I'm not a game programmer but SDL and OpenGL still useful in my case.
Thank you for the links!
May 20, 2009 at 1:28pm
> I use Visual Studio 2008.

Then graphics.h has nothing to do here.
Simply use Native Win32 Gdi apis (no need of SDL or any other external library)
May 20, 2009 at 1:41pm
Is there any recommended site which teach how to use Native Win32 GDI ?
May 20, 2009 at 1:56pm
closed account (S6k9GNh0)
http://windows-programming.suite101.com/article.cfm/drawing_win32_gdi_api_programming

Mind you, this tutorial explains very clearly that this type of programming isn't made for games.
Last edited on May 20, 2009 at 1:57pm
May 20, 2009 at 2:25pm
you can study charles petzold also.. very good book on win32..
May 20, 2009 at 3:31pm
Noha
George is a rabid MS groupie. Win32 is not particularly simple, especially for beginners -- it is a low-level API.

If you are trying to keep it simple, go with SDL. There is nothing wrong with using non-Microsoft-made libraries, and SDL is exceedingly easy to begin with.
May 20, 2009 at 3:49pm
closed account (z05DSL3A)
There once was a man called George.
Who, on Microsoft products did gorge.
When it came to third party,
Especially things arty.
He was as blind a Gordy Laforge!
May 20, 2009 at 4:28pm
closed account (S6k9GNh0)
I agree. I see nothing wrong with moving into SDL or other type APIs that can be used similarly. Win32 GDI should probably be avoided....
May 20, 2009 at 4:55pm
The portability and ease of use of SDL makes it far more preferable than using any Windows GDI gitup for basic graphic stuff, IMO.

Don't assume everyone uses Windows! Break away from the Win-only development habit by never getting sucked into it!
May 20, 2009 at 6:10pm
Now lets make a final decision!
Hmm.. According to the majority here I see that SDL is more recommended.

Thank you all :)


May 20, 2009 at 6:48pm
For just playing around with it on the fly, there is also PyGame, which works with Python.
http://www.pygame.org/
Pages: 12