Git Product home page Git Product logo

dds_image's Introduction

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

#include <dds.hpp>

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.

#include <vulkan/vulkan.h> // Before!
#include <dds.hpp>
// 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.

dds_image's People

Contributors

shaunus84 avatar spnda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dds_image's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.