Skip to content

Conversation

@Themperror
Copy link

@Themperror Themperror commented Nov 19, 2022

Manual texture loading with FreeImage will give us a good excuse to explain how to create textures, rather than let DirectXTex do it for us entirely.

Docs will follow later at some point

@Themperror Themperror requested a review from deccer November 19, 2022 17:58
@Themperror Themperror added the documentation Improvements or additions to documentation label Nov 20, 2022
@Themperror Themperror changed the title Add FreeImage image loading (and updated FreeImage static libraries) Add Texturing Chapter Nov 20, 2022
Copy link
Contributor

@deccer deccer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it a lot so far.

Just a few formatting/linking things and that one actual question regarding resource deletion after srv creation

WRL::ComPtr<ID3D11ShaderResourceView> CreateTextureView(ID3D11Device* device, const std::wstring& pathToTexture)
{
FIBITMAP* image = nullptr;
//Open our file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm code comments make no sense when the code is obvious already, that's why i want readable code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've actually increased the comment a bit because "CreateFile" sounds counterintuitive to Opening a file (thanks winapi :) )


size_t fileSize = GetFileSize(file, nullptr);
//Create our data buffer and read in the entire file
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scoping trick might not be obvious enough, I would suggest a separate private method for that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally rather add a comment explaining the scope, ideally I'd leave this entire texture loading at the two core functions it is currently.

Alternatively I can remove the scope entirely but this way we can keep memory usage across the function low and at best only keep FileSize * 2 amount of data in memory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you explain the scope with a sentence or two, that should be OK then

bool ImageLibraryApplication::Initialize()
bool TexturingApplication::Initialize()
{
// This section initializes GLFW and creates a Window
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm looks like we do have random comments which state the obvious already?????????

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it.

- "ppShaderResourceViews" : The array of SRVs.

If we only need to set a single texture, this is as simple as calling: `PSSetShaderResources(0, 1, srv.Get())`.
If we call `PSSetShaderResources(2,2,srvs)` it will start at slot 2 and thus set slot 2 and 3, with the SRV's supplied.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All those slotisms, I wonder if it makes sense to insert a sentence here that those can be looked at in graphics debuggers as well, like RenderDoc and that we might have to massage/backreference/ofsorts to the debugging chapter somehow... do you know what i mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing in the method params

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see what I can do with a renderdoc screenshot.

Fixed the spacings

Copy link
Contributor

@deccer deccer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@spec-chum spec-chum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on mobile, but it all seems fine to me.

@Themperror Themperror merged commit 4fbef77 into GraphicsProgramming:main Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants