# Preknownlegdes before OpenGL

• 10-19-2004
Tynnhammar
Preknownlegdes before OpenGL
Hello again!

Well I've decided that my exam work, will be a demo made with OpenGL. So my question is what are the preknownledges that I should have before I start OpenGL?

I already know basic C++, and its 1,5 year until we are starting to work on the above noted project. You think I can learn up all I need until then? :)

Well I have a last question, these things with pointers, I just don't get it! I would be greatly thankful if someone could post a link to an useful article or something, please do not post mediocre onces because Ive read so many but still don't get it. I mean what is the point? :o ;) :p
• 10-19-2004
bithub
If you understand the basics of C or C++, then you can start learning openGL. In my opinion, the best site to learn is NeHe's.

Pointers are fairly simple to understand once you realize what they are actually doing. Take a look at the following example:

Code:

```int x;                // A variable named 'x' which holds an integer value int *px;        // A pointer named 'px' which holds the location                         // of an integer variable. x = 10;                // assign x the value of 10 px = &x;        // assign px the address of the variable 'x'.                          // px is now pointing to the variable x. printf("The value of x is %d\n",x); printf("The value px points to is %d\n",*px); // The * before 'px' on the above line is needed to indicate we want // the value pointed to by px, not the value stored in px.  The value // stored in px is an address, but we want the value which the address // points to.  This is called dereferencing the pointer. x = 5;                // change the value of x to 5. printf("The value px points to is %d\n",*px); // Notice now how the value that px points to is now 5 instead of // 10.  This is because the variable that it was pointing to was // changed.```
• 10-19-2004
Tynnhammar
Thanks, you have enlightened me pretty much, thanks :).

So you can say that a pointer holds the value of another variable? But when is it good to use it? Why not just use a normal variable?, I mean wouldn't have that worked in you'r example?

*Clicks reputation*
• 10-19-2004
• 10-19-2004
Tynnhammar
Hmm.. I've seen those, going to read up about Linked lists.
• 10-19-2004
Hunter2
A suggestion to mods: Perhaps the two threads could be merged and then moved to the FAQ board.
• 10-19-2004
Tynnhammar
That would be a good idea, I know alot more people than I have problems with pointers.
• 10-20-2004
13th Phazer
Well, NeHe is definitly the best and I started OpenGL about a half year ago with his stuff and am now attempting my own game... dunno how it will go, but the graphics are not the problem! As for pointers, my main use with them is for functions.

As in, if you had a function that maby looked like this:
Code:

```void function(huge_class class) { //do stuff }```
huge_class does not necessarily need to be class, but lets pretend that it is something that is quite large. In this situation when you call function() it would COPY the entire huge_class that you pass to it, which is very ineffective. Something far more effective is the following function:

Code:

```void function(huge_class *class) { //do stuff }```
This allows for the computer to only have to copy the pointer to the huge class (which is very small) instead of the entire class. This also allows for the function to directly modify the huge_class that *class is pointing to, which can be a good thing for functions to do (no need for a return type in some cases). I hope this helps, and is definatly not the only purpose of pointers, but a substantial one.
• 10-21-2004
Tynnhammar
Thank you all for being so helpful :).