How to make a 3D game in C++?


by Algren
Tags: game
Algren
Algren is offline
#1
Jan24-12, 07:14 AM
P: 47
I dont want to use any game engine.

I want to use only C++ to make a 3D Game. How can I do so?

I have made many 2D games, like chess, connect 4, mario, snake, etc.

But how do i do 3D and make things like DOOM?

I use the OLD Turbo C++ Compiler, not Dev C++
Phys.Org News Partner Science news on Phys.org
SensaBubble: It's a bubble, but not as we know it (w/ video)
The hemihelix: Scientists discover a new shape using rubber bands (w/ video)
Microbes provide insights into evolution of human language
phiby
phiby is offline
#2
Jan24-12, 07:37 AM
P: 77
Quote Quote by Algren View Post
I dont want to use any game engine.

I want to use only C++ to make a 3D Game. How can I do so?

I have made many 2D games, like chess, connect 4, mario, snake, etc.

But how do i do 3D and make things like DOOM?

I use the OLD Turbo C++ Compiler, not Dev C++
AFAIK, Turbo C++ doesn't support any 3d Graphics library. Other than that, TurboC++ is a 16-bit compiler & it produces 16 bit binaries. 16 bit stuff doesn't run well on Win7-64 bit edition - you will need to use an emulator.

Download Visual C++ (I think non-commercial edition is free) or g++ (this is fully free) Then you can use OpenGL or DirectX for programming 3D Graphics.

If you want to learn more about Computer Graphics - pick up the book by Hearn & Baker.
Algren
Algren is offline
#3
Jan24-12, 07:44 AM
P: 47
Quote Quote by phiby View Post
AFAIK, Turbo C++ doesn't support any 3d Graphics library. Other than that, TurboC++ is a 16-bit compiler & it produces 16 bit binaries. 16 bit stuff doesn't run well on Win7-64 bit edition - you will need to use an emulator.

Download Visual C++ (I think non-commercial edition is free) or g++ (this is fully free) Then you can use OpenGL or DirectX for programming 3D Graphics.

If you want to learn more about Computer Graphics - pick up the book by Hearn & Baker.
Well, i will have to make a great deal of syntax change to transfer into another compiler.

Although, then what is the best possible game makeable in TC?

phiby
phiby is offline
#4
Jan24-12, 08:23 AM
P: 77

How to make a 3D game in C++?


Quote Quote by Algren View Post
Well, i will have to make a great deal of syntax change to transfer into another compiler.
Depends. All the standard C++ stuff remains the same. But any compiler specific functions you have used would need to be rewritten. Another thing to remember is that TC is a 20 year old compiler. C++ has changed radically since those times. Most standard code written in TC++ would still work in a modern C++ compiler, but current C++ is far more powerful & offers you really powerful features (templates etc) which will make programming easier for you.

However, since you say that you have only written 2d games till now, wouldn't you have to scratch from scratch anyway to make 3d games?

Quote Quote by Algren View Post
Although, then what is the best possible game makeable in TC?
You can do 3D - but you would have to write you own 3d library which would be non trivial exercise. If you are serious about programming, take the plunge and move to a modern compiler & library.

By the way, I am not a game programmer.
Coin
Coin is offline
#5
Jan24-12, 07:24 PM
P: 587
First off, you probably do want to use a game engine. Here's a list of game engines suitable for a hobbyist, some free...

Second off, I recommend using Dev-C++ or Microsoft Visual Studio Express.

Third off if you just want to start drawing 3D and do not want to rely on a library, the best thing to do is start learning OpenGL or DirectX. What I like to do is use SDL to create an OpenGL window and draw OpenGL inside of that. I use this approach because it means my code is very portable and can run on all operating systems. (If you are careful to write "OpenGL 3.0" or "OpenGL ES", you can even port to mobile phones easily.) There are many OpenGL tutorials on the internet.

Here is some OpenGL sample code I put on the internet but I am not sure it will help you much if you are a beginner... http://msm.runhello.com/?p=385

