Results 1 to 10 of 10

Thread: new to programming

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    cape coral, fl
    Posts
    2

    new to programming

    hi, im pretty new to any programming besides web programming. I know very little c++ im about 4 chapters into my book and i was wondering if i would be able to learn opengl without really knowing any c++?
    `k3v0

  2. #2
    Member Contributor
    Join Date
    May 2003
    Posts
    50

    Re: new to programming

    no, read the whole c++ book and make a few simple c++ consol programs, then go to nehe.gamedev.net and start at the first tutorial.

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    625

    Re: new to programming

    I don't really agree on this.
    It is something really subjective. Maybe someone will feel better by learning while "on the road".

    To tell the truth, a lot can be done with using basic C/C++, basic GL and a bunch of time to spend.

    Of curse, having C skill helps, but usually not so much.

    My personal opinion is that you need just a basic C knowledge to start using GL.

    One you got data types, ifs, pointers (a bit, some people finds 'em difficult), cicles, something about I/O and you __practiced__ it a bit you may start GL and learn while using it, if you are good at thinking... else read teh book, prac, prac, prac, read the tuts.

    PS: Always leave your book at hand however...

    EDIT: forgot you have to know a bit of dynamic memory allocation and arrays.

    [This message has been edited by Obli (edited 05-09-2003).]

  4. #4
    Guest

    Re: new to programming

    I too, am new to coding, and have grasped the first few chapters of my C++ book (I can code a math quiz) and wish to know when I should try and learn openGL or directX.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: new to programming

    No, do NOT learn all of C++ before starting OpenGL. I've been writing production C++ code for five years and there are parts of that gigantic language I haven't used yet.

    Learn the basics - classes, virtual functions, constructors, destructors. Pick up the /C++ FAQs/ book if you can...just about any question you might have about the language is in there.

    Good advice on the NeHe tutorials, though.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: new to programming

    Oh yeah...learn the C++ standard library, at the very least the std::string and std::vector classes. You will find that you can use these to replace char * strings and dynamically allocated/reallocated arrays. I'd still stick with arrays for things that have static bounds, though (like vectors, matrices, etc.).

    A good book for learning C++ is /Accelerated C++/ by Koenig and Moo.

  7. #7
    Junior Member Newbie
    Join Date
    Jun 2002
    Posts
    14

    Re: new to programming

    im also C++ noob, and i realy dont know how to use pointers. But i feel good without them. Im creating opengl fps game, with some model imports, console and other ****.

  8. #8
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: new to programming

    Pointers can be used a lot less frequently in C++ than they were in C. If you want to pass something to a function by reference, use a const reference instead of a pointer:

    void draw(const GameObject & obj);

    If you want to store text strings, use the std::string class instead of allocating (and worrying about) character pointers:

    #include <string>

    std::string WindowTitle = "My OpenGL Program";

    If you are calling functions that use take character pointers, just call the c_str() member function:

    someFunc(WindowTitle.c_str());

    If your class has to use pointers, make sure you allocate your pointer in the constructor and delete it in the destructor so you avoid memory leaks:

    MyClass::MyClass()
    {
    gameObject_ = new GameObject();
    }

    MyClass::~MyClass()
    {
    delete gameObject_;
    }

    Finally, you can use the Boost library's smart pointers if you don't want to worry about managing the memory yourself. Download them at boost.org.

    #include <boost/shared_ptr.hpp>

    boost::shared_ptr<GameObject> gameObjectPtr(new GameObject());

    Now you can pass gameObjectPtr around like you would a raw pointer to a Game Object, but you don't have to worry about who owns the pointer and who is responsible for deleting it - shared_ptr does the work for you.

  9. #9
    Junior Member Newbie
    Join Date
    Jan 2003
    Posts
    11

    Re: new to programming

    Yeah, a question about that std::string
    class, why can't it convert itself?

    I would reckon that using global operator
    overloading it would be possible to do
    something like :

    std::string number = "20.34";

    float value = atof(number);

    Or is there another way to convert strings to numbers and am I just being inefficient?

    -Red15-
    -- PIPE GREP MORE --

  10. #10
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: new to programming

    'std::string number = "20.34";

    float value = atof(number);
    '

    Actually, you would call "atof(number.c_str());" since atof() takes a char *, not a string.

Similar Threads

  1. Replies: 2
    Last Post: 07-14-2017, 12:03 AM
  2. Programming on the GPU
    By Cucus in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 07-21-2011, 08:47 AM
  3. Is OpenGL Programming Same as VRML Programming
    By grungefreak1 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 09-30-2008, 03:07 PM
  4. GUI programming
    By Brokenlynx in forum OpenGL: Windows
    Replies: 3
    Last Post: 12-07-2007, 05:50 AM
  5. OT: Programming Languages
    By Whittick in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 07-24-2000, 07:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean