Advertisement

what did you do?

Started by November 17, 2004 06:34 PM
10 comments, last by llvllatrix 20 years ago
is there anybody here who is really good at opengl? if there is, what did you do to learn is so well, i can get the basics and stuff, but i see some stuff that is insane, and i think it would be cool to do it.
I spent a lot of time and effort.
And I didn't look at other people source.
For the first times, a printed book helps. The best book I've bough is OpenGL superbible. A new edition has been recently published. For beginners it's really useful and has some interesting reference properties until you don't know how to read extension specifications.

Good luck!

Previously "Krohm"

Advertisement
Yes, getting a book is very helpful. Looking at code is a great way to learn, but it has this nasty habit of creating a dependence on it. I speak from experience here ;) I have a tendency of writing something once and then reusing/modifying it for every program i write afterwords. (on a side note, how bad is it to reuse your *own* code?)
"If it aint broke dont fix it."

One one side, I believe that one of the goals of progamming is to write code that is reusable.

But on the flip side, dont be afraid to start over and try something different if your not happy.

Programming is a profession/hobby where it pays to be lazy.
I agree with that. :)
I use some components I have developed 2 years ago and never looked at them anymore. I'm amused of how much those stuff do their job.

Previously "Krohm"

Advertisement
Makes me feel a little better about it ;) I remember at one time I had about 300Mb of source code (VB, C++, ASP, and Java) that I lost.... I wanted to cry.


On a side note, I have a question about an unorthodox way I set up OpenGL... I learn by writing code. For the moment I am working on the basics of an X-Com like game (*someday* ill think about the battle's). Anyways, I use a custom file for each "scene" and include them in the drawing code... Each of my "GLScene" files has an if statement at the top to see if it should run.

I.e.
if (PlayMenu){
Draw_This_and_That;
}

I like to break things up a lot, for me it makes it easier to find everything. I have a header file for custom global vars, custom functions, etc. Right now for about 4K lines of code I have it broken up into about 10 sections + the GLScenes. How should you handle the switching from one scene to the next and does it break any major conventions to separate stuff so much?

(On a side note, as this is a learning project I am happy with how it is progressing.. I have a small intro, a partially functional main menu, and a good start on the geoscape. It displays the world, even does the Day/Night effect, had time control's, and keeps track of the date)
Separation and encapsulization good and the degree to which you do it depends on what you're writing. The larger the project, the larger the separation you should need. If you consider the stuff you've seen on nehe's site as orthodox then yes, you definitely need more separation (there really are no set standards that people adhere to; its more of a design instinct).

Scene switching is a similar problem. It can be done many ways. Like everything, you want to pick a solution that will let you do what you need to do now and later on down the line. What I do for state management in games is I have a state stack. Each state in the stack has an expired property. When the state is put on the stack, its set to alive and certain things like waiting x number of seconds can kill the state. If you start a new game, or bring up a menu, a new state is added to the stack. When there are no states left, the game is over.

Here is a typical example:
- game starts, create a menu state and add it to the stack
- user chooses to start single player game, create a game state and add it to the stack
- user brings up menu, add a menu state to the stack
- user chooses to quit, kill the menu, kill the game
- only state left is the original menu state so display that
- user chooses to exit the menu, kill the menu state
- since no states are left, exit the game

Thats what I typically do, but it typically depends on the type and complexity of the game. This for example, is overkill for tetris, is probably good for something like starcraft and halo, and probably wont scale to something like ffXI.

Cheers,
- llvllatrix
Quote: Original post by Dvad78
I remember at one time I had about 300Mb of source code (VB, C++, ASP, and Java) that I lost.... I wanted to cry.

Same happend to me. 500mb of sources&demos gone.

@iedoc:
You learn by trying. Start small and build your way up. Don't worry if you fail. We all failed countles times. But each time you do something you learn something new. And that counts.
Reading is also important. Not just books (personaly I don't like reading books all that much) but various papers about graphics and programming in general. If you don't understand a paper save it for later. All things can come usefull at some later stage. Right now I have about 1bg of them. Some are still a bit out of reach, but in time.. we'll see.
You should never let your fears become the boundaries of your dreams.
Thanks for the tips. Since i plan on this being a decent sized project (im expecting around 50K lines of code before i am done) i have been breaking things down a lot.. Sound effects is one file, Background sound is another, Texture manipulation is one file, save functions are in another, etc...

A note on me using "big" projects to learn from, i am good at breaking them down into small chunks.. I use each "chunk" to learn how to do something.. Like for example in this project, setting up the load screens was one chunk, the applog was one chunk, creating sound effects was one chunk, mouse input was one chunk, the main menu interface was one chunk... In the end all the little chunks add up to a game. =)

This topic is closed to new replies.

Advertisement