Unofficial OpenGL Software Development Kit: C:/Projects/distro/glsdk_0_5_1/glmesh/include/glmesh/CpuDataWriter.h Source File

Unofficial OpenGL Software Development Kit 0.5.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CpuDataWriter.h
Go to the documentation of this file.
1
2 #ifndef GLSDK_MESH_CPU_DATA_WRITER_H
3 #define GLSDK_MESH_CPU_DATA_WRITER_H
4
10 #include <vector>
11 #include "VertexWriter.h"
12
13 namespace glmesh
14 {
17
19 class CpuDataException : public std::exception
20 {
21 public:
22 virtual ~CpuDataException() throw() {}
23
24 virtual const char *what() const throw() {return message.c_str();}
25
26 protected:
27 std::string message;
28 };
29
31 class IncompleteVertexException : public CpuDataException
32 {
33 public:
34 IncompleteVertexException()
35 {
36 message = "All vertices must be complete before attempting to extract them from CpuDataWriter.";
37 }
38 };
39
41
44
64 class CpuDataWriter : public VertexWriter<CpuDataWriter>
65 {
66 public:
73 CpuDataWriter(const VertexFormat &fmt, size_t vertexReserve = 0);
74
81
82
91 void Extract(std::vector<char> &output);
92
98 std::vector<char> Copy() const;
99
118 GLuint TransferToBuffer(GLenum target, GLenum usage, GLuint bufferObject = 0) const;
120
124 size_t GetNumVerticesWritten() const {return m_numVerticesWritten;}
125
126 private:
127 std::vector<char> m_tempBuffer;
128 std::vector<char> m_data;
129 const VertexFormat &m_fmt;
130 size_t m_numVerticesWritten;
131
132 void *GetPtrForAttrib(size_t currAttrib);
133
134 friend class VertexWriter<CpuDataWriter>;
135 const VertexFormat &GetVertexFormat() const {return m_fmt;}
136 void WriteAttribute( const void *pData, size_t bytesPerComponent, size_t currAttrib );
137 };
138
140 }
141
142 #endif //GLSDK_MESH_CPU_DATA_WRITER_H