質問編集履歴

9

提示コードを修正

2022/02/01 13:02

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
  ##### makefile
11
- ```
11
+ ```makefile
12
12
  PRG :=Game
13
13
  SRC_DIR :=FrameWork/source
14
14
  SRC_USE_DIR :=source

8

文集を修正

2022/02/01 13:01

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -4,29 +4,45 @@
4
4
  ##### 試したこと
5
5
  Main.cppのEntryクラスや初期化関係の関数をコメントアウトして実験
6
6
 
7
-
8
- wikipedia https://ja.wikipedia.org/wiki/%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D#:~:text=%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D%EF%BC%88%E8%8B%B1%E8%AA%9E%3A%20segmentation%20fault,%E3%81%97%E3%82%88%E3%81%86%E3%81%A8%E3%81%99%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AB
9
-
10
7
  参考サイト: https://www.toumasu-program.net/entry/2019/05/24/112315/
11
8
 
9
+
10
+ ##### makefile
11
+ ```
12
+ PRG :=Game
13
+ SRC_DIR :=FrameWork/source
14
+ SRC_USE_DIR :=source
15
+
16
+ OBJ_DIR :=FrameWork/object
17
+ OBJ_USE_DIR :=object
18
+
19
+ DEP_DIR :=FrameWork/object
20
+ DEP :=$(wildcard $(DEP_DIR)/*.d)
21
+
22
+ SRC :=$(wildcard $(SRC_DIR)/*.cpp)
23
+ SRC_USE :=$(wildcard $(SRC_USE_DIR)/*.cpp)
24
+
25
+ OBJ :=$(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC))))
26
+ OBJ_USE :=$(addprefix $(OBJ_USE_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC_USE))))
27
+
28
+ $(PRG): $(OBJ) $(OBJ_USE)
29
+ $(CXX) $^ -o $@ -ldl -lGLESv2 -lGLU -lGL -lglfw3 -pthread -lGL -lGLEW -lfreetype -ldl -lX11
30
+
31
+ $(OBJ_DIR)/%.o: FrameWork/source/%.cpp
32
+ $(CXX) -g -c -MMD -MP $< -o $@
33
+ -include $(DEP)
34
+
35
+ $(OBJ_USE_DIR)/%.o: source/%.cpp
36
+ $(CXX) -g -c -MMD -MP $< -o $@
37
+ -include $(DEP)
38
+
39
+ clean:
40
+ rm -f ./$(OBJ_USE_DIR)/*.o ./$(OBJ_DIR)/*.o *.out ./$(OBJ_DIR)/*.d ./$(OBJ_USE_DIR)/*.d $(PRG)
41
+
42
+ ```
43
+
12
44
  ##### Console debug
