Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Texture2DVK::loadFromFile(std::string filename) {
- const char * filename_char = filename.c_str();
- int texWidth, texHeight, texChannels;
- stbi_uc* pixels = stbi_load(filename_char, &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
- DeviceSize imageSize = texWidth * texHeight * 4;
- if (!pixels) {
- return -1;
- }
- ImageCreateInfo imageInfo = {};
- imageInfo.imageType = ImageType::e2D;
- imageInfo.extent.width = static_cast<uint32_t>(texWidth);
- imageInfo.extent.height = static_cast<uint32_t>(texHeight);
- imageInfo.extent.depth = 1;
- imageInfo.mipLevels = 1;
- imageInfo.arrayLayers = 1;
- imageInfo.format = Format::eR8G8B8A8Unorm;
- imageInfo.tiling = ImageTiling::eOptimal;
- imageInfo.initialLayout = ImageLayout::eUndefined;
- imageInfo.usage = ImageUsageFlagBits::eTransferDst | ImageUsageFlagBits::eSampled;
- imageInfo.sharingMode = SharingMode::eExclusive;
- imageInfo.samples = SampleCountFlagBits::e1; //wrong?
- imageInfo.flags = vk::ImageCreateFlags();
- if (device.createImage(&imageInfo, nullptr, &textureImage) != Result::eSuccess) { //create empty Image space
- return -1;
- }
- MemoryRequirements memReq;
- device.getImageMemoryRequirements();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement