質問編集履歴
2
文章を修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,110 +32,6 @@
|
|
32
32
|
|
33
33
|
```cpp
|
34
34
|
|
35
|
-
#include "Resource.hpp"
|
36
|
-
|
37
|
-
#include <iostream>
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
#define STB_IMAGE_IMPLEMENTATION
|
42
|
-
|
43
|
-
#include "stb/stb_image.h"
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
//テクスチャ
|
48
|
-
|
49
|
-
std::shared_ptr<std::vector<std::shared_ptr<FrameWork::Resource::Texture_Data>>> FrameWork::Resource::texture = std::make_shared<std::vector<std::shared_ptr<FrameWork::Resource::Texture_Data>>>(0);
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
//シェーダー
|
54
|
-
|
55
|
-
std::shared_ptr<std::vector<std::shared_ptr<FrameWork::Resource::Shader_Data>>> FrameWork::Resource::shader = std::make_shared<std::vector<std::shared_ptr<FrameWork::Resource::Shader_Data>>>(0);
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
//ファイル名
|
60
|
-
|
61
|
-
std::shared_ptr<std::vector<FrameWork::Resource::Resource_File>> FrameWork::Resource::resourceFile = std::make_shared<std::vector<FrameWork::Resource::Resource_File>>(0);
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
// ##################################### テクスチャーを読み込み #####################################
|
66
|
-
|
67
|
-
void FrameWork::Resource::LoadTexture(Asset assetName)
|
68
|
-
|
69
|
-
{
|
70
|
-
|
71
|
-
Texture data;
|
72
|
-
|
73
|
-
data.fileData = NULL;
|
74
|
-
|
75
|
-
for (std::vector<Resource_File>::const_iterator itr = resourceFile->begin(); itr != resourceFile->end(); itr++)
|
76
|
-
|
77
|
-
{
|
78
|
-
|
79
|
-
if (itr->assetName == assetName)
|
80
|
-
|
81
|
-
{
|
82
|
-
|
83
|
-
data.fileData = std::shared_ptr<byte>(stbi_load(itr->fileName, &data.size.x, &data.size.y, &data.channel, 0), stbi_image_free);
|
84
|
-
|
85
|
-
texture->push_back(std::make_shared<Texture_Data>(Texture_Data{ std::make_shared<FrameWork::Resource::Texture>(data),assetName }));
|
86
|
-
|
87
|
-
break;
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
if (data.fileData == NULL)
|
96
|
-
|
97
|
-
{
|
98
|
-
|
99
|
-
std::cerr << "アセットが見つかりません: " << (int)assetName << std::endl;
|
100
|
-
|
101
|
-
assert(0);
|
102
|
-
|
103
|
-
}
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
// ##################################### 読み込んだテクスチャーを取得 #####################################
|
110
|
-
|
111
|
-
std::shared_ptr<FrameWork::Resource::Texture> FrameWork::Resource::getTexture(Asset assetName)
|
112
|
-
|
113
|
-
{
|
114
|
-
|
115
|
-
for (std::vector<std::shared_ptr<Texture_Data>>::const_iterator itr = texture->begin(); itr != texture->end(); itr++)
|
116
|
-
|
117
|
-
{
|
118
|
-
|
119
|
-
if ((*itr)->assetName == assetName)
|
120
|
-
|
121
|
-
{
|
122
|
-
|
123
|
-
return (*itr)->texture;
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
std::cerr << "テクスチャファイルが見つかりません: " << (int)assetName << std::endl;
|
132
|
-
|
133
|
-
assert(0);
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
|
-
|
139
35
|
|
140
36
|
|
141
37
|
// ##################################### シェーダーを読み込む #####################################
|
@@ -144,7 +40,7 @@
|
|
144
40
|
|
145
41
|
{
|
146
42
|
|
147
|
-
|
43
|
+
|
148
44
|
|
149
45
|
std::shared_ptr<Shader> data = std::make_shared<Shader>();
|
150
46
|
|
@@ -224,35 +120,7 @@
|
|
224
120
|
|
225
121
|
}
|
226
122
|
|
227
|
-
|
123
|
+
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
// ##################################### 読み込んだシェーダーを取得 #####################################
|
232
|
-
|
233
|
-
std::shared_ptr<GLchar*> FrameWork::Resource::getShader(Asset assetName)
|
234
|
-
|
235
|
-
{
|
236
|
-
|
237
|
-
for (std::vector<std::shared_ptr<Shader_Data>>::const_iterator itr = shader->begin(); itr != shader->end(); itr++)
|
238
|
-
|
239
|
-
{
|
240
|
-
|
241
|
-
if ((*itr)->assetName == assetName)
|
242
|
-
|
243
|
-
{
|
244
|
-
|
245
|
-
return (*itr)->shader->fileData;
|
246
|
-
|
247
|
-
}
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
std::cerr << "シェーダーファイルが見つかりません: " << (int)assetName << std::endl;
|
254
|
-
|
255
|
-
assert(0);
|
256
124
|
|
257
125
|
}
|
258
126
|
|
@@ -260,78 +128,4 @@
|
|
260
128
|
|
261
129
|
|
262
130
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
// ##################################### ファイルが全部読み込めるかどうか確認する #####################################
|
270
|
-
|
271
|
-
void FrameWork::Resource::InputFile_Ok(std::vector<Resource_File>& data)
|
272
|
-
|
273
|
-
{
|
274
|
-
|
275
|
-
for (std::vector<Resource_File>::const_iterator itr = data.begin(); itr != data.end(); itr++)
|
276
|
-
|
277
|
-
{
|
278
|
-
|
279
|
-
if (FileCheck(itr->fileName) == TRUE)
|
280
|
-
|
281
|
-
{
|
282
|
-
|
283
|
-
resourceFile->push_back(Resource_File{ itr->fileName,itr->assetName });
|
284
|
-
|
285
|
-
}
|
286
|
-
|
287
|
-
else
|
288
|
-
|
289
|
-
{
|
290
|
-
|
291
|
-
std::cerr << "ファイルが読み込めません: " << itr->fileName << std::endl;
|
292
|
-
|
293
|
-
assert(0);
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
}
|
298
|
-
|
299
|
-
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
// ##################################### ファイルが読めるかどうか? #####################################
|
304
|
-
|
305
|
-
byte FrameWork::Resource::FileCheck(const char* fileName)
|
306
|
-
|
307
|
-
{
|
308
|
-
|
309
|
-
std::ifstream file(fileName);
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
if (file.is_open() == false)
|
314
|
-
|
315
|
-
{
|
316
|
-
|
317
|
-
file.close();
|
318
|
-
|
319
|
-
return FALSE;
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
else
|
324
|
-
|
325
|
-
{
|
326
|
-
|
327
|
-
file.close();
|
328
|
-
|
329
|
-
return TRUE;
|
330
|
-
|
331
|
-
}
|
332
|
-
|
333
|
-
}
|
334
|
-
|
335
|
-
|
336
|
-
|
337
131
|
```
|
1
タグを修正
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|