13
45
  ```
14
- shigurechan@shigurechan-System-Product-Name:~/prg/TopDownGame$ gdb ./Game
15
- GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
16
- Copyright (C) 2020 Free Software Foundation, Inc.
17
- License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
18
- This is free software: you are free to change and redistribute it.
19
- There is NO WARRANTY, to the extent permitted by law.
20
- Type "show copying" and "show warranty" for details.
21
- This GDB was configured as "x86_64-linux-gnu".
22
- Type "show configuration" for configuration details.
23
- For bug reporting instructions, please see:
24
- <http://www.gnu.org/software/gdb/bugs/>.
25
- Find the GDB manual and other documentation resources online at:
26
- <http://www.gnu.org/software/gdb/documentation/>.
27
-
28
- For help, type "help".
29
- Type "apropos word" to search for commands related to "word"...
30
46
  Reading symbols from ./Game...
31
47
  (gdb) run
32
48
  Starting program: /home/shigurechan/prg/TopDownGame/Game
@@ -38,26 +54,6 @@
38
54
  (gdb) bt
39
55
  #0 0x0000000000000000 in ?? ()
40
56
  #1 0x0000555555563ff3 in FrameWork::Sprite::Sprite (this=0x55555563f9c0) at FrameWork/source/Sprite.cpp:29
41
- #2 0x000055555556c799 in __gnu_cxx::new_allocator<FrameWork::Sprite>::construct<FrameWork::Sprite> (this=0x7fffffffde1f, __p=0x55555563f9c0) at /usr/include/c++/9/ext/new_allocator.h:147
42
- #3 0x000055555556c501 in std::allocator_traits<std::allocator<FrameWork::Sprite> >::construct<FrameWork::Sprite> (__a=..., __p=0x55555563f9c0) at /usr/include/c++/9/bits/alloc_traits.h:484
43
- #4 0x000055555556c088 in std::_Sp_counted_ptr_inplace<FrameWork::Sprite, std::allocator<FrameWork::Sprite>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(std::allocator<FrameWork::Sprite>) (
44
- this=0x55555563f9b0, __a=...) at /usr/include/c++/9/bits/shared_ptr_base.h:548
45
- #5 0x000055555556bbe6 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<FrameWork::Sprite, std::allocator<FrameWork::Sprite>>(FrameWork::Sprite*&, std::_Sp_alloc_shared_tag<std::allocator<FrameWork::Sprite> >) (this=0x55555560aa28 <sprite+8>, __p=@0x55555560aa20: 0x0, __a=...) at /usr/include/c++/9/bits/shared_ptr_base.h:679
46
- #6 0x000055555556ba94 in std::__shared_ptr<FrameWork::Sprite, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<FrameWork::Sprite>>(std::_Sp_alloc_shared_tag<std::allocator<FrameWork::Sprite> >)
47
- (this=0x55555560aa20 <sprite>, __tag=...) at /usr/include/c++/9/bits/shared_ptr_base.h:1344
48
- #7 0x000055555556b9bf in std::shared_ptr<FrameWork::Sprite>::shared_ptr<std::allocator<FrameWork::Sprite>>(std::_Sp_alloc_shared_tag<std::allocator<FrameWork::Sprite> >) (this=0x55555560aa20 <sprite>,
49
- __tag=...) at /usr/include/c++/9/bits/shared_ptr.h:359
50
- #8 0x000055555556b862 in std::allocate_shared<FrameWork::Sprite, std::allocator<FrameWork::Sprite>>(std::allocator<FrameWork::Sprite> const&) (__a=...) at /usr/include/c++/9/bits/shared_ptr.h:702
51
- #9 0x000055555556b632 in std::make_shared<FrameWork::Sprite> () at /usr/include/c++/9/bits/shared_ptr.h:718
52
- #10 0x000055555556b3cb in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at FrameWork/source/Init.cpp:22
53
- #11 0x000055555556b413 in _GLOBAL__sub_I_ft () at FrameWork/source/Init.cpp:55
54
- #12 0x00005555555c830d in __libc_csu_init ()
55
- #13 0x00007ffff786f040 in __libc_start_main (main=0x5555555a5c18 <main()>, argc=1, argv=0x7fffffffe088, init=0x5555555c82c0 <__libc_csu_init>, fini=<optimized out>, rtld_fini=<optimized out>,
56
- stack_end=0x7fffffffe078) at ../csu/libc-start.c:264
57
- #14 0x000055555555f7fe in _start ()
58
- (gdb) Quit
59
- (gdb)
60
-
61
57
  ```
62
58
 
63
59
 

7

文章を修正

2022/02/01 12:55

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- 実行するとSegmentation fault (コアダンプ) 0x0000000000000000 in ?? () というデバッガによ出力結果はどう対処すればいのか?
1
+ glGenVertexArrays(1, &vao); 関数でSegmentation fault (コアダンプ)というセングメンテーションエラーが発生す原因が知りた
test CHANGED
@@ -1,5 +1,5 @@
1
1
  提示コードですが以下のメイクファイルを実行すると下記のコンソールのエラーが表示されるのですがこれは何が原因なのでしょうか?
2
- デバッガで調べましたが「0x0000000000000000 in ?? ()」と表示されるのですこれは何が言いたいのでしょう
2
+ デバッガで調べましたが見て通りSprite.cpp 29行目たいななのですが原因わりません。`///`コメント部参照
3
3
 
