Thread: Preknownlegdes before OpenGL

  1. #1
    Interested Newbie
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    51

    Question 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?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    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.

  3. #3
    Interested Newbie
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    51
    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*

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595

  5. #5
    Interested Newbie
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    51
    Hmm.. I've seen those, going to read up about Linked lists.

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    A suggestion to mods: Perhaps the two threads could be merged and then moved to the FAQ board.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #7
    Interested Newbie
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    51
    That would be a good idea, I know alot more people than I have problems with pointers.

  8. #8
    Registered User
    Join Date
    Oct 2004
    Posts
    4
    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.

  9. #9
    Interested Newbie
    Join Date
    Sep 2004
    Location
    Sweden
    Posts
    51
    Thank you all for being so helpful .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM