回答編集履歴

3

文言

2021/05/21 14:17

投稿

int32_t
int32_t

スコア20884

test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- もし自分が仕事でOpenGLを扱うことになったら、以下のような [RAII](https://ja.wikipedia.org/wiki/RAII) クラスを作ると思います。
5
+ もし自分がC++でOpenGLを扱うことになったら、以下のような [RAII](https://ja.wikipedia.org/wiki/RAII) クラスを作ると思います。
6
6
 
7
7
 
8
8
 

2

RAII

2021/05/21 14:17

投稿

int32_t
int32_t

スコア20884

test CHANGED
@@ -1 +1,47 @@
1
1
  `glGenTextures(1, &ch.textureID)` に対応する `glDeleteTextures()` がないからでは。
2
+
3
+
4
+
5
+ もし自分が仕事でOpenGLを扱うことになったら、以下のような [RAII](https://ja.wikipedia.org/wiki/RAII) クラスを作ると思います。
6
+
7
+
8
+
9
+ ```c++
10
+
11
+ class ScopedTexture {
12
+
13
+ public:
14
+
15
+ ScopedTexture() {
16
+
17
+ glGenTextures(1, &texture_);
18
+
19
+ }
20
+
21
+ ~ScopedTexture() {
22
+
23
+ glDeleteTextures(1, &texture_);
24
+
25
+ }
26
+
27
+ ScopedTexture(const ScopedTexture&) = delete;
28
+
29
+ ScopedTexture& operator=(const ScopedTexture&) = delete;
30
+
31
+
32
+
33
+ Bind(GLenum target) {
34
+
35
+ glBindTexture(target, texture_);
36
+
37
+ }
38
+
39
+
40
+
41
+ private:
42
+
43
+ GLuint texture_;
44
+
45
+ };
46
+
47
+ ```

1

文言

2021/05/21 14:16

投稿

int32_t
int32_t

スコア20884

test CHANGED
@@ -1 +1 @@
1
- `glDeleteTextures()` を呼んでいないからでは。
1
+ `glGenTextures(1, &ch.textureID)` に対応する `glDeleteTextures()` ないからでは。