4
4
  ##### 試したこと
5
5
  Main.cppのEntryクラスや初期化関係の関数をコメントアウトして実験
@@ -111,36 +111,142 @@
111
111
  Segmentation fault (コアダンプ)
112
112
  ```
113
113
 
114
- ##### Makefile
115
- ```makefile
116
- PRG :=Game
117
- SRC_DIR :=FrameWork/source
118
- SRC_USE_DIR :=source
119
-
120
- OBJ_DIR :=FrameWork/object
121
- OBJ_USE_DIR :=object
122
-
123
- DEP_DIR :=FrameWork/object
124
- DEP :=$(wildcard $(DEP_DIR)/*.d)
125
-
126
- SRC :=$(wildcard $(SRC_DIR)/*.cpp)
127
- SRC_USE :=$(wildcard $(SRC_USE_DIR)/*.cpp)
128
-
129
- OBJ :=$(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC))))
130
- OBJ_USE :=$(addprefix $(OBJ_USE_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC_USE))))
131
-
132
- $(PRG): $(OBJ) $(OBJ_USE)
133
- $(CXX) $^ -o $@ -ldl -lGLESv2 -lGLU -lGL -lglfw3 -pthread -lGL -lGLEW -lfreetype -ldl -lX11
134
-
135
- $(OBJ_DIR)/%.o: FrameWork/source/%.cpp
136
- $(CXX) -g3 -c -MMD -MP $< -o $@
137
- -include $(DEP)
138
-
139
- $(OBJ_USE_DIR)/%.o: source/%.cpp
140
- $(CXX) -g3 -c -MMD -MP $< -o $@
141
- -include $(DEP)
142
-
143
- clean:
144
- rm -f ./$(OBJ_USE_DIR)/*.o ./$(OBJ_DIR)/*.o *.out ./$(OBJ_DIR)/*.d ./$(OBJ_USE_DIR)/*.d $(PRG)
145
-
146
- ```
114
+ ##### Srpite.cpp
115
+ ```cpp
116
+ #include "../header/Sprite.hpp"
117
+
118
+ #include <array>
119
+ #include <memory>
120
+
121
+ #include <GL/glew.h>
122
+ #include <glm/glm.hpp>
123
+ #include <glm/gtc/type_ptr.hpp>
124
+ #include <glm/gtc/quaternion.hpp>
125
+ #include <glm/gtc/type_ptr.hpp>
126
+ #include <glm/gtx/transform.hpp>
127
+ #include <glm/gtc/matrix_transform.hpp>
128
+
129
+ #include "../header/Resource.hpp"
130
+ #include "../header/Shader.hpp"
131
+ #include "../header/Vertex.hpp"
132
+ #include "../header/Sprite.hpp"
133
+ #include "../header/Shader.hpp"
134
+ #include "../header/Window.hpp"
135
+ #include "../header/Init.hpp"
136
+
137
+
138
+
139
+ FrameWork::Sprite::Sprite() : Render()
140
+ {
141
+ vao = 0;
142
+ vbo = 0;
143
+ //////////////////////////////////////////////////////////////////
144
+ glGenVertexArrays(1, &vao);
145
+ ////////////////////////////////////////////////////////////////
146
+ glGenBuffers(1, &vbo);
147
+
148
+
149
+
150
+ glBindVertexArray(vao);
151
+ glBindBuffer(GL_ARRAY_BUFFER, vbo);
152
+
153
+ shader->setEnable();
154
+
155
+ glBufferData(GL_ARRAY_BUFFER, vertex.size() * sizeof(VertexAttributeSprite), (float*)vertex.data(), GL_DYNAMIC_DRAW);
156
+
157
+ GLuint attrib = shader->getAttribLocation("vertexPosition");
158
+ glEnableVertexAttribArray(attrib);
159
+ glVertexAttribPointer(attrib, 3, GL_FLOAT, GL_FALSE, (sizeof(VertexAttributeSprite) / sizeof(float)) * sizeof(float), (GLvoid*)(sizeof(GLfloat) * 0));
160
+ shader->setBindAttribLocation("vertexPosition");
161
+
162
+ attrib = shader->getAttribLocation("vertexUV");
163
+ glEnableVertexAttribArray(attrib);
164
+ glVertexAttribPointer(attrib, 3, GL_FLOAT, GL_FALSE, (sizeof(VertexAttributeSprite) / sizeof(float)) * sizeof(float), (GLvoid*)(sizeof(GLfloat) * 3));
165
+ shader->setBindAttribLocation("vertexUV");
166
+
167
+ shader->setDisable();
168
+ glBindVertexArray(0);
169
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
170
+
171
+ }
172
+
173
+ // ##################################### 描画 #####################################
174
+ void FrameWork::Sprite::Renderer(const glm::mat4 view,const FrameWork::Texture texture,const glm::vec3 position,const glm::ivec2 startSize,const glm::ivec2 endSize)
175
+ {
176
+ setSize(startSize,endSize);
177
+ setUV(startSize, endSize,texture.size);
178
+
179
+ glBindVertexArray(vao);
180
+ glBindBuffer(GL_ARRAY_BUFFER, vbo);
181
+ glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(VertexAttributeSprite) * vertex.size(), vertex.data());
182
+
183
+ Transform::setPosition(position);
184
+ Transform::setRotate(glm::vec3(0, 0, 1), 0);
185
+ Transform::setScale(glm::vec3(endSize - startSize,1));
186
+
187
+ shader->setUniformSampler2D("uImage",0,texture.ID);
188
+ shader->setUniformMatrix4fv("uTranslate", Transform::getMatTranslation());
189
+ shader->setUniformMatrix4fv("uRotate", Transform::getMatRotate());
190
+ shader->setUniformMatrix4fv("uScale", Transform::getMatScale());
191
+ shader->setUniformMatrix4fv("uViewProjection", view);
192
+
193
+ glDrawArrays(GL_TRIANGLES,0,6);
194
+
195
+ glBindVertexArray(0);
196
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
197
+ }
198
+
199
+
200
+ ```
201
+
202
+ ##### Sprite.hpp
203
+ ```cpp
204
+ #
205
+
206
+ /*#########################################################################
207
+ # スプライトクラス
208
+ 説明
209
+ 2Dのテクスチャ描画 正射形
210
+ ###########################################################################*/
211
+
212
+ /*#########################################################################
213
+ *NOTE
214
+ *
215
+ * 頂点の順番
216
+ * 0 2,3
217
+ * 1,4 5
218
+ ###########################################################################*/
219
+
220
+
221
+ namespace FrameWork
222
+ {
223
+
224
+
225
+ class Sprite : public Render
226
+ {
227
+ public:
228
+
229
+ Sprite();
230
+ ~Sprite();
231
+
232
+ void Renderer(const glm::mat4 view, const FrameWork::Texture texture,const glm::vec3 position, const glm::ivec2 startSize, const glm::ivec2 endSize);
233
+ void Renderer_Rotate(const glm::mat4 view, const glm::vec3 position, const glm::ivec2 startSize, const glm::ivec2 endSize,const glm::ivec2 textureSize, const glm::vec3 rotate, const float radian);
234
+
235
+ std::shared_ptr<FrameWork::Shader> shader;
236
+
237
+ private:
238
+
239
+ GLuint vao;
240
+ GLuint vbo;
241
+
242
+ std::array<VertexAttribute, 6> vertex;
243
+
244
+ void setSize(const glm::vec2 startSize, const glm::vec2 endSize);
245
+ void setUV(const glm::vec2 startSize, const glm::vec2 endSize, const glm::ivec2 textureSize);
246
+
247
+
248
+ };
249
+ }
250
+ #endif
251
+ ```
252
+

6

文章を修正

2022/02/01 12:38

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  ##### Console debug
13
13
  ```
14
- shigurechan@shigurechan-System-Product-Name:~/prg/TopDownGame$ gdb Game
14
+ shigurechan@shigurechan-System-Product-Name:~/prg/TopDownGame$ gdb ./Game
15
15
  GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
16
16
  Copyright (C) 2020 Free Software Foundation, Inc.
17
17
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
@@ -27,7 +27,7 @@
27
27
 
28
28
  For help, type "help".
29
29
  Type "apropos word" to search for commands related to "word"...
30
- Reading symbols from Game...
30
+ Reading symbols from ./Game...
31
31
  (gdb) run
32
32
  Starting program: /home/shigurechan/prg/TopDownGame/Game
33
33
  [Thread debugging using libthread_db enabled]
@@ -35,6 +35,26 @@
35
35
 
36
36
  Program received signal SIGSEGV, Segmentation fault.
37
37
  0x0000000000000000 in ?? ()
38
+ (gdb) bt
39
+ #0 0x0000000000000000 in ?? ()
40
+ #1 0x0000555555563ff3 in FrameWork::Sprite::Sprite (this=0x55555563f9c0) at FrameWork/source/Sprite.cpp:29
41
+ #2 0x000055555556c799 in __gnu_cxx::new_allocator<FrameWork::Sprite>::construct<FrameWork::Sprite> (this=0x7fffffffde1f, __p=0x55555563f9c0) at /usr/include/c++/9/ext/new_allocator.h:147
42
+ #3 0x000055555556c501 in std::allocator_traits<std::allocator<FrameWork::Sprite> >::construct<FrameWork::Sprite> (__a=..., __p=0x55555563f9c0) at /usr/include/c++/9/bits/alloc_traits.h:484
43
+ #4 0x000055555556c088 in std::_Sp_counted_ptr_inplace<FrameWork::Sprite, std::allocator<FrameWork::Sprite>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(std::allocator<FrameWork::Sprite>) (
44
+ this=0x55555563f9b0, __a=...) at /usr/include/c++/9/bits/shared_ptr_base.h:548
45
+ #5 0x000055555556bbe6 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<FrameWork::Sprite, std::allocator<FrameWork::Sprite>>(FrameWork::Sprite*&, std::_Sp_alloc_shared_tag<std::allocator<FrameWork::Sprite> >) (this=0x55555560aa28 <sprite+8>, __p=@0x55555560aa20: 0x0, __a=...) at /usr/include/c++/9/bits/shared_ptr_base.h:679
46
+ #6 0x000055555556ba94 in std::__shared_ptr<FrameWork::Sprite, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<FrameWork::Sprite>>(std::_Sp_alloc_shared_tag<std::allocator<FrameWork::Sprite> >)
47
+ (this=0x55555560aa20 <sprite>, __tag=...) at /usr/include/c++/9/bits/shared_ptr_base.h:1344
48
+ #7 0x000055555556b9bf in std::shared_ptr<FrameWork::Sprite>::shared_ptr<std::allocator<FrameWork::Sprite>>(std::_Sp_alloc_shared_tag<std::allocator<FrameWork::Sprite> >) (this=0x55555560aa20 <sprite>,
49
+ __tag=...) at /usr/include/c++/9/bits/shared_ptr.h:359
50
+ #8 0x000055555556b862 in std::allocate_shared<FrameWork::Sprite, std::allocator<FrameWork::Sprite>>(std::allocator<FrameWork::Sprite> const&) (__a=...) at /usr/include/c++/9/bits/shared_ptr.h:702
51
+ #9 0x000055555556b632 in std::make_shared<FrameWork::Sprite> () at /usr/include/c++/9/bits/shared_ptr.h:718
52
+ #10 0x000055555556b3cb in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at FrameWork/source/Init.cpp:22
53
+ #11 0x000055555556b413 in _GLOBAL__sub_I_ft () at FrameWork/source/Init.cpp:55
54
+ #12 0x00005555555c830d in __libc_csu_init ()
55
+ #13 0x00007ffff786f040 in __libc_start_main (main=0x5555555a5c18 <main()>, argc=1, argv=0x7fffffffe088, init=0x5555555c82c0 <__libc_csu_init>, fini=<optimized out>, rtld_fini=<optimized out>,
56
+ stack_end=0x7fffffffe078) at ../csu/libc-start.c:264
57
+ #14 0x000055555555f7fe in _start ()
38
58
  (gdb) Quit