If you really, REAAALLLY just want something that looks like "doom", and you have working 2D drawing already, the original "doom" was done using "ray casting" and rendering in CPU. You can easily do the math for ray-casting yourself and then just splat that to screen with your existing 2D drawing tools. I find a tutorial on raycasting here. However this is not what you want, you want to be using a modern 3D API with GPU acceleration. 3D in CPU will be very slow and not look very good.

Well, i will have to make a great deal of syntax change to transfer into another compiler.
If you have actually written code which will break if you change C++ compilers, then it is bad code and you want to replace it anyway.
chiro
chiro is offline
#6
Jan25-12, 04:48 AM
P: 4,570
Quote Quote by Algren View Post
I dont want to use any game engine.

I want to use only C++ to make a 3D Game. How can I do so?

I have made many 2D games, like chess, connect 4, mario, snake, etc.

But how do i do 3D and make things like DOOM?

I use the OLD Turbo C++ Compiler, not Dev C++
Hey Algren and welcome to the forums.

As other posters have pointed out, using a game engine to make games is a good idea. I say its vital because it will take you a very very long time to get things done.

You should note that DOOM is actually a raycaster. It's not a true 3D rendering application like you see in your modern games. Quake was the one that filled this gap. You can get source code for both binaries from the iD website if you want to learn about this.

Also as other people have mentioned you will need to switch compilers. There are a few to choose from: Visual Studio is good for its interface. You could use Dev-C++ but I don't like its interface as much as VS.

Making 3D games is a lot of work. As other posters have pointed out, there are a lot of open-source hobbyist engines out there that allow you to get something up and running fairly quickly, and allow you to integrate game specific code fairly easily.

The biggest headache is learning the internals and how to get the stage of adding content (art assets or code) to where you can get what you want up and running straight away.

It takes a little while before you become able to get stuff up and running the way you want it with an existing engine, but its worth it. I wouldn't code your own from scratch unless you really, really want that learning experience. I did this to a large extent and it was a great learning experience for me, but it took years of my life to do this.
Coin
Coin is offline
#7
Jan25-12, 02:02 PM
P: 587
Really you might be happiest just downloading Unity 3D and using C#. If you already know some C++ it is not a big jump.
jedishrfu
jedishrfu is offline
#8
Jan25-12, 02:05 PM
P: 2,493
there was no mention of IDEs but both Eclipse and NetBeans supports C++ development and provides the same kind of experience as Turbo C++ does complete with code completion and code debugging. Learning these IDEs are crucial for modern programming development.
Hurkyl
Hurkyl is offline
#9
Jan25-12, 02:37 PM
Emeritus
Sci Advisor
PF Gold
Hurkyl's Avatar
P: 16,101
I'll give the cheeky answer.

Quote Quote by Algren View Post
I want to use only C++ to make a 3D Game. How can I do so?
It's impossible: C++ simply doesn't offer you the features to do so. Of course, the same is true of most programming languages.


However, C++ (and most languages) is flexible enough that third parties can provide you libraries that let you do graphics and other stuff.

For example, absolutely nothing in conio.h is part of C or C++. Instead, that was a bonus feature a lot of old MS-DOS vendors decided to bundle with their product.
chiro
chiro is offline
#10
Jan25-12, 10:59 PM
P: 4,570
Quote Quote by Hurkyl View Post
I'll give the cheeky answer.

It's impossible: C++ simply doesn't offer you the features to do so. Of course, the same is true of most programming languages.


However, C++ (and most languages) is flexible enough that third parties can provide you libraries that let you do graphics and other stuff.

For example, absolutely nothing in conio.h is part of C or C++. Instead, that was a bonus feature a lot of old MS-DOS vendors decided to bundle with their product.
Lol, you're a bastard Hurkyl :)


Register to reply

Related Discussions
Can you make an object have a stronger graviational pull if you make is denser? General Physics 29
How do I make Jscript interact with an EXE or MUD (game)? Programming & Computer Science 5
Game theory: value of a game Calculus & Beyond Homework 4
Help with game theory (specific knowledge in game theory probably not required) Calculus & Beyond Homework 4