Oscar
Oscar

Reputation: 2102

Is it always good to use Vec3f / Vec4f class defined by yourself?

A question about coding style: When you're going to reconstruct a virtural scene containing plenty of objects (Using JOGL), is it always good to define a Vec3f class and face class representing the vertices, normals, and faces rather than to directly use float[] type? Any ideas?

Upvotes: 0

Views: 416

Answers (1)

ratchet freak
ratchet freak

Reputation: 48196

Many people go step further and create a Vertex POD object of type:

struct Vertex{
    vec4 position;
    vec4 normal;
    vec2 texture;
}

Then the stride is simply sizeof(Vertex), and the offsets can be extracted using a offsetof macro. This leads to a more robust setup when passing the data.

Upvotes: 1

Related Questions