39
59
  (gdb)
40
60
 

5

文章を修正

2022/02/01 12:06

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -110,14 +110,14 @@
110
110
  OBJ_USE :=$(addprefix $(OBJ_USE_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SRC_USE))))
111
111
 
112
112
  $(PRG): $(OBJ) $(OBJ_USE)
113
- $(CXX) $^ -o $@ -ldl -lGLESv2 -L/usr/local/lib -lGLU -lGL -lglfw3 -pthread -lGL -lGLEW -lfreetype -ldl -lX11
113
+ $(CXX) $^ -o $@ -ldl -lGLESv2 -lGLU -lGL -lglfw3 -pthread -lGL -lGLEW -lfreetype -ldl -lX11
114
114
 
115
115
  $(OBJ_DIR)/%.o: FrameWork/source/%.cpp
116
- $(CXX) -c -MMD -MP $< -o $@
116
+ $(CXX) -g3 -c -MMD -MP $< -o $@
117
117
  -include $(DEP)
118
118
 
119
119
  $(OBJ_USE_DIR)/%.o: source/%.cpp
120
- $(CXX) -c -MMD -MP $< -o $@
120
+ $(CXX) -g3 -c -MMD -MP $< -o $@
121
121
  -include $(DEP)
122
122
 
123
123
  clean:

