1 /**
2  * Copyright:   Copyright (C) 2018 Gabriel Gheorghe, All Rights Reserved
3  * Authors:     $(Gabriel Gheorghe)
4  * License:     $(LINK2 https://www.gnu.org/licenses/gpl-3.0.txt, GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007)
5  * Source:      $(LINK2 https://github.com/GabyForceQ/LibertyEngine/blob/master/source/liberty/graphics/video/buffer.d, _buffer.d)
6  * Documentation:
7  * Coverage:
8  */
9 module liberty.graphics.video.buffer;
10 /// Represents the target to which the buffer object is bound.
11 enum BufferTarget : byte {
12 	/// Vertex attributes.
13 	Array = 0x00,
14 	/// Atomic counter storage.
15 	AtomicCounter = 0x01,
16 	/// Buffer copy source.
17 	CopyRead = 0x02,
18 	/// Buffer copy destination.
19 	CopyWrite = 0x03,
20 	/// Indirect compute dispatch commands.
21 	DispatchIndirect = 0x04,
22 	/// Indirect command arguments.
23 	DrawIndirect = 0x05,
24 	/// Vertex array indices.
25 	ElementArray = 0x06,
26 	/// Pixel read target.
27 	PixelPack = 0x07,
28 	/// Texture data source.
29 	PixelUnpack = 0x08,
30 	/// Query result buffer.
31 	Query = 0x09,
32 	/// Read-write storage for shaders.
33 	ShaderStorage = 0x0A,
34 	/// Texture data buffer.
35 	Texture = 0x0B,
36 	/// Transform feedback buffer.
37 	TransformFeedback = 0x0C,
38 	/// Uniform block storage.
39 	Uniform = 0x0D
40 }
41 ///
42 abstract class VideoBuffer {
43 	protected {
44         uint _buffer;
45         size_t _size;
46         uint _target;
47         uint _usage;
48         bool _firstLoad;
49         bool _initialized;
50     }
51     ///
52     size_t size() pure const nothrow;
53 	///
54 	void data(T)(T[] buffer) {
55 		setData(buffer.length * T.sizeof, buffer.ptr);
56 	}
57 	///
58 	void setData(size_t size, void* data);
59 	///
60 	void setSubData(size_t offset, size_t size, void* data);
61 	///
62 	void getSubData(size_t offset, size_t size, void* data);
63 	///
64 	ubyte[] bytes();
65 	///
66 	void bind();
67 	///
68 	void unbind();
69 	///
70 	uint handle() pure const nothrow;
71 }