@Hybrid: I'm not sure I understand what you mean in your post. What does "some simple vertex array and buffer properties" mean?
I agree, that exposure of the underlying API-interfaces is a bad idea. Did someone propose this?
@Spintz: Imho your implementation doesn't go far enough. It doesn't allow a free format and it still uses the differen fixed SVertex-Types.
I've basically the same objections, EmmanuelD voiced in his post.
Here is a small mock-up I just made up, so no all-things-figured-out proposal...
Code: Select all
typedef enum {EVET_POSITION, EVET_NORMAL, EVET_TEXCOORD_2D, ...} VertexElementType;
// SXXX because it can be implemented in a header and be used for all
// drivers..
class SVertexDefinition
{
public:
u8 getNumElements() const;
VertexElementType getElementType(u8 elementIndex) const;
u8 getElementOffset(u8 elementIndex) const;
u8 getOffsetByType(VertexElementType) const;
u8 getSize() const; // in byte for the whole vertex
void clear();
void addElement(VertexElementType)
bool operator==(const SVertexDefinition& ) const; // important for checking buffer compatiblity
....
private:
// implementation details, for instance a single or a pair of arrays for
// type and offset.
};
class IVertexBuffer : public IUnknown
{
public:
virtual SVertexDefinition* getVertexDefinition() const;
virtual void* lock();
virtual void unlock();
virtual u32 getSize() const;
};
Of course you can still cast the void* to SVertex*, if your layout matches the accordant E_VERTEX_TYPE.
One might argue, that thus irrlicht will get more difficult to use, but I don't believe this to be true. Multiple reasons: First, this affects only the deeper end of irrlicht. The beginner doesn't come in touch with vertex buffers really, as he uses the ISceneNode interfaces rather than direct buffers. Users that do are used to handle pointers themself.
Second, while this is less safe than SVertex, it is in the end easier to program with. You can now handle all vertex types the same. If some element type you would handle is not there, you ommit it, if all you want to do is to update position, then you can do it for all thinkable vertex formats without distinguish between them.