4

文章とタイトルを修正

2022/02/01 11:56

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- 実行するとSegmentation fault (コアダンプ) と表示さる場合プログラム上で何を疑えばいいのか知りたい。
1
+ 実行するとSegmentation fault (コアダンプ) 0x0000000000000000 in ?? () いうデバッガによる出力結果はどう対処すればいいのか
test CHANGED
@@ -1,5 +1,5 @@
1
1
  提示コードですが以下のメイクファイルを実行すると下記のコンソールのエラーが表示されるのですがこれは何が原因なのでしょうか?
2
- 調べるとセグメンテーション違反という記事がヒットしますがこれはプログラム上では何が原因で起こるのでしょうか?
2
+ デバッガで調べましたが「0x0000000000000000 in ?? ()」と表示されのですがこれは何が言いたいのでしょうか?
3
3
 
4
4
  ##### 試したこと
5
5
  Main.cppのEntryクラスや初期化関係の関数をコメントアウトして実験

3

文章を修正

2022/02/01 11:54

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -8,6 +8,39 @@
8
8
  wikipedia https://ja.wikipedia.org/wiki/%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D#:~:text=%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D%EF%BC%88%E8%8B%B1%E8%AA%9E%3A%20segmentation%20fault,%E3%81%97%E3%82%88%E3%81%86%E3%81%A8%E3%81%99%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AB
