graphics programming - c++

I would like to program some graphic figures such as line, circle,etc. I have used turboc++ 3.0 for
dos graphics. I would like to do the same with the compilers dev c++ or code blocks or vc++.
I would like to implement dda and bresenhems line and circle drawing algorithm.
how should I go about implementing these programs through these compilers (not the command line tools).
I have a really vague picture of graphics programming.please help..
please note : I have a nvidia graphics card 1gb.. so I cannot use dos graphics (I think the card is the reason).

If you're wanting to play around with graphics code to draw objects and do things with them may I suggest that you skip the whole Windows/GDI/DirectX/ thing completely and take a look at Processing?
It's basically Java, so you won't have to jump too far for the language, but more specifically it's designed for playing around and experimenting with graphics, so may suit you perfectly.

You really have a vast variety of options. Starting from GDI (not hardware accelerated), finishing with a heavy stuff like DirectX, OpenGl. There is also a nice library, called SDL. It does not really matter what technology you will use to solve your problems. If the speed is not a matter, i think GDI is the right and most simple choice.

You may want to start off with these tutorials:
http://www.tutorialized.com/tutorials/C-and-Cpp/Graphics/1

From the sound of things, you're trying to produce a program that runs on Windows. In that case, you don't need to implement basics like Bresenham's algorithm to be able to draw lines and circles. Windows provides MoveTo and LineTo to do basic line drawing, and Ellipse to draw ellipses -- and if the axes are equal, the ellipse it draws will be a circle.
Edit: It also sounds like you haven't written any code for Windows. This is quite different from writing code for DOS, so you'll probably need a good book. Charles Petzold's Programming Windows is a classic (though for C++ you'll want a somewhat older version -- I believe the current ones concentrate on the .NET languages).

I am using the powerful cross platform project: http://cimg.sourceforge.net/ .
you have there all primitives and more.
I you wish to use your GPU power you can use glut library for OpenGL.
cheers Arman.

Related

C++ Graphic API with a small learning curve - linux

i have to do some very basic drawing in Linux , like joining some points , tracing trajectory of a moving point . I am looking for a graphic library which has a very small learning curve so that i can save my time and avoid getting into things like gtk and opengl since i don't need something complicated .
Edit 1 :Can you provide links to the tutorials for SDL which explains very basic drawing also for any other libraries which you think is relevant .
You want pygame, Allegro, or SDL with SDL_gfx. All of these are available through the most popular package repositories.
Be prepared to get used to dealing with surfaces, graphics primitives, blitting, and the like. The learning curve is not large, but it's still a significant paradigm shift if you've never done graphics before.
I was taught with FLTK, and as the middle aged man says "I turned out OK didn't I?"
You might be also interested in Cocos2dx, it works on many different platforms (linux included).

Easy to use drawing library in c or c++?

I'd need a very easy to use drawing c or c++ library. This means that I don't need to put buttons, frames or anything else in there, but I need just to draw points, circles, lines on a graphic window. Is that possible?
Cairo is a nice option if you are looking for ease of usage.
You can use one of the many C++ creative coding frameworks:
Cinder
openFrameworks
polyCode
If you are working on Windows, try Direct2D, it's very powerful and equally simple to use.
More info at : http://msdn.microsoft.com/en-us/library/dd370990%28v=vs.85%29.aspx
SDL is pretty nice. If you really want to get involved, Direct3D and OpenGL are probably the best options.
Try SFML: http://www.sfml-dev.org/
You should be a little more specific:
What platforms do you want to target?
What do you exactly mean by "easy to use"?
If you are using Windows and just want to learn the concepts of computer graphics, just use the Windows GDI.
If you want to learn computer graphics for mobile devices, use OpenGL. It is a bit harder to use than the Windows GDI, because it is a lower level API, but it is more powerful.
Anti-Grain Geometry has some really nice results. It's not difficult to use. It's a C++ library and I don't know if there are C bindings.

3-d animation in C++

I am doing a scientific project in C++ and I need to draw simple animated 3-d images of moving atomic groups. What is a good and convenient graphics library to do that? Some general remarks are also appreciated. I work in Linux.
Thank you in advance, Roman
OpenGL of course,
one library you could use is glut for that.
have a look on http://nehe.gamedev.net/
If you want to show 3D in linux, you should use OpenGL. But since it is a C library, you can use a wrapper, like for example glt or sfml
The easiest library to use is Vtk. A more difficult and slower, but potentially better rasterization can be achieved using POVRAY.
I suggest looking at game oriented graphics engines. They provide OO wrappers around openGL and have lots of utility functions for loading 3d model formats etc.
If you don't want to get bogged down in writing the graphics, a game oriented renderer is likely the fastest way for you to get stuff on screen.
Ogre may be a good choice - it has a fairly large and helpful community.
Irrlicht is another possibility.
There are several possibilities, some perhaps more suitable than others, obviously!
I think any one of the options mentioned above would serve to do so.
I personally recommend OSG.
http://www.openscenegraph.org/projects/osg

