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

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++.

Related

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.

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.

Cross platform window library - Integrating OpenGL and DirectX

I'm about to start working on a custom cross platform engine (c++) that will need to be able to support the latest versions of both OpenGL and DirectX. The renderer is chosen before compilation.
I'm looking at cross platform libraries to handle window creation and input that can also handle the latest implementations of DX and OGL - preferably low profile and most importantly: fast. Any recommendations?
Thanks!
SDL is probably the most used cross-platform library for that kinda thing.
You should check out SFML (Simple Fast Media Library). Although SDL is much more well-known due to its older age, SFML is far richer functionality- and design-wise, despite being only a few years old. It can essentially be described as a newer, more modern, and object-oriented SDL (it's C++; SDL is C).
To give you a brief overview of its features:
Cross-platform (Windows, Mac OS X,
and Linux).
Has modules for system-related stuff
(events, timers, etc), windowing,
video (hardware-accelerated OpenGL 2D
graphics), audio, and networking.
Supports all essential and mainstream
image and audio file formats, with
the notable exception of MP3 due to
licensing issues (although this is
available as an extension).
Also supports fonts (FreeType2 is
integrated) and many other things.
I use it for all my projects that need more than just a command line and I love it. I highly recommend it.
It should be able to provide a good base for your idea.
wxWidgets.
The OpenGL and DirectX are somewhat similar yet very different. OpenGL is built with idea to forward developers desire to render to devices if available. DirectX is built with idea to make rendering capabilities of devices available for developer.
Thanks to differences you end up implementing almost everything twice. Manipulating windows is quite minor issue. You do not need exactly same windows since you will use one or another anyway for rendering in them.
It is perhaps best to use different things for creating the windows (like SDL for OpenGL and MS API for DirectX) and wrap it behind common interface. Then the "things" will be also chosen before compilation. Where MS API is not available there you will lack DirectX too, so no need to make it portable.
Irrlicht
Ogre
Both are fast and powerful. They fit great for games, if I'm getting right your intention.

Does XNA support OpenGL

Eventually, when I've finished the game I'm writing, I'd like to port it to XNA. I'm using C++ and OpenGL at the moment. My question is simply this: does XNA support OpenGL (I can switch from C++ to XNA language if need be)?
No, not directly. XNA is built upon DirectX.
You can spin off a separate window, using a wrapper around OpenGL if you want however. You'll need to use a unofficial binding though, in order to do this. Then use XNA constructs within this. I've worked on a project like this and wouldn't reccommend it. There are two ways to use XNA. The by the book approach, which is too limited for most, or the other way. The 'other' way being not making use of the base game classes and handling your own game logic. With the second approach using another rendering method is too much work for no real pay off.
I'd recommend that for your current game the logic and graphics are separate. If you do decide to port at a later date, the transfer should be easier to convert from C++ to C#.
Also, XNA is not a language. It's a framework built using C#.
The XnaTouch implementation runs on iPhone and so uses OpenGL ES under the hood. It uses C# via the Mono project (specifically MonoTouch for the iPhone). This could conceivably be used as a base to port XNA to other platforms that don't support DirectX (eg: Mac, Linux).
(Note: in my experience the XnaTouch implementation is not very good.)
Obviously the Xbox 360 doesn't use OpenGL at all - it uses DirectX - you don't get an option about this.
And I don't even understand why you'd want to use XNA, but with OpenGL under the covers, on Windows when the existing XNA implementation works just fine.

Is GLUT dead?

After reading a discussion on Ubuntu Forums concerning GLUT vs. FreeGLUT.
Is GLUT dead for graphics programming? Is SDL all the rage now for OpenGL programming?
In my opinion, GLUT is still great to learn programming OpenGL in. It is no longer maintained, as far as I know.
Do look at : http://www.opengl.org/resources/libraries/glut/ for the official word
Extract from the above link -
"The GLUT library has both C, C++ (same as C), FORTRAN, and Ada programming bindings. The GLUT source code distribution is portable to nearly all OpenGL implementations and platforms. The current version is 3.7. Additional releases of the library are not anticipated.
GLUT is not open source. Mark Kilgard maintains the copyright."
Also look at : http://www.opengl.org/resources/libraries/windowtoolkits/ for alternatives.
You may also want to check out GLUX : http://code.google.com/p/glux/
As far as SDL being the rage, it is great for cross-platform stuff and many people are using it. I personally use Qt for my OpenGL work. Other windowing system alternatives also exist. It is also possible to program natively for windows or X.
Edit Feb 28 2017:
I should clarify that the student looking to jump into the practicalities of OpenGL would be better served by starting with SDL or Qt. As #TM rightly notes in his comment, using GLUT is far removed from the realities of programming a real world rendering application in OpenGL. My opinion that GLUT is good for learning comes from the thought that it is easier to learn when one separates the concern of learning an OpenGL from the concern of learning about the specifics of a Windowing system. Naturally, this may not match your needs.
GLUT is rather simplistic for serious game development. SDL is used by numerous commercial game porting companies. GLUT happens to be good for studying OpenGL and for simple demos. Something like SDL is quite good for actual games.
SDL with its abstractions for other things, such as audio, and SDL's various addon libraries (SDL_image, SDL_mixer, ...) help a lot when writing a full game. Having control over the main loop is also pretty important.
If you are working on an OpenGL application which needs some native GUI as well (for example, a 3D modeler) you may be more interested in using wxWidgets or, as batbrat suggested, Qt.
GLUT is a very useful learning guide, but it's not full featured or useful enough for most real-world applications. I've also encountered minor issues with a few different GLUT implementations and support in some environments, so I've learned to stay away from it for anything but quick demos.
My OpenGL experience has generally been on embedded systems where I have complete control over the output, and there I use X Instrinsics to get the basic OpenGL Window up. It's a bit painful, but it's a small amount of code to get to OpenGL, where the bulk of the work is done.