9
9
 
10
10
  参考サイト: https://www.toumasu-program.net/entry/2019/05/24/112315/
11
+
12
+ ##### Console debug
13
+ ```
14
+ shigurechan@shigurechan-System-Product-Name:~/prg/TopDownGame$ gdb Game
15
+ GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
16
+ Copyright (C) 2020 Free Software Foundation, Inc.
17
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
18
+ This is free software: you are free to change and redistribute it.
19
+ There is NO WARRANTY, to the extent permitted by law.
20
+ Type "show copying" and "show warranty" for details.
21
+ This GDB was configured as "x86_64-linux-gnu".
22
+ Type "show configuration" for configuration details.
23
+ For bug reporting instructions, please see:
24
+ <http://www.gnu.org/software/gdb/bugs/>.
25
+ Find the GDB manual and other documentation resources online at:
26
+ <http://www.gnu.org/software/gdb/documentation/>.
27
+
28
+ For help, type "help".
29
+ Type "apropos word" to search for commands related to "word"...
30
+ Reading symbols from Game...
31
+ (gdb) run
32
+ Starting program: /home/shigurechan/prg/TopDownGame/Game
33
+ [Thread debugging using libthread_db enabled]
34
+ Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
35
+
36
+ Program received signal SIGSEGV, Segmentation fault.
37
+ 0x0000000000000000 in ?? ()
38
+ (gdb) Quit
39
+ (gdb)
40
+
41
+ ```
42
+
43
+
11
44
  ##### Main.cpp
