Extending RendererDX11 class

Oct 8, 2011 at 10:48 AM

Hello,

I'm currently reading "Practical Rendering & Computation with Direct3D11". Everything is interesting but I'm specifically interested by the computation part: I want to do image processing and then rendering.

The sample program "BasicComputeShader" looks like a good starting point for me. So I started to modify it to fit my needs.

To fit my needs, I need something similar to RendererDX11::LoadTexture but instead of loading texture from a file, I would like to load it from memory, that is using D3DX11CreateTextureFromMemory insted of D3DX11CreateTextureFromFile. In order to not modify Hieroglyph3 source code, my idea was to create a new class - RendererExDX11 - inheriting from RendererDX11 and adding LoadTextureFromMemory function. Unfortunately, as Hieroglyph3 is designed, it is not possible to do it: you are immediately stuck because you need to access private members !

As far as I understand up to now (I'm just starting with Hieroglyph3 and I'm not a C++ expert), Hieroglyph3 has not been designed with extension in mind. In my opinion, way too much members are private instead of protected and the use of friend keyword is not always appropriate. Am I mistaken ?

I would really be pleased if someone could show the code required to create my RendererExDX11 class inheriting from RendererDX11 and create RendererExDX11::LoadTextureFromMemory by almost duplicationg RendererDX11::LoadTexture function and replacing D2DX11CreateTextureFromFile by D3DX11CreateTextureFromMemory.

Thanks in advance.

Francois Piette



Coordinator
Oct 8, 2011 at 1:09 PM

Hello,

Thank you for your interest in the project.  To be perfectly honest, when I designed the library I had no intentions of ever extending the RendererDX11 class - my idea was to have multiple renderer classes instead that could be implemented as needed.  However, with more people using the library, I don't see any reason to restrict the usage to my original intent.

Here is what I propose:

1. I will update the renderer class to allow access to subclasses for all currently private members.

2. I will add the texture loading function as you requested to the main renderer - it is a good use case that would make sense to have in the primary engine anyways.

Finally, have you taken a look at the ImageProcessor sample?  This also demonstrates a few different filtering techniques that might be interesting for you.

Thank you for your comments, and suggestions like this are always welcome - I'm not a C++ expert either, but I am more than willing to take advice myself.  Good luck with your project, and be sure to let us know how it turns out!

Jason

Coordinator
Oct 8, 2011 at 1:25 PM

Update: I just made those two changes!  Check out the method and see if it works out for you.  It is just an overload of LoadTexture().

Oct 8, 2011 at 3:40 PM
Edited Oct 8, 2011 at 3:41 PM
Hello Jason,
Thanks for your fast reaction !
It seems that ViewDeferredRenderer.h and ViewDeferredRenderer.cpp are now missing.
(I have done a svn update).
--
Francois
Coordinator
Oct 8, 2011 at 4:58 PM

Sorry about that... I just committed those two files.  Please let me know if you have any other problems getting your subclass working!