teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

10

提示コードを修正

2022/02/01 01:27

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -22,7 +22,7 @@
22
22
  ソースコード全文: https://github.com/Shigurechan/AAEditor/tree/e0db42df3945fc1e1ea9879e2746ffe5eeedf9f2
23
23
 
24
24
 
25
- ###### Camera
25
+ ##### Camera
26
26
  ```cpp
27
27
 
28
28
  // ##################################### 初期化 #####################################
@@ -361,6 +361,75 @@
361
361
 
362
362
  ```
363
363
 
364
+ ##### Chracter
365
+ ```cpp
366
+ #include "Character.hpp"
364
367
 
368
+ Character::Character(glm::vec2 pos,int pixel)
369
+ {
370
+ position = pos;
371
+ character = '\0';
372
+ pixelSize = pixel;
373
+ }
365
374
 
375
+ void Character::setCharacter(const char ch)
376
+ {
377
+ character = ch;
378
+ DeleteCharacterTexture(texture);
379
+ texture = FrameWork::GenCharacterTexture("Asset/font/PressStart2P.ttf", pixelSize, FrameWork::GetRGBAColor(glm::vec4(0, 255, 0, 255)), "%c",ch);
380
+ }
366
381
 
382
+ void Character::Resize(int pixel)
383
+ {
384
+ pixelSize = pixel;
385
+ DeleteCharacterTexture(texture);
386
+ texture = FrameWork::GenCharacterTexture("Asset/font/PressStart2P.ttf", pixelSize, FrameWork::GetRGBAColor(glm::vec4(0, 255, 0, 255)), "%c", character);
387
+ }
388
+
389
+
390
+
391
+ glm::ivec2 Character::getPosition()
392
+ {
393
+ return position;
394
+ }
395
+
396
+ FrameWork::CharacterTexture* Character::getTexture()
397
+ {
398
+ return &texture;
399
+ }
400
+
401
+ void Character::Update()
402
+ {
403
+
404
+ }
405
+
406
+ void Character::Renderer(const glm::ivec2 pos,const glm::mat4 view)const
407
+ {
408
+ switch(character)
409
+ {
410
+
411
+ case 0x28: // (
412
+ {
413
+
414
+ }
415
+ break;
416
+
417
+ case 0x29: // )
418
+ {
419
+
420
+ }
421
+ break;
422
+
423
+
424
+ default:
425
+ {
426
+
427
+ }
428
+ break;
429
+
430
+ }
431
+ }
432
+ ```
433
+
434
+
435
+

9

文章を修正

2022/02/01 01:26

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,13 +1,8 @@
1
- 提示コードですがEntryクラスのコンストラクタ部で下のエラーglgetError:0x502が表示されます原因がわりません。
1
+ 提示コードですがcamera->RendererBuffer()部で下のエラーますこれは何が原因なのでしょう
2
2
 
3
- ##### 知りたい事
4
- A,Bクラスがどういった影響を受けいるのかわかりません。
5
-
6
3
  ##### 現状
7
- 提示コードEntryコンストラクタ部ですがA,Bの中身は提示の通りです。
8
- Aクラスをコメントアウトするとエラーが出ません。普通に動きます
9
- AをコメントアウトしないでBクラスのcamra->RendererBuffer();関数をコメントアウトすると動きます。
4
+ Camera->RendererBuffer()をコメントアウトすると普通にくのでが他のクラスでこの関数を使うとエラーにはなりません
10
- Aクラスのコンストラクタ部のlayer変数部をコメントアウトすと普通に動きます。
5
+ これは何が影響していのでしょうか?
11
6
 
12
7
 
13
8
  glGetError: https://qiita.com/_ydah/items/da56763e94ba58af3d91
@@ -27,160 +22,265 @@
27
22
  ソースコード全文: https://github.com/Shigurechan/AAEditor/tree/e0db42df3945fc1e1ea9879e2746ffe5eeedf9f2
