MCPcopy Create free account
hub / github.com/PacktPublishing/3D-Graphics-Rendering-Cookbook / createTextureImage

Function createTextureImage

shared/UtilsVulkan.cpp:2336–2357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2334}
2335
2336bool createTextureImage(VulkanRenderDevice& vkDev, const char* filename, VkImage& textureImage, VkDeviceMemory& textureImageMemory, uint32_t* outTexWidth, uint32_t* outTexHeight)
2337{
2338 int texWidth, texHeight, texChannels;
2339 stbi_uc* pixels = stbi_load(filename, &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);
2340
2341 if (!pixels) {
2342 printf("Failed to load [%s] texture\n", filename); fflush(stdout);
2343 return false;
2344 }
2345
2346 bool result = createTextureImageFromData(vkDev, textureImage, textureImageMemory,
2347 pixels, texWidth, texHeight, VK_FORMAT_R8G8B8A8_UNORM);
2348
2349 stbi_image_free(pixels);
2350
2351 if (outTexWidth && outTexHeight) {
2352 *outTexWidth = (uint32_t)texWidth;
2353 *outTexHeight = (uint32_t)texHeight;
2354 }
2355
2356 return result;
2357}
2358
2359size_t allocateVertexBuffer(VulkanRenderDevice& vkDev, VkBuffer* storageBuffer, VkDeviceMemory* storageBufferMemory, size_t vertexDataSize, const void* vertexData, size_t indexDataSize, const void* indexData)
2360{

Callers 5

initVulkanFunction · 0.85
loadTexture2DMethod · 0.85
loadTextureFunction · 0.85
ModelRendererMethod · 0.85
VulkanQuadRendererMethod · 0.85

Calls 1

Tested by

no test coverage detected