Question about OpenGl, 3D engines, and C

Currently I am learning the C programming language. What I’d like to do after learning it is to make a 3D engine for a game idea I have (I want to make an engine similar to Quake3 not a DOOM clone). What I’d like to know is: 1) how do I go about making a 3D engine, 2) where does OpenGL fit into all of this, and 3) is learning C++ really neccesary for the 3D engine I want to make. Thanks for any help.

[This message has been edited by Icyrain (edited 06-13-2000).]

Though I’m relatively new to the 3d engine field,I think I can answer your questions.

  1. how do I go about making a 3D engine

First,find some good reference books.If you really want to make a 3d engine,you need to understand some of the basic concepts and math involved with the process,even though you may never have to see them.The Black Art of 3d Game Programming is a good reference.The author of this book does a very good job of explaining the math involved with 3d games,and he touches on just about every aspect of 3d engine creation.The book is intended to be used for dos games,but the lessons that you learn will apply to real projects.

If you’re really crazy about writing your own equations and formulas,you might want to check out Computer Graphics:Practices and Principles.This book is not for the faint of heart,and it can be very dry reading,but it will tell you more about underlying math involved in making a 3d engine.You might want to find a copy of Introduction to Computer Graphics.It’s a textbook version of Practices and Principals,and it’s quite a bit easier to follow.

You also might want to check out some sites on the net for 3d tutorials.The 3d Blackhole Tutorial is a good read,if you can find it.I don’t have the URL for it anymore.

You might also want to look at the source code for commercial game engines to see how they’re structured.Source code is available for Doom,Quake I,Hexen,Heretic,Descent,and probably a couple other games I can’t think of right now.Don’t steal code from them,though.It’s much better to learn on your own than to steal code from someone else when you can’t figure something out.

And,finally,get a copy of the OpenGL Reference manual(AKA the Red Book).It explains every function in OpenGL,and is really handy to have around.There’s a version of it available online,but I really reccomend getting the book,because it is much more convenient.

  1. where does OpenGL fit into all of this,

OpenGl will be your rendering API.OGL is very powerful,but more importantly,very easy to learn.In 3 days,I was able to make a very basic First Person Shooter engine.It’s flat shaded,and there is no collision detection,but it’s still pretty amazing.OGL is really the quickest path to success if you’re a beginner,or even if you’re an advanced coder.OGL code is also platform independent,unlike Direct X.So,you can have your engine compiled for all sorts of bizzare platforms,without having to touch much of the OpenGL code at all.

  1. is learning C++ really neccesary for the 3D engine I want to make

This is a matter of debate.You can write the engine that you want to write in C without any problems.I personally prefer C over C++,because C++ adds a lot pretty useless functions,from my perspective at least.Anything that can be done in C++ can be done in C.You might have to work a little harder in C in some cases,but that’s pretty rare.C should suit you just fine.Doom and Quake were written in C.

I hope I have enlightened you…

Chris

Thanks for the help it was pretty informative. I was thinking about getting “The Red Book” but am not sure whether to get it or get The OpenGl Superbible which I’ve also heard good things about as well. I’ll be sure to check out The Blackart of… Thanks again.

[This message has been edited by Icyrain (edited 06-12-2000).]

You might want to pick up both.The Red Book is handy for reference purposes,while the SuperBible gives you more information concerning coding and techniques.The Superbible also covers a few popular formula’s,like rotation and tranlation in a 3d world<—This would help you out a bit with writing your engine.
Good luck!

Chris

Thanks. Once I can get some cash I’ll pick them up.

[This message has been edited by Icyrain (edited 06-12-2000).]

<sarkymode>
Hi! I’m just learning to build little toy houses out of match sticks! I wanna know, how do I build NASA’s space shuttle?!
</sarkymode>

Hey, I was just trying to figure out what books I’d need to read to reach my ultimate goal of making a game. It’s not like I’m going to build the next Q3 killer this weekend or something.

[This message has been edited by Icyrain (edited 06-14-2000).]

Hey! hey… sorry. okay
my apologies for thatr sarky comment. But!! But. I have to explain the background to my… er… bemusement

My argument is largely based on the observation that there’s a HELL of a lot more to programming than just knowning a language; moreover, there’s a hell of a lot to opengl before you can “just” write a graphics engine; it’s much in the same vein that knowing english grammar and a vocabularly DOESN"T MAKE YOU A POET or a novelist, or a satirtical essayist, or the ability to write technical documents for a conference.

Knowing how to construct a for() loop doesn’t tell you ANYTHING about how to write large programs. Nor does it tell you how about “advanced” structures you’ll need, like stacks, queues, linked lists, binary search trees, binary partition trees, oct trees, hash tables, and so on and so. it won’t tell you how to ANALYSE algorithms, to find out when heap sort might be better to use than quicksort, or why bubble sort is so sucky, and so on. Just knowing SYNTAX doesn’t MAKE YOU A PROGRAMMER. that’s my assertion.

so, after you’re learn how to make a while loop… perhaps even know how to use void pointers properly to get something approaching generics, you want to launch into quake 3. not even dabbling in wolfevensteins engine, where you don’t need to learn about arbitary line intersections (how DO you work out the intersection of two lines? solving simultaneous equations? working out the determinant of the matrix of homeogeneous equations??). You want to get stuck into quake3… an engine that took carmack, a mightly experienced coder, a year to complete…

I admire your ambition! but! you MUST realise what you’re asking isn’t impossible, but pretty f*cking close to it…
you have to practice programming first… to find out HOW to structure your thinking to write programs. you need to learn a heap of maths behind the practice… how to calculate the intersection of lines and polygons for creating oct trees, for example.

my suggestion is to RELAX about the quake3 engine for now. Learn how to CODE, not how to udnerstand syntax, and try more basic stuff before diving into the quake 3 end…

don’t let me try and flame you and dash your hopes for world domination, btw. I wish you the BEST of luck, but PLEASE realise that what you’re asking is a difficult task…

cheers
John

ya. no sh*t. i learned C/C++ over 6 years ago, have been at this 3D programming gig solidly for about 3 years now. I learn something new every day. This area of programming is enourmously complicated. I thought much the same. You know, whack at it untill i think i got it, then whip out a bad ass engine. NOT. 3D engines go way beyond looking pretty I found this to be ture, and it would have been a real hope crusher, had I not been so patient with myself. The ultimate goal: be as fast as possible AND look pretty. Sounds easy enoguh. But unfortunatley it isn’t. And if a game is the end goal, theres sooooooooooo much more that goes beyond the backbone renderer. You gotta take into consideration the game logic, user input handling, sound, netwroking, etc… All the while this other stuff will have to run almost at light speed so the little renderer you whipped out retains it’s 90+ FPS. John Carmack didn’t become the “definitive programming god” overnight. It took him a decade to write the Q3A engine. Thats the truth. I don’t wanna put a dent in anyone’s desire to tackle the challenges that lie in creating a cutting edge 3D engine. This is just a dose of reality. Oddly enough, it is this reality that keeps me hooked on this stuff. When the day comes that i do achieve my goal…well, you imagine for yourself how you’d feel.

I have to agree that it’s definitely not easy.I spent 2 years studying OpenGL,game physics,and rendering techniques before I ever touched any 3d code.That has really helped me out,because with all of the reading and outlining I’ve done,I’ve been able to get past a lot(but not all) of the common beginner’s mistakes and misconceptions.Plus,I’ve been coding in general for 18+ years,so that tends to help out a bit as well.There is no quick and easy solution.But,I will say that there is a new generation of programmers coming along,with new ideas and new techniques.You’ve got to start somewhere.But,I’ve never met anyone who produced a grade A game or application on their first attempt.I wouldn’t get discouraged just yet.Just don’t expect to write a game and make a million on your first attempt.

Chris

The more I learn the more I realize how much I don’t know. But we are all in the same boat. I started thinking I was going to make a game also but have since realized that I probably can’t do much on my own. What I am working on is a short (90 seconds) animated “movie”. This I can realize though I estimate it will take at least six months, use OpenGL and TrueSpace, and though I believe the movie will be great content-wise, only so-so technically. But press on. A great book (in my humble opion) is Andre LeMoths’ “Tricks of the Windows Game Programming Gurus”. This book is totally DirectX oriented but full of good stuff you can use if you want to make games. I think you should get your hands on all the books you can. They all have something to offer. You have a dream. Go for it because you have no idea where it will take you. Godspeed.

