-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.cpp
45 lines (37 loc) · 979 Bytes
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <map>
#include "wmb.hpp"
using namespace WMB;
/*
* This example lists all textures in the level file.
*/
std::map<WMB::Texture::Format, std::string> formats =
{
{ WMB::Texture::RGBA8888, "RGBA8888" },
{ WMB::Texture::RGB888, "RGB888" },
{ WMB::Texture::RGB565, "RGB565" },
{ WMB::Texture::DDS, "DDS" },
};
int main(int argc, char ** argv)
{
if(argc < 2) {
std::cout << "Usage: wmb [filename]" << std::endl;
return 0;
}
auto level = WMB::load(argv[1]);
if(not level) {
std::cerr << "Failed to load '" << argv[1] << "'." << std::endl;
return 1;
}
for(auto const & tex : level->textures)
{
auto fmt = formats.find(tex.format);
std::cout << "size=" << tex.width << "*" << tex.height << ",\t";
if(fmt != formats.end())
std::cout << "format=" << fmt->second<< ",\t";
else
std::cout << "format=unknown(" << tex.format << "),\t";
std::cout << "name='" << tex.name << "'" << std::endl;
}
return 0;
}