mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
Rendertarget inherits from texture
This commit is contained in:
@@ -14,7 +14,7 @@ namespace ImGui
|
||||
|
||||
public static override void Image(Texture2D texture, Vec2 size, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, Vec4 tint_col = Vec4.Ones, Vec4 border_col = Vec4.Zero)
|
||||
{
|
||||
var view = texture.nativeResourceView..AddRef();
|
||||
var view = texture._nativeResourceView..AddRef();
|
||||
_resourceViews.Add(view);
|
||||
|
||||
ImGui.Image(view, size, uv0, uv1, tint_col, border_col);
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace GlitchyEngine.Renderer
|
||||
extension RenderTarget2D
|
||||
{
|
||||
protected internal ID3D11Texture2D* _nativeTexture ~ _?.Release();
|
||||
protected internal ID3D11ShaderResourceView* _nativeResourceView ~ _?.Release();
|
||||
protected internal ID3D11RenderTargetView* _nativeRenderTargetView ~ _?.Release();
|
||||
|
||||
private void ReleaseAndNullify()
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
extension Texture
|
||||
{
|
||||
protected internal ID3D11ShaderResourceView* nativeResourceView ~ _?.Release();
|
||||
protected internal ID3D11ShaderResourceView* _nativeResourceView ~ _?.Release();
|
||||
|
||||
/** \brief Loads the texture from the specified path.
|
||||
* @param path The path of the texture to load.
|
||||
@@ -39,17 +39,17 @@ namespace GlitchyEngine.Renderer
|
||||
}
|
||||
|
||||
((ID3D11Resource*)texture)?.Release();
|
||||
nativeResourceView?.Release();
|
||||
_nativeResourceView?.Release();
|
||||
|
||||
HResult loadResult = DDSTextureLoader.CreateDDSTextureFromMemory(NativeDevice,
|
||||
ddsData.Ptr, (uint)ddsData.Count, (.)&texture, &nativeResourceView);
|
||||
ddsData.Ptr, (uint)ddsData.Count, (.)&texture, &_nativeResourceView);
|
||||
|
||||
if(loadResult.Failed)
|
||||
{
|
||||
Log.EngineLogger.Error($"Failed to load texture. Error({(int)loadResult}): {loadResult}");
|
||||
|
||||
ReleaseAndNullify!(texture);
|
||||
ReleaseAndNullify!(nativeResourceView);
|
||||
ReleaseAndNullify!(_nativeResourceView);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace GlitchyEngine.Renderer
|
||||
var result = NativeDevice.CreateTexture2D(ref nativeDesc, resDataPtr, &nativeTexture);
|
||||
Log.EngineLogger.Assert(result.Succeeded, scope $"Failed to create texture 2D. Error ({result.Underlying}): {result}");
|
||||
|
||||
result = NativeDevice.CreateShaderResourceView(nativeTexture, null, &nativeResourceView);
|
||||
result = NativeDevice.CreateShaderResourceView(nativeTexture, null, &_nativeResourceView);
|
||||
Log.EngineLogger.Assert(result.Succeeded, scope $"Failed to create texture view. Error ({result.Underlying}): {result}");
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
nativeTexture?.Release();
|
||||
nativeTexture = null;
|
||||
nativeResourceView?.Release();
|
||||
nativeResourceView = null;
|
||||
_nativeResourceView?.Release();
|
||||
_nativeResourceView = null;
|
||||
|
||||
nativeDesc = (NativeTex2DDesc)desc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user