summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/gpu_buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/modules/asura-core/graphics/gpu_buffer.h')
-rw-r--r--source/modules/asura-core/graphics/gpu_buffer.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/source/modules/asura-core/graphics/gpu_buffer.h b/source/modules/asura-core/graphics/gpu_buffer.h
new file mode 100644
index 0000000..aba1157
--- /dev/null
+++ b/source/modules/asura-core/graphics/gpu_buffer.h
@@ -0,0 +1,69 @@
+#ifndef __ASURA_GPU_BUFFER_H__
+#define __ASURA_GPU_BUFFER_H__
+
+#include <asura-utils/exceptions/exception.h>
+#include <asura-utils/type.h>
+
+#include "gl.h"
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ enum BufferType
+ {
+ BUFFER_TYPE_VERTEX, ///< 㻺
+ BUFFER_TYPE_INDEX, ///<
+ };
+
+ enum BufferUsage
+ {
+ BUFFER_USAGE_STREAM, ///< ޸һΣʹô
+ BUFFER_USAGE_DYNAMIC, ///< ޸һΣʹ
+ BUFFER_USAGE_STATIC, ///< ޸ĺʹ
+ };
+
+ ///
+ /// GPU壬ֶ㻺֣ÿζڴԴϴݡ
+ ///
+ class GPUBuffer
+ {
+ public:
+
+ GPUBuffer(BufferType type, BufferUsage usage, size_t size) ASURA_THROW(Exception);
+ ~GPUBuffer();
+
+ ///
+ /// ʼ\»棬ûgpu bufferԴΪdzʼΪǸ¡
+ ///
+ bool Fill(const void* data, size_t size, uint offset = 0) ASURA_THROW(Exception);
+
+ ///
+ /// 󶨵ӦĿϣͿʹˡ
+ ///
+ void Bind();
+ void UnBind();
+
+ uint GetBufferSize();
+
+ private:
+
+ GLenum mTarget;
+ GLuint mBuffer;
+ GLuint mUsage;
+ uint mSize;
+
+#if ASURA_DEBUG
+ ///
+ /// رbufferݣԴݱһ£Ժ͸Դ档
+ ///
+ byte* mData;
+#endif
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file