28
23
 
29
24
 
30
- ##### Entry
25
+ ###### Camera
31
26
  ```cpp
32
27
 
28
+ // ##################################### 初期化 #####################################
33
- Entry::Entry() : Scene(Scene::SceneType::Entry)
29
+ FrameWork::Camera::Camera()
34
- {
30
+ {
35
- ///////////////////////////////////////////////////////////////////////////////////////////////
36
- title = std::make_unique<Title>();//A
37
- edit = std::make_unique<Edit>();//B
38
- ////////////////////////////////////////////////////////////////////////////////////////////////
39
31
 
40
- scene = SceneType::Edit;
41
- //scene = SceneType::Title;
32
+ // レンダリングポリゴン
33
+ glGenVertexArrays(1, &quadVAO);
42
- }
34
+ glGenBuffers(1, &quadVBO);
43
35
 
36
+ shader = std::make_shared<FrameWork::Shader>();
37
+
38
+ shader->Load("Asset/shader/FrameBuffer.vert", "Asset/shader/FrameBuffer.frag");
39
+
40
+ shader->setEnable();
41
+ glBindVertexArray(quadVAO);
42
+ glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
43
+
44
+ glBufferData(GL_ARRAY_BUFFER, 24 * sizeof(float), &quad, GL_STATIC_DRAW);
45
+
46
+ GLuint attrib = shader->getAttribLocation("vertexPosition");
47
+ glEnableVertexAttribArray(attrib);
48
+ glVertexAttribPointer(attrib, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0);
49
+ shader->setBindAttribLocation("vertexPosition");
50
+
51
+ attrib = shader->getAttribLocation("vertexUV");
52
+ glEnableVertexAttribArray(attrib);
53
+ glVertexAttribPointer(attrib, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float)));
54
+ shader->setBindAttribLocation("vertexUV");
55
+
56
+ shader->setDisable();
44
- void Entry::Loop()
57
+ glBindVertexArray(0);
58
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
59
+
60
+
61
+
45
- {
62
+ //MSAA バッファ
63
+ glGenFramebuffers(1, &frameBufferFBO);
64
+ glBindFramebuffer(GL_FRAMEBUFFER, frameBufferFBO);
65
+ glGenTextures(1, &frameBuffer);
66
+ glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, frameBuffer);
67
+ glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGB, windowContext->getSize().x, windowContext->getSize().y, GL_TRUE);
68
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, frameBuffer, 0);
69
+
70
+
71
+ //レンダリングバッファ
72
+ glGenRenderbuffers(1, &rbo);
73
+ glBindRenderbuffer(GL_RENDERBUFFER, rbo);
74
+ glRenderbufferStorageMultisample(GL_RENDERBUFFER, 8, GL_DEPTH24_STENCIL8, windowContext->getSize().x, windowContext->getSize().y);
75
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
76
+
77
+ //MSAA アタッチ
78
+ GLuint attachment = GL_COLOR_ATTACHMENT0;
46
- switch(scene)
79
+ glDrawBuffers(1,&attachment);
80
+
81
+
82
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
47
83
  {
48
- case SceneType::Title:
84
+ std::cerr << "Framebuffer is not complete: 0x" << glCheckFramebufferStatus(GL_FRAMEBUFFER) << std::endl;
49
- {
50
- title->Loop();
85
+ assert(0);
86
+ }
87
+ glBindFramebuffer(GL_FRAMEBUFFER,0);
51
88
 
52
- if (title->getSceneType() != SceneType::Title)
53
- {
54
- scene = title->getSceneType();
55
89
 
56
- switch (scene)
90
+ //深度マップ
57
- {
91
+ glGenFramebuffers(1, &depthMapFBO);
92
+ glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
58
- case SceneType::Edit:
93
+ glGenTextures(1, &depthMap);
59
- {
60
- edit = std::make_unique<Edit>();
94
+ glBindTexture(GL_TEXTURE_2D, depthMap);
95
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, windowContext->getSize().x, windowContext->getSize().y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
61
- }
96
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
97
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
62
- break;
98
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
99
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
100
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap, 0);
63
101
 
64
- }
65
- }
66
-
67
- }
68
- break;
102
+ //カラーバッファ
103
+ glGenFramebuffers(1, &colorBufferFBO);
104
+ glBindFramebuffer(GL_FRAMEBUFFER, colorBufferFBO);
105
+ glGenTextures(1, &colorBuffer);
106
+ glBindTexture(GL_TEXTURE_2D, colorBuffer);
107
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, windowContext->getSize().x, windowContext->getSize().y, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
108
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
109
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
110
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorBuffer, 0); // we only need a color buffer
69
111
 
70
112
 
71
- case SceneType::Edit:
72
- {
73
-
74
- edit->Loop();
75
113
 
76
- if (scene != SceneType::Title)
77
- {
78
- scene = edit->getSceneType();
79
114
 
80
- switch (scene)
81
- {
82
- case SceneType::Title:
83
- {
84
- title = std::make_unique<Title>();
115
+ position = glm::vec3(0,0,0.5); //座標
85
- }
86
- break;
116
+ vecLook = glm::vec3(0,0,-1); //向き
87
117
 
88
- }
118
+ setPosition(position);
89
- }
90
- }
91
- break;
119
+ setLook(vecLook);
92
120
 
93
- }
94
121
  }
95
122
 
96
123
 
124
+ // ##################################### スカイボックスを設定 #####################################
125
+ void FrameWork::Camera::setSkyBox(GLuint tex)
97
- ```
126
+ {
98
127
 
99
- ##### A クラス内部
100
- ```cpp
128
+ }
101
- #include "Title_Menu.hpp"
102
- #include "Layer.hpp"
103
129
 
104
- #include <FrameWork.hpp>
105
130
 
131
+ // ##################################### 描画 #####################################
106
- Title_Menu::Title_Menu() : Actor()
132
+ void FrameWork::Camera::View(std::shared_ptr<Actor> actor)
107
133
  {
108
- //renderer = std::make_shared<FrameWork::Text>();
109
- layer = std::make_shared<Layer>(glm::ivec2(18,32),25);
110
134
 
135
+ glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
111
- //layer->setCharacter(glm::ivec2(0,0),'A');
136
+ glViewport(0, 0, windowContext->getSize().x, windowContext->getSize().y);
112
137
 
113
- }
138
+ //actor->Renderer_Depth(getViewPerspective());
114
139
 
140
+ glBindFramebuffer(GL_FRAMEBUFFER, frameBufferFBO);
141
+ glViewport(0, 0, windowContext->getSize().x, windowContext->getSize().y);
115
142
 
143
+ glEnable(GL_DEPTH_TEST);
144
+ // actor->Renderer(getViewPerspective());
116
145
 
117
- void Title_Menu::Update()
146
+ glDepthFunc(GL_LEQUAL);
118
- {
119
147
 
148
+ actor->Renderer(getViewOrthographic());
149
+
150
+
151
+ // actor->Renderer(getViewPerspective());
152
+ glDepthFunc(GL_LESS);
153
+
154
+ glBindFramebuffer(GL_FRAMEBUFFER,0);
120
155
  }
121
156
 
157
+ // ##################################### フレームバッファ クリア #####################################
122
- void Title_Menu::Renderer(const glm::mat4 view)const
158
+ void FrameWork::Camera::ClearBuffer()
123
159
  {
160
+ glEnable(GL_DEPTH_TEST);
161
+ glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
162
+ glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
163
+ glClear(GL_DEPTH_BUFFER_BIT);
164
+ glBindFramebuffer(GL_FRAMEBUFFER, frameBufferFBO);
165
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
166
+ //glBindFramebuffer(GL_FRAMEBUFFER, 0);
167
+ }
124
168
 
169
+ // ##################################### フレームバッファ 描画 #####################################
170
+ void FrameWork::Camera::RendererBuffer()
171
+ {
172
+
173
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
174
+
175
+ glBindVertexArray(quadVAO);
176
+ glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
177
+ shader->setEnable();
178
+
179
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, frameBuffer);
180
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, colorBufferFBO);
181
+ glBlitFramebuffer(0, 0, windowContext->getSize().x, windowContext->getSize().y, 0, 0, windowContext->getSize().x, windowContext->getSize().y, GL_COLOR_BUFFER_BIT, GL_NEAREST);
182
+
183
+
184
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
185
+ shader->setUniformSampler2D("screenTexture", 0,colorBufferFBO);
186
+ glDrawArrays(GL_TRIANGLES,0,6);
187
+
188
+ shader->setDisable();
189
+ glBindVertexArray(0);
190
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
191
+
125
192
  }
126
193
 
127
194
  ```
128
- ##### Bクラス内部
195
+ ##### Title.hpp
129
- ```cpp
196
+ ```
130
- #include "Edit.hpp"
131
- #include "Canvas_Mng.hpp"
132
- #include "MenuBar_Mng.hpp"
133
- #include "Control.hpp"
134
- #include "Scene.hpp"
197
+ #include "Title.hpp"
198
+ #include <FrameWork.hpp>
199
+ #include "Title_Menu.hpp"
135
200
 
136
-
137
- Edit::Edit() : Scene(Scene::SceneType::Edit)
201
+ Title::Title() : Scene(Scene::SceneType::Title)
138
202
  {
203
+ title = std::make_shared<Title_Menu>();
139
- camera = std::make_shared<FrameWork::Camera>();
204
+ camera = std::make_unique<FrameWork::Camera>();
140
205
 
141
- control = std::make_shared<Control>();
206
+ }
142
- canvas_Mng = std::make_shared<Canvas_Mng>();
143
- menu_bar_Mng = std::make_shared<MenuBar_Mng>();
144
207
 
145
208
 
146
209
 
147
- menu_bar_Mng->setControl(control);
148
- control->setCanvas_Mng(canvas_Mng);
149
- canvas_Mng->setControl(control);
150
- }
151
-
152
- void Edit::Update()
210
+ void Title::Update()
153
211
  {
212
+ //title->Update();
154
213
 
155
- control->Update();
156
- canvas_Mng->Update();
157
- menu_bar_Mng->Update();
158
214
 
159
-
160
215
 
216
+
217
+
161
218
  }
