Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEEDBACK] Pg 145 : Sergey Kosarevsky #41

Closed
yeokaiwei opened this issue Dec 28, 2024 · 1 comment
Closed

[FEEDBACK] Pg 145 : Sergey Kosarevsky #41

yeokaiwei opened this issue Dec 28, 2024 · 1 comment

Comments

@yeokaiwei
Copy link

yeokaiwei commented Dec 28, 2024

Hi Sergey,
No 12/13/14 mismatch of code with book.

I assume you put it in the function createTextureImageFromData() under updateTextureImage().

However, updateTextureImage() doesn't match the code in the book.

Can I assume the book is NOT updated?

Reference

bool createTextureImage(VulkanRenderDevice& vkDev, 
						const char* filename, 
						VkImage& textureImage, 
						VkDeviceMemory& textureImageMemory, 
						uint32_t* outTexWidth, <-- This is not in the book  
						uint32_t* outTexHeight) <--- This is not in the book 
{
	int texWidth, texHeight, texChannels;
	stbi_uc* pixels = stbi_load(filename, &texWidth, &texHeight, &texChannels, STBI_rgb_alpha);

	if (!pixels) {
		printf("Failed to load [%s] texture\n", filename); fflush(stdout);
		return false;
	}

	bool result = createTextureImageFromData(vkDev, textureImage, textureImageMemory, pixels, texWidth, texHeight, VK_FORMAT_R8G8B8A8_UNORM);

	stbi_image_free(pixels);

	if (outTexWidth && outTexHeight) {
		*outTexWidth  = (uint32_t)texWidth;
		*outTexHeight = (uint32_t)texHeight;
	}

	return result;
}

	createImage(vkDev.device, vkDev.physicalDevice, 
		texWidth, 
		texHeight,  
		texFormat,
		VK_IMAGE_TILING_OPTIMAL, 
		VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, 
		VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 
		textureImage, 
		textureImageMemory, 
		flags);  <-- This is not in the book  
@corporateshark
Copy link
Collaborator

The source code has been updated with bug fixes and changes that were made after the book review was completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants