CrossFramework Library
|
00001 00006 #if defined(XG3D_INCLUDED_VERTEXBUFFER_HPP) 00007 #else 00008 #define XG3D_INCLUDED_VERTEXBUFFER_HPP 00009 00010 //------------------------------------------------------------ 00011 #include <XBase/Color4.hpp> 00012 #include <XBase/IAllocator.hpp> 00013 #include <XBase/Matrix34.hpp> 00014 #include <XBase/NonCopyable.hpp> 00015 #include <XBase/RuntimeMArray.hpp> 00016 #include <XBase/Vector2.hpp> 00017 #include <XBase/Vector3.hpp> 00018 #include <XBase/Vector4.hpp> 00019 #include <XG3D/BuiltInTypes.hpp> 00020 #include <XG3D/Engine.hpp> 00021 #include <XG3D/PrimitiveKind.hpp> 00022 00023 #if defined(XG3D_ENGINE_GLSERIES) 00024 #include <XG3D/VertexBuffer_GL.hpp> 00025 #endif 00026 00027 //------------------------------------------------------------ 00028 namespace XG3D { 00030 00031 00037 class VertexBuffer : public ::XBase::NonCopyable 00038 { 00039 public: 00041 00042 00048 VertexBuffer( 00049 uint aMeshCountMax 00050 , uint aVertexCountMax 00051 , ::XBase::IAllocator& aAllocator = ::XBase::IAllocator::Default() 00052 ); 00053 00055 ~VertexBuffer(); 00057 00059 00060 void reset(); 00061 void clear(); 00062 00063 00065 00066 00074 void worldMtx( const ::XBase::Matrix34POD& aMtx ); 00076 00078 00079 00080 void begin( PrimitiveKind aKind ); 00081 00083 void end(); 00085 00087 00088 void normal( f32 aX , f32 aY , f32 aZ ); 00089 void normal( const ::XBase::Vector3POD& aXYZ ); 00090 void texCoord( f32 aS , f32 aT ); 00091 void texCoord( const ::XBase::Vector2POD& aST ); 00092 void color( f32 aR , f32 aG , f32 aB ); 00093 void color( f32 aR , f32 aG , f32 aB , f32 aA ); 00094 void color( const ::XBase::Color4POD& aRGBA ); 00095 void vertex( f32 aX , f32 aY ); 00096 void vertex( f32 aX , f32 aY , f32 aZ ); 00097 void vertex( const ::XBase::Vector2POD& aXY ); 00098 void vertex( const ::XBase::Vector3POD& aXYZ ); 00099 00100 00102 00103 00109 void flush(); 00110 00116 void draw(); 00117 00122 void draw( const ::XBase::Matrix34POD& aViewMtx ); 00123 00125 00126 private: 00127 struct Vertex 00128 { 00129 ::XBase::Vector3POD position; 00130 ::XBase::Vector3POD normal; 00131 ::XBase::Vector2POD texCoord; 00132 ::XBase::Color4POD color; 00133 }; 00134 struct Mesh 00135 { 00136 ::XBase::Matrix34 worldMtx; 00137 uint beginIndex; // 頂点追加中は頂点の開始index。終了後はelementの開始index。 00138 uint count; // 頂点追加中は頂点の個数。終了後はelementの個数。 00139 PrimitiveKind kind; 00140 }; 00141 typedef u16 Index; 00142 //------------------------------------------------------------ 00143 ::XBase::RuntimeMArray< Vertex > mVertexArray; 00144 ::XBase::RuntimeMArray< Index > mIndexArray; 00145 ::XBase::RuntimeMArray< Mesh > mMeshArray; 00146 VertexBuffer_EXT mEXT; 00147 ::XBase::Matrix34 mWorldMtx; 00148 ::XBase::Vector3 mNormal; 00149 ::XBase::Vector2 mTexCoord; 00150 ::XBase::Color4 mColor; 00151 bool mIsMeshActive; 00152 bool mIsFlushed; 00153 }; 00155 } 00156 //------------------------------------------------------------ 00157 #endif 00158 // EOF