162
219
 
163
- void Edit::Renderer()
220
+ void Title::Renderer()
164
221
  {
165
222
  camera->ClearBuffer();
166
223
 
167
-
168
- camera->View(control);
224
+ camera->View(title);
169
- camera->View(canvas_Mng);
170
- camera->View(menu_bar_Mng);
171
225
 
172
226
 
227
+ camera->RendererBuffer();
173
228
 
174
- camera->RendererBuffer();
175
229
  }
176
230
 
231
+
177
- void Edit::Loop()
232
+ void Title::Loop()
178
233
  {
179
234
  Update();
180
235
  Renderer();
181
236
  }
237
+
182
238
  ```
239
+ ##### Title_menu
240
+ ```cpp
241
+ #include "Title_Menu.hpp"
242
+ #include "Layer.hpp"
183
243
 
244
+ #include <FrameWork.hpp>
245
+
246
+ Title_Menu::Title_Menu() : Actor()
247
+ {
248
+ renderer = std::make_shared<FrameWork::Text>();
249
+ layer = std::make_shared<Layer>(glm::ivec2(18,32),25);
250
+
251
+ //layer->setCharacter(glm::ivec2(0,0),'A');
252
+
253
+ }
254
+
255
+
256
+
257
+ void Title_Menu::Update()
258
+ {
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+ }
268
+
269
+ void Title_Menu::Renderer(const glm::mat4 view)const
270
+ {
271
+ /*
272
+ for (int y = 0; y < layer->getSize().y; y++)
273
+ {
274
+ for (int x = 0; x < layer->getSize().x; x++)
275
+ {
276
+ renderer->Renderer(view,glm::ivec2(x * 25, y * 25),layer->getCharacter(glm::ivec2(x,y)).getTexture());
277
+ }
278
+ }
279
+
280
+ */
281
+ }
282
+
283
+ ```
184
284
  ##### Layer
185
285
  ```cpp
