https://github.com/spnda/dds_image
Header-only C++11/C++17 DirectDraw Surface (DDS) decoder with Vulkan helpers.
https://github.com/spnda/dds_image
cpp cpp11 cpp17 dds dds-loader directdraw-surface header-only vulkan
Last synced: 7 months ago
JSON representation
Header-only C++11/C++17 DirectDraw Surface (DDS) decoder with Vulkan helpers.
- Host: GitHub
- URL: https://github.com/spnda/dds_image
- Owner: spnda
- License: mit
- Created: 2021-10-18T23:24:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-27T10:15:07.000Z (almost 2 years ago)
- Last Synced: 2025-04-07T07:42:08.649Z (11 months ago)
- Topics: cpp, cpp11, cpp17, dds, dds-loader, directdraw-surface, header-only, vulkan
- Language: C++
- Homepage:
- Size: 27.3 KB
- Stars: 21
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dds_image
A C++11 single-header DDS (DirectDraw Surface) image library,
with no dependencies.
It also includes utilities to work with Vulkan, as well
as optional support for C++17 and C++20 specific features.
You can quickly add this as a submodule and add the header files,
or import it as a subdirectory in CMake.
### Example
```cpp
#include
dds::Image image;
dds::readFile("example.dds", &image);
```
On MSVC you might need to build with `/Zc:__cplusplus` for the built-in C++17 features to work.
You can then optionally also define `DDS_USE_STD_FILESYSTEM`, which will make `dds::readFile` accept
a `std::filesystem::path` instead.
Each mipmap can be accessed through `image.mipmaps`. A mipmap is a `dds::span` which represents a
contiguous block of memory within the image data that represents the specific mipmap. All mipmaps
use the same format and the mipmaps are arranged in order of size in the vector, meaning the
largest mipmap is `image.mipmaps.front()` and every next mipmap is exactly 50% smaller.
### Vulkan Usage
If you want to use the built-in Vulkan features, you **have** to include
the Vulkan header before you import this library.
To create the VkImage and VkImageView you can use the following two functions.
Note that you still need to set some fields yourself, most notably `VkImageCreateInfo::usage`,
`VkImageCreateInfo::samples` and `VkImageViewCreateInfo::image`.
```cpp
#include // Before!
#include
```
```cpp
// Optional, for own usage.
VkImageFormat imageFormat = dds::getVulkanFormat(image.format, image.supportsAlpha);
// Will automatically fill VkImageCreateInfo::format with a separate call to dds::getVulkanFormat.
VkImageCreateInfo imageCreateInfo = dds::getVulkanImageCreateInfo(&image);
VkImageViewCreateInfo imageViewCreateInfo = dds::getVulkanImageViewCreateInfo(&image);
```
### License
The library itself is licensed under MIT.