Results 1 to 2 of 2

Thread: 3d Struct tutorial

  1. #1
    Junior Member Newbie
    Join Date
    May 2001
    Posts
    25

    3d Struct tutorial

    Anyone know where I can find a tutorial on creating/using the struct command to create classes for 3d object information?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    431

    Re: 3d Struct tutorial

    A struct in C++ is the same as a class except that all members are public by default (whereas a class has private members by default). struct and class are almost synonyms in C++. A struct can have constructors, destructors, operators, private members, everything that a class has. If you don't write them yourself, the compiler does it for you anyway (same as a class).

    If your question is how do I design a class for holding 3D objects, then I'd suggest using encapsulation: start with a vertex class with three floats and necessary operations. Next a triangle class with three vertices either in a container or three separate vertices and the necessary operations for triangles. Lastly you could have an object class that encapsulates a container of triangles, plus the necessary operations. If you want, you can add information to the triangle like normals, etc depending on what you want to do.

    If you don't know anything about classes in C++ (or structs in C or C++) I'd suggest before thinking about OpenGL you spend some time with a good C/C++ book learning about them - you'll need it.

    Hope that helps

    [This message has been edited by ffish (edited 05-09-2001).]

Similar Threads

  1. How to use struct in OpenCL
    By bokibo in forum OpenCL
    Replies: 3
    Last Post: 03-05-2018, 05:00 AM
  2. OpenCL struct bug?
    By Gadersd in forum OpenCL
    Replies: 1
    Last Post: 02-24-2015, 05:08 AM
  3. NeHe tutorial on Bitmap Fonts (tutorial 13) error
    By Mariusz in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-03-2012, 09:16 AM
  4. varying struct?
    By knackered in forum OpenGL: GLSL
    Replies: 4
    Last Post: 04-24-2011, 02:08 PM
  5. struct and interpolants
    By adamvanner in forum OpenGL: GLSL
    Replies: 9
    Last Post: 01-11-2011, 06:32 PM

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