@@ -16,67 +16,67 @@ void surface::load(const std::string& filename) noexcept
16
16
Expects (scener::io::file::exists (filename));
17
17
18
18
file_stream stream (filename);
19
- header ddsheader ;
20
- std::size_t blocksize = 16 ;
19
+ header dds_header ;
20
+ std::size_t block_size = 16 ;
21
21
22
- Ensures (stream.length () >= sizeof ddsheader );
22
+ Ensures (stream.length () >= sizeof dds_header );
23
23
24
- stream.read (reinterpret_cast <char *>(&ddsheader ), 0 , sizeof ddsheader );
24
+ stream.read (reinterpret_cast <char *>(&dds_header ), 0 , sizeof dds_header );
25
25
26
26
// ensure contents are in DDS format
27
- Ensures (ddsheader .magic == 0x20534444 );
27
+ Ensures (dds_header .magic == 0x20534444 );
28
28
29
29
// ensure required flags are meet
30
- Ensures ((ddsheader .flags & header_flags::pixelformat) == header_flags::pixelformat);
31
- Ensures ((ddsheader .flags & header_flags::caps) == header_flags::caps);
32
- Ensures ((ddsheader .flags & header_flags::height) == header_flags::height);
33
- Ensures ((ddsheader .flags & header_flags::width) == header_flags::width);
30
+ Ensures ((dds_header .flags & header_flags::pixelformat) == header_flags::pixelformat);
31
+ Ensures ((dds_header .flags & header_flags::caps) == header_flags::caps);
32
+ Ensures ((dds_header .flags & header_flags::height) == header_flags::height);
33
+ Ensures ((dds_header .flags & header_flags::width) == header_flags::width);
34
34
35
- if (ddsheader .mipmap_count > 0 )
35
+ if (dds_header .mipmap_count > 0 )
36
36
{
37
- Ensures ((ddsheader .flags & header_flags::mipmapcount) == header_flags::mipmapcount);
38
- Ensures ((ddsheader .flags & header_flags::linearsize) == header_flags::linearsize);
37
+ Ensures ((dds_header .flags & header_flags::mipmapcount) == header_flags::mipmapcount);
38
+ Ensures ((dds_header .flags & header_flags::linearsize) == header_flags::linearsize);
39
39
}
40
40
41
41
// ensure pixel format size is correct
42
- Ensures (ddsheader .pixel_format .size == 32 );
42
+ Ensures (dds_header .pixel_format .size == 32 );
43
43
44
44
// ensure the texture is in compressed format
45
- Ensures ((ddsheader .pixel_format .flags & pixel_format_flags::fourcc) == pixel_format_flags::fourcc);
45
+ Ensures ((dds_header .pixel_format .flags & pixel_format_flags::fourcc) == pixel_format_flags::fourcc);
46
46
47
47
// check DXTn format
48
- Ensures (ddsheader .pixel_format .fourcc == fourcc::dxt1
49
- || ddsheader .pixel_format .fourcc == fourcc::dxt3
50
- || ddsheader .pixel_format .fourcc == fourcc::dxt5);
48
+ Ensures (dds_header .pixel_format .fourcc == fourcc::dxt1
49
+ || dds_header .pixel_format .fourcc == fourcc::dxt3
50
+ || dds_header .pixel_format .fourcc == fourcc::dxt5);
51
51
52
52
// process dds contents
53
- _height = ddsheader .height ;
54
- _width = ddsheader .width ;
53
+ _height = dds_header .height ;
54
+ _width = dds_header .width ;
55
55
56
- if (ddsheader .pixel_format .fourcc == fourcc::dxt1)
56
+ if (dds_header .pixel_format .fourcc == fourcc::dxt1)
57
57
{
58
58
_format = surface_format::dxt1;
59
- blocksize = 8 ;
59
+ block_size = 8 ;
60
60
}
61
- else if (ddsheader .pixel_format .fourcc == fourcc::dxt3)
61
+ else if (dds_header .pixel_format .fourcc == fourcc::dxt3)
62
62
{
63
63
_format = surface_format::dxt3;
64
64
}
65
- else if (ddsheader .pixel_format .fourcc == fourcc::dxt5)
65
+ else if (dds_header .pixel_format .fourcc == fourcc::dxt5)
66
66
{
67
67
_format = surface_format::dxt5;
68
68
}
69
69
70
- auto mipmapwidth = _width;
71
- auto mipmapheight = _height;
72
- auto position = size_type { 0 };
73
- auto length = stream.length () - sizeof ddsheader ;
70
+ auto mipmap_width = _width;
71
+ auto mipmap_height = _height;
72
+ auto position = size_type { 0 };
73
+ auto length = stream.length () - sizeof dds_header ;
74
74
75
75
_mipmaps.clear ();
76
76
_buffer.clear ();
77
77
_view = { };
78
78
79
- _mipmaps.reserve (ddsheader .mipmap_count );
79
+ _mipmaps.reserve (dds_header .mipmap_count );
80
80
_buffer.reserve (length);
81
81
82
82
auto readed = stream.read (reinterpret_cast <char *>(_buffer.data ()), 0 , length);
@@ -85,15 +85,15 @@ void surface::load(const std::string& filename) noexcept
85
85
86
86
_view = gsl::span<std::uint8_t >(_buffer.data (), static_cast <std::ptrdiff_t >(length));
87
87
88
- for (size_type level = 0 ; level < ddsheader .mipmap_count ; ++level)
88
+ for (size_type level = 0 ; level < dds_header .mipmap_count ; ++level)
89
89
{
90
- auto size = std::max<size_type>(4 , mipmapwidth ) / 4 * std::max<size_type>(4 , mipmapheight ) / 4 * blocksize ;
90
+ auto size = std::max<size_type>(4 , mipmap_width ) / 4 * std::max<size_type>(4 , mipmap_height ) / 4 * block_size ;
91
91
auto view = _view.subspan (static_cast <std::ptrdiff_t >(position), static_cast <std::ptrdiff_t >(size));
92
92
93
- _mipmaps.push_back ({ level, mipmapwidth, mipmapheight , view });
93
+ _mipmaps.push_back ({ level, mipmap_width, mipmap_height , view });
94
94
95
- mipmapwidth = std::max<std::size_t >(1 , mipmapwidth >>= 1 );
96
- mipmapheight = std::max<std::size_t >(1 , mipmapheight >>= 1 );
95
+ mipmap_width = std::max<std::size_t >(1 , mipmap_width >>= 1 );
96
+ mipmap_height = std::max<std::size_t >(1 , mipmap_height >>= 1 );
97
97
98
98
position += size;
99
99
}
0 commit comments