186
286
  #include "Layer.hpp"
@@ -213,17 +313,22 @@
213
313
  std::vector<Character> ch;
214
314
  for (int x = 0; x < s.x - size.x; x++)
215
315
  {
216
-
217
316
  ch.push_back(Character(glm::ivec2(size.x + x, size.y + y),pixelSize));
218
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
219
- ch.back().setCharacter(' ');
220
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
221
317
  }
222
-
223
318
  character.push_back(ch);
224
319
  }
320
+
321
+ for (int y = size.y; y < s.y; y++)
322
+ {
323
+ for (int x = size.x; x < s.x; x++)
324
+ {
325
+ character.at(y).at(x).setCharacter(' ');
326
+ }
327
+ }
225
328
  }
226
329
 
330
+
331
+
227
332
  size = s;
228
333
  }
229
334
 
@@ -256,94 +361,6 @@
256
361
 
257
362
  ```
258
363
 
259
- ##### setCharacter()関数
260
- ```cpp
261
364
 
262
- void Character::setCharacter(const char ch)
263
- {
264
- character = ch;
265
- DeleteCharacterTexture(texture);
266
- texture = FrameWork::GenCharacterTexture("Asset/font/PressStart2P.ttf", pixelSize, FrameWork::GetRGBAColor(glm::vec4(0, 255, 0, 255)), "%c",ch);
267
- }
268
365
 