12
45
  ```
13
46
  #include <iostream>

2

文章を修正

2022/02/01 10:55

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,8 +1,13 @@
1
1
  提示コードですが以下のメイクファイルを実行すると下記のコンソールのエラーが表示されるのですがこれは何が原因なのでしょうか?
2
2
  調べるとセグメンテーション違反という記事がヒットしますがこれはプログラム上では何が原因で起こるのでしょうか?
3
+
4
+ ##### 試したこと
3
- Main.cppのEntryクラスや初期化関係の関数をコメントアウトしていましたが変わりません。
5
+ Main.cppのEntryクラスや初期化関係の関数をコメントアウトして実験
6
+
7
+
4
8
  wikipedia https://ja.wikipedia.org/wiki/%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D#:~:text=%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D%EF%BC%88%E8%8B%B1%E8%AA%9E%3A%20segmentation%20fault,%E3%81%97%E3%82%88%E3%81%86%E3%81%A8%E3%81%99%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AB
5
9
 
10
+ 参考サイト: https://www.toumasu-program.net/entry/2019/05/24/112315/
6
11
  ##### Main.cpp
7
12
  ```
8
13
  #include <iostream>

1

文章を修正

2022/02/01 10:53

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,9 +1,51 @@
1
1
  提示コードですが以下のメイクファイルを実行すると下記のコンソールのエラーが表示されるのですがこれは何が原因なのでしょうか?
2
2
  調べるとセグメンテーション違反という記事がヒットしますがこれはプログラム上では何が原因で起こるのでしょうか?
3
+ Main.cppのEntryクラスや初期化関係の関数をコメントアウトしていましたが変わりません。
4
+ wikipedia https://ja.wikipedia.org/wiki/%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D#:~:text=%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D%EF%BC%88%E8%8B%B1%E8%AA%9E%3A%20segmentation%20fault,%E3%81%97%E3%82%88%E3%81%86%E3%81%A8%E3%81%99%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AB
5
+
6
+ ##### Main.cpp
7
+ ```
8
+ #include <iostream>
9
+ #include "../FrameWork/FrameWork/FrameWork.hpp"
10
+
11
+ #include "../header/Entry.hpp"
12
+
13
+ int main()
14
+ {
15
+ if (glfwInit() == GL_FALSE)
16
+ {
17
+ std::cerr << "glfw を初期化出来ません。" << std::endl;
18
+ assert(0);
19
+ }
20
+
21
+ int screenSize = 50;
22
+ std::shared_ptr<FrameWork::Window> window = FrameWork::GenWindowContext(glm::ivec2(16 * screenSize, 9 * screenSize), "Game");
23
+ FrameWork::setCurrentContext(window);
3
24
 
4
25
 
5
- wikipedia https://ja.wikipedia.org/wiki/%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D#:~:text=%E3%82%BB%E3%82%B0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E9%81%95%E5%8F%8D%EF%BC%88%E8%8B%B1%E8%AA%9E%3A%20segmentation%20fault,%E3%81%97%E3%82%88%E3%81%86%E3%81%A8%E3%81%99%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AB
26
+ if (glewInit() != GLEW_OK)
27
+ {
28
+ std::cerr << "glew を初期化出来ません。" << std::endl;
29
+ assert(0);
30
+ }
6
31
 
32
+
33
+ FrameWork::Init_FrameWork();
34
+
35
+ std::unique_ptr<Entry> entry = std::make_unique<Entry>();
36
+
37
+ while (*window)
38
+ {
39
+ entry->Loop();
40
+
41
+ window->SwapBuffers();
42
+ }
43
+
44
+
45
+ return 0;
46
+ }
47
+
48
+ ```
7
49
 
8
50
  ##### Console
9
51
  ```