C++ Game Programming Resources

Where can i get some advanced game programming resources for c++?
At http://gamedev.stackexchange.com ?
More specifically, this question and lots of others tagged with c++
Start with writing some simple 2D games, e.g. Snake, TicTacToe, etc. Write these using any GUI builder you're already familiar with.
Then try to rewrite these games using a serious graphic engine, e.g. SDL, OpenGL, or DirectX.
Then try to write a more complex 2D games, e.g. side-scroller. Write these games with the graphic engine of your choice.
Then add some simple 3D effect to your 2D game, e.g. parallax scrolling.
Then rewrite this effect with true 3D, use 3D models/sprites, 3D environment, etc, while maintaining a 2D look and feel.
Then add some simple 3D look and feel, e.g. allowing characters to move in the Z-direction (to/from the camera), doing camera rotation, etc.
If you just got out of the command prompt and simple GUI, you'll probably want to start simple.
I'd very much recommend OpenGL as your API of choice. Since you've done some simple GUI programming, you'd know what an API is.
OpenGL has the following advantages (compared to SDL and DirectX previously mentioned):
-Its hardware accelerated (SDL is not as far as I know)
-Its 3D (SDL is 2D)
-Its cross-platform (DirectX is Windows only)
By far the best place to start with OpenGL is the Nehe tutorials.
http://nehe.gamedev.net/
Game programming becomes evident once you become a bit more familiar with the API.
Also, I'd heartily recommend GLUT (OpenGL Utilities Toolkit). It simplifies window creation and user input handling, among other things. Its great for learning OpenGL. It also happens to be cross platform.
Here's freeglut, a free GLUT implementation:
http://freeglut.sourceforge.net/
OpenGL is also a relatively simple and easy API to learn. You'll be going into 3D in no time.
What libraries are you using? You can try GP wiki. It can be a bit hit and miss depending on what you want to use.
By "resources," do you mean tools? Libraries? Tutorials? I have a bunch of useful game developer links in the sidebar of my own site. I also think "Mathematics for Game Developers" was very helpful. It has a second edition as well.

What environment should I use for 3d programming on Linux?

One thing I always shy away from is 3d graphics programming, so I've decided to take on a project working with 3d graphics for a learning experience. I would like to do this project in Linux.
I want to write a simple 3d CAD type program. Something that will allow the user to manipulate objects in 3d space. What is the best environment for doing this type of development? I'm assuming C++ is the way to go, but what tools? Will I want to use Eclipse? What tools will I want?
OpenGL/SDL, and the IDE is kind-of irrelevant.
My personal IDE preference is gedit/VIM + Command windows. There are tons of IDE's, all of which will allow you to program with OpenGL/SDL and other utility libraries.
I am presuming you are programming in C, but the bindings exist for Python, Perl, PHP or whatever else, so no worries there.
Have a look online for open-source CAD packages, they may offer inspiration!
Another approach might be a C#/Mono implementations ... these apps are gaining ground ... and you might be able to make it a bit portable.
It depends on what exactly you want to learn.
At the heart of the 3d stuff is openGL, there is really no competitor for 3d apps, especially on non-windows platforms.
On top of this you might want a scenegraph (osg, openscengraph, coin) - this handles the list of objects you want to draw, their relationship to each other in space the ability to move one relative to the others, selecting objects etc. It calls opengGL to do the actual rendering.
Then on top of this you need a gui library. Qt, Fltk, wxWigets or one built into the scene library or written directly in openGL. This handles the menus, dialogs frames etc of your app. It provides an openGL canvas to draw into.
Personal choices are openscenegraph and Qt
For the 3D part, I strongly recommend the SDL Library with the OpenGL library
You can get some tutorials here
Qt has a pretty decent OpenGL-based graphics module.
Maybe you should consider using a graphics rendering engine such as OGRE. Coding a CAD program from scratch using OpenGL will take lots of time.
On Linux you have no competition to OpenGL.
It's one of the big players in the 3D field, so it's definitely worth learning.
This site has some excellent guides and code examples (on various languages).
You can use OpenGL with many languages, naturally on C and C++ but also for example with JAVA using LWJGL or other API's.
If you want to program at "a higher level" than opengl, use vtk. It is quite easy to get started and has bindings to many languages.
See www.vtk.org
you may use OpenSceneGraph for rendering.. it is an OpenGL based library..
and you may use OpenCascade.. it is good for 3D modelling...
we are implementing such an IDE at work and we use these things.. using pure OpenGL may be hard for you... anyway you may try...
for interface it is good to use Qt..
and i suggest you to use Eclipse if it is Linux..
(if it was Windows, suggestion would be Visual Studio)
For a C/C++ IDE, you have the following options:
KDevelop - KDE-based
Anjuta - GTK-based
Netbeans
Eclipse
Of course, you could also use a language like C# or Java:
Best OpenGL Wrappers for Mono and .Net
JOGL
There's really no reason why a simple CAD application would have to be written in C++.