269
- void Character::Resize(int pixel)
270
- {
271
366
 
272
- pixelSize = pixel;
273
- DeleteCharacterTexture(texture);
274
- texture = FrameWork::GenCharacterTexture("Asset/font/PressStart2P.ttf", pixelSize, FrameWork::GetRGBAColor(glm::vec4(0, 255, 0, 255)), "%c", character);
275
- }
276
-
277
- ```
278
-
279
- ##### Character
280
- ```cpp
281
- #include "Character.hpp"
282
-
283
- Character::Character(glm::vec2 pos,int pixel)
284
- {
285
- position = pos;
286
- character = '\0';
287
- pixelSize = pixel;
288
- }
289
-
290
- void Character::setCharacter(const char ch)
291
- {
292
- character = ch;
293
- DeleteCharacterTexture(texture);
294
- texture = FrameWork::GenCharacterTexture("Asset/font/PressStart2P.ttf", pixelSize, FrameWork::GetRGBAColor(glm::vec4(0, 255, 0, 255)), "%c",ch);
295
- }
296
-
297
- void Character::Resize(int pixel)
298
- {
299
- pixelSize = pixel;
300
- DeleteCharacterTexture(texture);
301
- texture = FrameWork::GenCharacterTexture("Asset/font/PressStart2P.ttf", pixelSize, FrameWork::GetRGBAColor(glm::vec4(0, 255, 0, 255)), "%c", character);
302
- }
303
-
304
-
305
-
306
- glm::ivec2 Character::getPosition()
307
- {
308
- return position;
309
- }
310
-
311
- FrameWork::CharacterTexture* Character::getTexture()
312
- {
313
- return &texture;
314
- }
315
-
316
-
317
- void Character::Update()
318
- {
319
-
320
- }
321
-
322
- void Character::Renderer(const glm::ivec2 pos,const glm::mat4 view)const
323
- {
324
- switch(character)
325
- {
326
-
327
- case 0x28: // (
328
- {
329
-
330
- }
331
- break;
332
-
333
- case 0x29: // )
334
- {
335
-
336
- }
337
- break;
338
-
339
-
340
- default:
341
- {
342
-
343
- }
344
- break;
345
-
346
- }
347
- }
348
- ```
349
-

8

文章を修正

2022/02/01 01:11

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- 同じクラスでもエラーになる原因が知りたい。
1
+ glGetError: 0x502が発生する原因が知りたい。
body CHANGED
File without changes

7

タイトルを修正

2022/02/01 00:32

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- 同じクラスでもエラーになる時とそうじゃない時の原因が知りたい
1
+ 同じクラスでもエラーになる原因が知りたい
body CHANGED
File without changes

6

タグを修正

2022/01/31 09:03

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
File without changes

5

タイトルを修正

2022/01/31 08:25

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- 同じクラスでも使うクラスによってエラーになる原因が知りたい
1
+ 同じクラスでもエラーになる時とそうじゃない時の原因が知りたい
body CHANGED
File without changes

4

文章を修正

2022/01/31 07:31

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -276,92 +276,74 @@
276
276
 
277
277
  ```
