12345678910111213141516171819202122232425262728293031323334 |
- #ifndef STREAMBUFFER_H
- #define STREAMBUFFER_H
- #include <cstring>
- class StreamBuffer final {
- public:
- StreamBuffer(int size, int bytesPerVertex);
- StreamBuffer(const StreamBuffer& other) = delete;
- StreamBuffer(StreamBuffer&& other) = delete;
- StreamBuffer& operator=(const StreamBuffer& other) = delete;
- StreamBuffer& operator=(StreamBuffer&& other) = delete;
- void reset(int size);
- template<typename T>
- StreamBuffer& add(const T& t) {
- std::memcpy(buffer + index, &t, sizeof (t));
- index += sizeof (t);
- return *this;
- }
-
- void draw();
- private:
- int bufferSize;
- int offset;
- int bytesPerVertex;
- int index;
- char* buffer;
- };
- #endif
|