// Copyright (C) 2002-2012 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #pragma once #include #include "IVertexBuffer.h" namespace irr { namespace scene { //! Template implementation of the IVertexBuffer interface template class CVertexBuffer final : public IVertexBuffer { public: //! Default constructor for empty buffer CVertexBuffer() { #ifdef _DEBUG setDebugName("CVertexBuffer"); #endif } const void *getData() const override { return Data.data(); } void *getData() override { return Data.data(); } u32 getCount() const override { return static_cast(Data.size()); } video::E_VERTEX_TYPE getType() const override { return T::getType(); } const core::vector3df &getPosition(u32 i) const override { return Data[i].Pos; } core::vector3df &getPosition(u32 i) override { return Data[i].Pos; } const core::vector3df &getNormal(u32 i) const override { return Data[i].Normal; } core::vector3df &getNormal(u32 i) override { return Data[i].Normal; } const core::vector2df &getTCoords(u32 i) const override { return Data[i].TCoords; } core::vector2df &getTCoords(u32 i) override { return Data[i].TCoords; } E_HARDWARE_MAPPING getHardwareMappingHint() const override { return MappingHint; } void setHardwareMappingHint(E_HARDWARE_MAPPING NewMappingHint) override { MappingHint = NewMappingHint; } void setDirty() override { ++ChangedID; } u32 getChangedID() const override { return ChangedID; } void setHWBuffer(void *ptr) const override { HWBuffer = ptr; } void *getHWBuffer() const override { return HWBuffer; } u32 ChangedID = 1; //! hardware mapping hint E_HARDWARE_MAPPING MappingHint = EHM_NEVER; mutable void *HWBuffer = nullptr; //! Vertices of this buffer std::vector Data; }; //! Standard buffer typedef CVertexBuffer SVertexBuffer; //! Buffer with two texture coords per vertex, e.g. for lightmaps typedef CVertexBuffer SVertexBufferLightMap; //! Buffer with vertices having tangents stored, e.g. for normal mapping typedef CVertexBuffer SVertexBufferTangents; } // end namespace scene } // end namespace irr