diff options
Diffstat (limited to 'Runner/Graphics/VertexBuffer.h')
-rw-r--r-- | Runner/Graphics/VertexBuffer.h | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/Runner/Graphics/VertexBuffer.h b/Runner/Graphics/VertexBuffer.h deleted file mode 100644 index 33c0783..0000000 --- a/Runner/Graphics/VertexBuffer.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef VBO_H -#define VBO_H - -#include <vector> - -#include "../Utilities/UtilMacros.h" -#include "../Shaders/ShaderChannel.h" - -#include "OpenGL.h" -#include "GpuDataBuffer.h" - -enum VertexAttr -{ - VertexAttr_Position = 0, - VertexAttr_Normal = 1, - VertexAttr_Tangent = 2, - VertexAttr_Color = 3, - VertexAttr_TexCoord0 = 4, - VertexAttr_TexCoord1 = 5, - - VertexAttr_Count = 6 -}; - -enum RenderMode -{ - RenderMode_Triangle = 1, - RenderMode_Line = 2, - RenderMode_Point = 3, -}; - -struct VertexInputInfo -{ - const void* pointer; // either cpu memory or gpu memory - uint componentType; // one of VertexAttrFormat - uint componentNum; - uint16 stride; -}; - -// gpu side vertex attributes array -struct VertexArrayInfo -{ - uint32 enableMask; - GLuint buffers[VertexAttr_Count]; - VertexInputInfo attributes[VertexAttr_Count]; -}; - -class VertexBuffer -{ -public: - enum VertexBufferType - { - VertexBufferType_Static, // device - VertexBufferType_Stream, // pinned (best performance) - VertexBufferType_Dynamic,// device - }; - - VertexBuffer(VertexBufferType type); - ~VertexBuffer(); - - void Draw(); - -private: - - VertexBufferType m_Type; - GPU::DataBuffer *m_VB, *m_IB;// vertex buffer and index buffer - -}; - -class SharedVertexBuffer -{ -public: - void GetChunk(uint attrs, int maxVerts, int maxIndices, RenderMode mode, void **out_vb, void **out_ib); - void ReleaseChunk(int actualVerts, int actualIndices); - - void DrawChunk(); - -private: - - void FillVertexArrayInfo(VertexArrayInfo& dst); - - void Clean(); - - // if vertex databuffer size beyond this value, use pinned memory mapping, instead of glBufferData. - enum { DataBufferThreshold = 1024 }; - - // shared vbo and ibo - GPU::DataBuffer *m_CurVB, *m_CurIB; - - // restore vbo and ibo data if not using pinned memory mapping - std::vector<byte> m_CurVBData; - std::vector<uint16> m_CurIBData; - - RenderMode m_CurRenderMode; - - uint m_CurAttrMask; - uint m_CurStride; - - uint m_CurVertexCount; - uint m_CurIndexCount; - -}; - -#endif
\ No newline at end of file |