#pragma once
#include "3D/Enums.h"

#ifdef GUI_WIN32

namespace gui {

	class D3DBuffer {
	public:
		// Create from a pointer.
		D3DBuffer(Engine &e, ID3D10Device *device, UINT bindFlags, BufferUsage usage, const void *data, size_t size);

		// The buffer itself.
		ComPtr<ID3D10Buffer> buffer;

		// Bind flags.
		UINT bindFlags;

		// Current size of the buffer.
		size_t size;

		// Currrent usage of the buffer.
		BufferUsage usage;

		// Update the buffer.
		void update(Engine &e, BufferUsage usage, const void *data, size_t size, size_t dirtyFrom, size_t dirtyTo);

		// Cleanup.
		static void cleanup(void *mem) {
			delete (D3DBuffer *)mem;
		}

	private:
		// (re-)create the buffer.
		void create(Engine &e, ID3D10Device *device, BufferUsage usage, const void *data, size_t size);
	};

}

#endif