278
278
 
279
- ##### FrameWork::GenCharacterTexture
279
+ ##### Character
280
280
  ```cpp
281
- // ##################################### 単一テクスチャ 生成 #####################################
281
+ #include "Character.hpp"
282
+
282
- FrameWork::CharacterTexture FrameWork::GenCharacterTexture(const char* fontPath, int pixelSize, glm::vec4 color, const char* args, ...)
283
+ Character::Character(glm::vec2 pos,int pixel)
283
284
  {
285
+ position = pos;
284
- std::vector<char> charText(sizeof(args), '\0');
286
+ character = '\0';
285
- wchar_t wcharText;
287
+ pixelSize = pixel;
288
+ }
286
289
 
287
- //書式指定文字列に変換
288
- va_list va;
289
- va_start(va, args);
290
- //int er = vsprintf_s(charText.data(), charText.size(), args, va);
291
- int er = vsprintf(charText.data(), args, va);
290
+ void Character::setCharacter(const char ch)
291
+ {
292
+ character = ch;
293
+ DeleteCharacterTexture(texture);
294
+ texture = FrameWork::GenCharacterTexture("Asset/font/PressStart2P.ttf", pixelSize, FrameWork::GetRGBAColor(glm::vec4(0, 255, 0, 255)), "%c",ch);
295
+ }
292
296
 
293
- if (er < 0)
297
+ void Character::Resize(int pixel)
294
- {
298
+ {
299
+ pixelSize = pixel;
300
+ DeleteCharacterTexture(texture);
295
- std::cerr << "GenCharacterTexture() Error: vsprintf_s(): " << er << std::endl;
301
+ texture = FrameWork::GenCharacterTexture("Asset/font/PressStart2P.ttf", pixelSize, FrameWork::GetRGBAColor(glm::vec4(0, 255, 0, 255)), "%c", character);
296
- assert(0);
297
- }
302
+ }
298
- va_end(va);
299
303
 
300
- mbrtowc(&wcharText, &charText.at(0), (size_t)MB_CUR_MAX, nullptr);//wchar_t型文字を生成
301
304
 
302
- //printf("%c\n",charText.at(0));
303
305
 
304
- FT_Face face = LoadFont(fontPath); //フォントをロード
306
+ glm::ivec2 Character::getPosition()
307
+ {
308
+ return position;
309
+ }
305
310
 
311
+ FrameWork::CharacterTexture* Character::getTexture()
312
+ {
313
+ return &texture;
314
+ }
306
315
 
307
- FT_Error err = FT_Set_Pixel_Sizes(face, 0, pixelSize);
308
- if (err != 0)
309
- {
310
- std::cerr << "FrameWork::getGenCharacterTexture() Error: FT_Set_Pixel_Sizes: " << err << std::endl;
311
- assert(0);
312
316
 
317
+ void Character::Update()
318
+ {
319
+
313
- }
320
+ }
314
321
 
315
- err = FT_Load_Glyph(face, FT_Get_Char_Index(face, wcharText), FT_LOAD_RENDER);
322
+ void Character::Renderer(const glm::ivec2 pos,const glm::mat4 view)const
316
- if (err != 0)
317
- {
323
+ {
318
- std::cerr << "FrameWork::getGenCharacterTexture() Error: FT_Load_Glyph: " << err << std::endl;
319
- assert(0);
324
+ switch(character)
325
+ {
320
326
 
327
+ case 0x28: // (
321
- }
328
+ {
322
329
 
330
+ }
331
+ break;
323
332
 
324
- CharacterTexture ch =
333
+ case 0x29: // )
325
- {
334
+ {
326
- 0,
327
- glm::lowp_u8vec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),
328
- glm::lowp_u8vec2(face->glyph->bitmap_left, face->glyph->bitmap_top),
329
- (unsigned short)face->glyph->advance.x,
330
- wcharText,
331
- color,
332
- pixelSize,
333
- glm::vec2(1.0f,1.0f),
334
335
 
335
- };
336
+ }
337
+ break;
336
338
 
337
- glGenTextures(1, &ch.textureID);
338
- glBindTexture(GL_TEXTURE_2D, ch.textureID);
339
- glActiveTexture(GL_TEXTURE0);
340
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
341
- glTexImage2D
342
- (
343
- GL_TEXTURE_2D,
344
- 0,
345
- GL_RED,
346
- face->glyph->bitmap.width,
347
- face->glyph->bitmap.rows,
348
- 0,
349
- GL_RED,
350
- GL_UNSIGNED_BYTE,
351
- face->glyph->bitmap.buffer
352
- );
353
339
 
354
- //テクスチャタイプを設定
355
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
356
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
357
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
358
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
359
- glBindTexture(GL_TEXTURE_2D, 0);
340
+ default:
341
+ {
360
342
 
361
-
343
+ }
362
-
363
- return ch;
344
+ break;
345
+
346
+ }
364
347
  }
365
-
366
348
  ```
367
349
 

3

タイトルを修正

2022/01/31 06:39

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- 二つのクラスが謎の影響を受けてエラーが出る原因が知りたい。
1
+ 同じクラスでも使うクラスによってエラーになる原因が知りたい。
body CHANGED
File without changes

2

文章を修正

2022/01/31 06:38

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -16,8 +16,17 @@
16
16
  0x502: 現在のステートで無効な操作をしている場合、もしくは廃止された関数を呼び出した場合(*1)
17
17
  ```
18
18
 
19
+ 利用ライブラリ:
20
+ opengl
21
+ freetype
22
+ glew
23
+ glfw
24
+ stbi
19
25
 
20
26
 
27
+ ソースコード全文: https://github.com/Shigurechan/AAEditor/tree/e0db42df3945fc1e1ea9879e2746ffe5eeedf9f2
28
+
29
+
21
30
  ##### Entry
22
31
  ```cpp
23
32
 

1

文章を修正

2022/01/31 06:09

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -7,9 +7,9 @@
7
7
  提示コードEntryコンストラクタ部ですがA,Bの中身は提示の通りです。
8
8
  Aクラスをコメントアウトするとエラーが出ません。普通に動きます
9
9
  AをコメントアウトしないでBクラスのcamra->RendererBuffer();関数をコメントアウトすると動きます。
10
+ Aクラスのコンストラクタ部のlayer変数部をコメントアウトすると普通に動きます。
10
11
 
11
12
 
12
-
13
13
  glGetError: https://qiita.com/_ydah/items/da56763e94ba58af3d91
14
14
 
15
15
  ```