]> git.sesse.net Git - casparcg/blob - accelerator/ogl/util/buffer.h
c60a0c0fa935a56c65a97b1421bb2fb86b76969f
[casparcg] / accelerator / ogl / util / buffer.h
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\r
5 *\r
6 * CasparCG is free software: you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation, either version 3 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * CasparCG is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #pragma once\r
23 \r
24 #include <common/memory.h>\r
25 #include <common/enum_class.h>\r
26 \r
27 #include <cstdint>\r
28 \r
29 namespace caspar { namespace accelerator { namespace ogl {\r
30                         \r
31 class buffer sealed\r
32 {\r
33         buffer(const buffer&);\r
34         buffer& operator=(const buffer&);\r
35 public:\r
36 \r
37         // Static Members\r
38 \r
39         struct usage_def\r
40         {\r
41                 enum type\r
42                 {\r
43                         write_only,\r
44                         read_only\r
45                 };\r
46         };\r
47         typedef enum_class<usage_def> usage;\r
48         \r
49         // Constructors\r
50 \r
51         buffer(std::size_t size, usage usage);\r
52         buffer(buffer&& other);\r
53         ~buffer();\r
54 \r
55         // Methods\r
56 \r
57         buffer& operator=(buffer&& other);\r
58         \r
59         void map();\r
60         void unmap();\r
61 \r
62         void bind() const;\r
63         void unbind() const;\r
64 \r
65         // Properties\r
66 \r
67         uint8_t* data();\r
68         std::size_t size() const;       \r
69 \r
70         int id() const;\r
71 \r
72 private:\r
73         struct impl;\r
74         spl::unique_ptr<impl> impl_;\r
75 };\r
76 \r
77 }}}