I should probably mention that I have 15 years experience in software development of business applications. I’ve only been trying to learn C++ on my own for a few months and have decided to take some night classes this fall to accelerate that process.
My movie will take at least a year or more to develop.
So far plan to use TrueSpace for the closeups (more detailed models) cause I got version 3 for free!
Have absolutely no idea how to integrate TrueSpace models into my C++ code. Or script camera movements. Or integrate sound. etc. etc.
But hell, its my dream.
But something will come out of it. Its the journey, not the destination.
Oh no waxing philisophical…

have you noticed that all those books are just documented source code? I realise some people might find that useful, but in LaMoths and his ilk seem to do a lot of this:

int main(int argc, char **argv)
{

now, this is declaring the function MAIN, which returns an int and accepts two arguments: the argument vector (argv) and the length, or “count” of this vector (argc).

printf("this is so lame
");

*this is calling the procedure PRINTF, a standard procedure declared in stdio. the stuff between the quotation marks (") is what is called a STRING LITERAL.

and so on. very little in the way of solid technical discussion, just pages and pages and PAGES of source code. What a poxy way of trying to teach something. Much better is the Red Book of OpenGL (which I love so very very much Yes! It has source, but no it isn’t pages of repetive boring stuff but focuses on how to use the funcs it describes… because it DOES DESCRIBE OpenGL, rather than LaMoth’s `look-at-this-context-and-follow’ style. No, he isn’t the only one who does this, and I’ve probably seen worse.

oh! even worse is some flight of fantasy book i’ve seen around the place. its old, now, but… geepers. it seemed to follow the philosophy of wasting space with source and poxy useless diagrams that took up the whole page but described NOTHING. true, they were nicely rendered, but utimately worthless. one was a nicely shaded rod trailing into the distance marked with sequential numvbers… the whole point of this was “welcome to the number line”. crikey… and this book was targetted for immediate-advanced programmers. number line? puh-LEASE. another one was the supposed difference between digital and analogue sound. one had some guy playing the saxaphone and the other had a CD… both with concentric arcs emmenating from them. these took up the entire page, pretty much, because of the weird alignment problem. What a waste of space… and they expect the public to fork our $AUD80 for what amounts to printed commented source code?! argh!

sorry. pet hate. i’ll… er… stop ranting now

cheers
John

I am writing this in another aspect.
let see how to say it.
you said you have an “idea” of making a game. I think the only thing you need to do is make a general look at how to make a game, not really learn how to programming.
a great game is not “made” by only one person. it needs ideas, artists, programmers…etc. I think you should be fit into the member of making ideas. and also, you need to learn how to work in a group, especially in computer science, group experience is a required skills for graduation.
Hope you can choose your right road.
From Alan.

Originally posted by Glenn Upton:

So far plan to use TrueSpace for the closeups (more detailed models) cause I got version 3 for free!
Have absolutely no idea how to integrate TrueSpace models into my C++ code. Or script camera movements. Or integrate sound. etc. etc.

Perhaps one of the possible ways to achieve this result is to use “Crossroads” (no URL, sorry), import Truespace and export as “C/C++”.

go on, ralf =;-)

Thanks Ralph
The url is http://home.europa.com/~keithr/crossroads/
Won’t get to check that out for a while though. Although my GL model is built of course like everyone else I’m improving tweaking etc.
Take care and thanks again
Glenn

I dunno john. There is one LaMothe book that REALLY helped me out, as far as 3D programming/game design fundamentals are concerned. I got it about 4 years ago. It’s called “The Black Art of 3D Game Programming”. Though it does tend to delve into the source code a lot, the book was very helpful in getting me started. I allready knew C/C++ at the time though, so I understood what all the source code displayed was doing as I read the chapters. But with this book, I was able to get a simple DOS gouraud-shaded, z-buffered ASC model viewer running at a decent speed (It ran swell on my P 200Mhz that I had at the time, but like sh*t on my 486 SX 66 =) in about 2 weeks. This was with very little knowledge of 3D programming before reading the book.

[This message has been edited by fenris (edited 06-17-2000).]

Even though LaMothe’s books are usually good in content, I find that there are numerous errors in his codes, especially in the first printout…

whoa, i have been programming in c++ for 1.5 yrs now… hehe, know all about stacks, queues, hashes n stuff… started to learn openGL about a month ago, just came back from a week of vacation.

hehe, I am so cool!!!

by the way, does any one know when is hashing actually useful?? Because I can’t really think of any scenario except one!

One great use of hash table is for script created classes.

It permits you to add and access properties rapidly.