# NewHeGL Framework

This topic is 3713 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

[New thread so I can go further OT] Caste, Your making me learn NameSpaces.. :-P Now here's a little trick for you. I like how you made the 'Vertex' struct, but we can carry it one step further. I saw something similar in a game-engine once, so try it out! [cool] Just #include "types.h" and you can use 'Vertex' like you already did, or 'Color3' or 'Color4'. When you need a new type or alias, just add it here and your golden! ( Time IS the great equalizer... ) types.h ---------------
namespace NeHe {
/*
* Holds a 3-coordinante point.
* Usefull for Vertices and colors.
*/
struct Point3f
{
float x, y, z;
Point3f(float x, float y, float z)
{
this->x = x;
this->y = y;
this->z = z;
}
};

/*
* Holds a 4-coordinante point.
* Usefull for colors-with-alpha.
*/
struct Point4f
{
float x, y, z, a;
Point4f(float x, float y, float z, float a)
{
this->x = x;
this->y = y;
this->z = z;
this->a = a;
}
};

// Make some convienent aliases
typedef Point3f Vertex;
typedef Point3f Color3;
typedef Point4f Color4;
}


--------------- [Edited by - ravenslay3r on July 22, 2008 11:56:26 PM]

##### Share on other sites
Hey,

well as this would be reasonable in a bigger project, you need to take care of the audience we're writing these tutorials for: from complete programming beginners to people who know programming but want to learn OpenGL.

Especially for complete beginners it's probably better not to have 20 headers but only three..
But I'll talk to Kazade about that, because we'll need texcoords in lesson 05 and this one needs its own struct.. Thx for the hint!

Cheers
Carsten

##### Share on other sites
Hey whatever floats your boat. Target-audience IS an important factor here, and I agree whole-heartedly with keeping it as simple as possible.

To play devil's advocate, the point of abstraction is to hide things the user doesn't need to fully understand "right now", allowing them to focus on what is important - in this case OpenGL. That's exactly what a header like types.h does.

By pulling out those struct definitions, each weeks tutorial-code is clearer and more concise. You get to define the struct once instead of weekly, the user can skim it once instead of learning it weekly. As a bonus we get to build vertice's with "Vertex" and colors with "Color3" which is just plain intuitive to me.

Best Regards,
Raven

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
frob
13

• 9
• 9
• 23
• 16
• 9
• ### Forum Statistics

• Total Topics
632610
• Total Posts
3007402

×