mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Load effects via content manager + virtual InitContentManager in App
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
AssetLoader = "EffectAssetLoader",
|
||||||
|
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}
|
||||||
|
}
|
||||||
@@ -4,13 +4,15 @@
|
|||||||
_generateMipMaps = true,
|
_generateMipMaps = true,
|
||||||
_isSrgb = true,
|
_isSrgb = true,
|
||||||
_samplerStateDescription = {
|
_samplerStateDescription = {
|
||||||
MinFilter = .Linear,
|
MinFilter = .Anisotropic,
|
||||||
|
MagFilter = .Anisotropic,
|
||||||
|
MipFilter = .Anisotropic,
|
||||||
ComparisonFunction = .Never,
|
ComparisonFunction = .Never,
|
||||||
AddressModeU = .Wrap,
|
AddressModeU = .Wrap,
|
||||||
AddressModeV = .Border,
|
AddressModeV = .Border,
|
||||||
AddressModeW = .Clamp,
|
AddressModeW = .Clamp,
|
||||||
MipMaxLOD = 160,
|
MipMaxLOD = 160,
|
||||||
MaxAnisotropy = 5,
|
MaxAnisotropy = 16,
|
||||||
BorderColor = {
|
BorderColor = {
|
||||||
R = 0.756863,
|
R = 0.756863,
|
||||||
G = 0.2,
|
G = 0.2,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
AssetLoader = "EditorTextureAssetLoader",
|
AssetLoader = "EditorTextureAssetLoader",
|
||||||
Config = (GlitchyEditor.Assets.EditorTextureAssetLoaderConfig){
|
Config = (GlitchyEditor.Assets.EditorTextureAssetLoaderConfig){
|
||||||
|
_isSrgb = true,
|
||||||
_samplerStateDescription = {
|
_samplerStateDescription = {
|
||||||
MinFilter = .Linear,
|
MinFilter = .Linear,
|
||||||
MagFilter = .Linear,
|
MagFilter = .Linear,
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
using Bon;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.IO;
|
||||||
|
using GlitchyEngine;
|
||||||
|
using GlitchyEngine.Renderer;
|
||||||
|
|
||||||
|
namespace GlitchyEditor.Assets;
|
||||||
|
|
||||||
|
class EffectAssetPropertiesEditor : AssetPropertiesEditor
|
||||||
|
{
|
||||||
|
public this(AssetFile asset) : base(asset)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ShowEditor()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetPropertiesEditor Factory(AssetFile assetFile)
|
||||||
|
{
|
||||||
|
return new Self(assetFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[BonTarget, BonPolyRegister]
|
||||||
|
class EffectAssetLoaderConfig : AssetLoaderConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class EffectAssetLoader : IAssetLoader //, IReloadingAssetLoader
|
||||||
|
{
|
||||||
|
private static readonly List<StringView> _fileExtensions = new .(){".hlsl"} ~ delete _;
|
||||||
|
|
||||||
|
public static List<StringView> FileExtensions => _fileExtensions;
|
||||||
|
|
||||||
|
public AssetLoaderConfig GetDefaultConfig()
|
||||||
|
{
|
||||||
|
return new EffectAssetLoaderConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Asset LoadAsset(Stream file, AssetLoaderConfig config, StringView assetIdentifier, StringView? subAsset, IContentManager contentManager)
|
||||||
|
{
|
||||||
|
Effect effect = new Effect(file, assetIdentifier, contentManager);
|
||||||
|
|
||||||
|
return effect;
|
||||||
|
|
||||||
|
/*StreamReader reader = scope .(file);
|
||||||
|
|
||||||
|
String text = scope .();
|
||||||
|
|
||||||
|
reader.ReadToEnd(text);
|
||||||
|
|
||||||
|
MaterialFile materialFile = scope .();
|
||||||
|
|
||||||
|
var result = Bon.Deserialize<MaterialFile>(ref materialFile, text);
|
||||||
|
|
||||||
|
if (result case .Err)
|
||||||
|
{
|
||||||
|
Log.EngineLogger.Error("Failed to load material.");
|
||||||
|
return null;
|
||||||
|
// TODO: return error material
|
||||||
|
}
|
||||||
|
|
||||||
|
Effect fx = new Effect(materialFile.Effect);
|
||||||
|
|
||||||
|
Material material = new Material(fx);
|
||||||
|
|
||||||
|
for (let (slotName, textureIdentifier) in materialFile.Textures)
|
||||||
|
{
|
||||||
|
Texture texture = contentManager.LoadAsset(textureIdentifier) as Texture;
|
||||||
|
|
||||||
|
if (texture == null)
|
||||||
|
{
|
||||||
|
Log.EngineLogger.Error("Failed to load texture.");
|
||||||
|
// TODO: LoadAsset should return an error texture.
|
||||||
|
}
|
||||||
|
|
||||||
|
material.SetTexture(slotName, texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
fx.ReleaseRef();
|
||||||
|
|
||||||
|
/*for (let (slotName, textureIdentifier) in materialFile.Variables)
|
||||||
|
{
|
||||||
|
if (texture == null)
|
||||||
|
{
|
||||||
|
Log.EngineLogger.Error("Failed to load texture.");
|
||||||
|
// TODO: LoadAsset should return an error texture.
|
||||||
|
}
|
||||||
|
|
||||||
|
material.SetVariable(slotName, );
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return material; //ModelLoader.LoadMesh(file, subAsset.Value, 0);*/
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,7 +52,7 @@ class MaterialAssetLoader : IAssetLoader //, IReloadingAssetLoader
|
|||||||
return new ModelAssetLoaderConfig();
|
return new ModelAssetLoaderConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Asset LoadAsset(Stream file, AssetLoaderConfig config, StringView? subAsset, IContentManager contentManager)
|
public Asset LoadAsset(Stream file, AssetLoaderConfig config, StringView assetIdentifier, StringView? subAsset, IContentManager contentManager)
|
||||||
{
|
{
|
||||||
StreamReader reader = scope .(file);
|
StreamReader reader = scope .(file);
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class ModelAssetLoader : IAssetLoader //, IReloadingAssetLoader
|
|||||||
return new ModelAssetLoaderConfig();
|
return new ModelAssetLoaderConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Asset LoadAsset(Stream file, AssetLoaderConfig config, StringView? subAsset, IContentManager contentManager)
|
public Asset LoadAsset(Stream file, AssetLoaderConfig config, StringView assetIdentifier, StringView? subAsset, IContentManager contentManager)
|
||||||
{
|
{
|
||||||
Log.EngineLogger.Assert(subAsset != null);
|
Log.EngineLogger.Assert(subAsset != null);
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ class EditorTextureAssetLoader : IAssetLoader, IReloadingAssetLoader
|
|||||||
return new EditorTextureAssetLoaderConfig();
|
return new EditorTextureAssetLoaderConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Asset LoadAsset(Stream data, AssetLoaderConfig config, StringView? subAsset, IContentManager contentManager)
|
public Asset LoadAsset(Stream data, AssetLoaderConfig config, StringView assetIdentifier, StringView? subAsset, IContentManager contentManager)
|
||||||
{
|
{
|
||||||
var config;
|
var config;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,41 @@
|
|||||||
using System;
|
using System;
|
||||||
using GlitchyEngine;
|
using GlitchyEngine;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
using GlitchyEditor.Assets;
|
||||||
|
|
||||||
namespace GlitchyEditor
|
namespace GlitchyEditor
|
||||||
{
|
{
|
||||||
class EditorApp : Application
|
class EditorApp : Application
|
||||||
{
|
{
|
||||||
|
EditorContentManager _contentManager;
|
||||||
|
|
||||||
public this()
|
public this()
|
||||||
{
|
{
|
||||||
PushLayer(new EditorLayer());
|
PushLayer(new EditorLayer(_contentManager));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IContentManager InitContentManager()
|
||||||
|
{
|
||||||
|
_contentManager = new EditorContentManager();
|
||||||
|
_contentManager.RegisterAssetLoader<EditorTextureAssetLoader>();
|
||||||
|
_contentManager.SetAsDefaultAssetLoader<EditorTextureAssetLoader>(".png", ".dds");
|
||||||
|
_contentManager.SetAssetPropertiesEditor<EditorTextureAssetLoader>(=> TextureAssetPropertiesEditor.Factory);
|
||||||
|
|
||||||
|
_contentManager.RegisterAssetLoader<ModelAssetLoader>();
|
||||||
|
_contentManager.SetAsDefaultAssetLoader<ModelAssetLoader>(".glb", ".gltf");
|
||||||
|
_contentManager.SetAssetPropertiesEditor<ModelAssetLoader>(=> ModelAssetPropertiesEditor.Factory);
|
||||||
|
|
||||||
|
_contentManager.RegisterAssetLoader<MaterialAssetLoader>();
|
||||||
|
_contentManager.SetAsDefaultAssetLoader<MaterialAssetLoader>(".mat");
|
||||||
|
_contentManager.SetAssetPropertiesEditor<MaterialAssetLoader>(=> MaterialAssetPropertiesEditor.Factory);
|
||||||
|
|
||||||
|
_contentManager.RegisterAssetLoader<EffectAssetLoader>();
|
||||||
|
_contentManager.SetAsDefaultAssetLoader<EffectAssetLoader>(".hlsl");
|
||||||
|
_contentManager.SetAssetPropertiesEditor<EffectAssetLoader>(=> EffectAssetPropertiesEditor.Factory);
|
||||||
|
|
||||||
|
_contentManager.SetContentDirectory("./content");
|
||||||
|
|
||||||
|
return _contentManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export, LinkName("CreateApplication")]
|
[Export, LinkName("CreateApplication")]
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ class EditorContentManager : IContentManager
|
|||||||
_supportedExtensions.Add(new String(ext));
|
_supportedExtensions.Add(new String(ext));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAsDefaultAssetLoader<T>(params StringView[] fileExtensions) where T : IAssetLoader
|
public void SetAsDefaultAssetLoader<T>(params Span<StringView> fileExtensions) where T : IAssetLoader
|
||||||
{
|
{
|
||||||
for (var ext in fileExtensions)
|
for (var ext in fileExtensions)
|
||||||
{
|
{
|
||||||
@@ -616,7 +616,7 @@ class EditorContentManager : IContentManager
|
|||||||
|
|
||||||
Stream stream = GetStream(filePath);
|
Stream stream = GetStream(filePath);
|
||||||
|
|
||||||
Asset loadedAsset = assetLoader.LoadAsset(stream, file.AssetConfig.Config, subassetName, this);
|
Asset loadedAsset = assetLoader.LoadAsset(stream, file.AssetConfig.Config, resourceName, subassetName, this);
|
||||||
|
|
||||||
delete stream;
|
delete stream;
|
||||||
|
|
||||||
@@ -637,9 +637,22 @@ class EditorContentManager : IContentManager
|
|||||||
// TODO: probably not needed
|
// TODO: probably not needed
|
||||||
public Stream GetStream(StringView assetIdentifier)
|
public Stream GetStream(StringView assetIdentifier)
|
||||||
{
|
{
|
||||||
|
var assetIdentifier;
|
||||||
|
|
||||||
|
if (!assetIdentifier.StartsWith(_contentDirectory))
|
||||||
|
{
|
||||||
|
String filePath = scope:: String(assetIdentifier.Length + _contentDirectory.Length + 2);
|
||||||
|
Path.Combine(filePath, _contentDirectory, assetIdentifier);
|
||||||
|
|
||||||
|
assetIdentifier = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
FileStream fs = new FileStream();
|
FileStream fs = new FileStream();
|
||||||
var result = fs.Open(assetIdentifier, .Open, .Read, .ReadWrite);
|
var result = fs.Open(assetIdentifier, .Open, .Read, .ReadWrite);
|
||||||
|
|
||||||
|
if (result case .Err)
|
||||||
|
return null;
|
||||||
|
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace GlitchyEditor
|
|||||||
BlendState _opaqueBlendState ~ _.ReleaseRef();
|
BlendState _opaqueBlendState ~ _.ReleaseRef();
|
||||||
DepthStencilState _depthStencilState ~ _.ReleaseRef();
|
DepthStencilState _depthStencilState ~ _.ReleaseRef();
|
||||||
|
|
||||||
Scene _scene = new Scene() ~ delete _;
|
Scene _scene ~ delete _;
|
||||||
String _sceneFilePath = new String() ~ delete _;
|
String _sceneFilePath = new String() ~ delete _;
|
||||||
|
|
||||||
public String SceneFilePath
|
public String SceneFilePath
|
||||||
@@ -69,14 +69,17 @@ namespace GlitchyEditor
|
|||||||
|
|
||||||
SceneState _sceneState = .Edit;
|
SceneState _sceneState = .Edit;
|
||||||
|
|
||||||
public this() : base("Example")
|
public this(EditorContentManager contentManager) : base("Example")
|
||||||
{
|
{
|
||||||
Application.Get().Window.IsVSync = false;
|
Application.Get().Window.IsVSync = false;
|
||||||
|
|
||||||
InitContentManager();
|
//InitContentManager();
|
||||||
|
_contentManager = contentManager;
|
||||||
|
|
||||||
InitGraphics();
|
InitGraphics();
|
||||||
|
|
||||||
|
_scene = new Scene();
|
||||||
|
|
||||||
_camera = EditorCamera(Vector3(3.5f, 1.25f, 2.75f), Quaternion.FromEulerAngles(MathHelper.ToRadians(40), MathHelper.ToRadians(25), 0), MathHelper.ToRadians(75), 0.1f, 1);
|
_camera = EditorCamera(Vector3(3.5f, 1.25f, 2.75f), Quaternion.FromEulerAngles(MathHelper.ToRadians(40), MathHelper.ToRadians(25), 0), MathHelper.ToRadians(75), 0.1f, 1);
|
||||||
_camera.RenderTarget = _cameraTarget;
|
_camera.RenderTarget = _cameraTarget;
|
||||||
|
|
||||||
@@ -85,7 +88,7 @@ namespace GlitchyEditor
|
|||||||
NewScene();
|
NewScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitContentManager()
|
/*private void InitContentManager()
|
||||||
{
|
{
|
||||||
_contentManager = new EditorContentManager();
|
_contentManager = new EditorContentManager();
|
||||||
_contentManager.RegisterAssetLoader<EditorTextureAssetLoader>();
|
_contentManager.RegisterAssetLoader<EditorTextureAssetLoader>();
|
||||||
@@ -99,12 +102,16 @@ namespace GlitchyEditor
|
|||||||
_contentManager.RegisterAssetLoader<MaterialAssetLoader>();
|
_contentManager.RegisterAssetLoader<MaterialAssetLoader>();
|
||||||
_contentManager.SetAsDefaultAssetLoader<MaterialAssetLoader>(".mat");
|
_contentManager.SetAsDefaultAssetLoader<MaterialAssetLoader>(".mat");
|
||||||
_contentManager.SetAssetPropertiesEditor<MaterialAssetLoader>(=> MaterialAssetPropertiesEditor.Factory);
|
_contentManager.SetAssetPropertiesEditor<MaterialAssetLoader>(=> MaterialAssetPropertiesEditor.Factory);
|
||||||
|
|
||||||
|
_contentManager.RegisterAssetLoader<EffectAssetLoader>();
|
||||||
|
_contentManager.SetAsDefaultAssetLoader<EffectAssetLoader>(".hlsl");
|
||||||
|
_contentManager.SetAssetPropertiesEditor<EffectAssetLoader>(=> EffectAssetPropertiesEditor.Factory);
|
||||||
|
|
||||||
_contentManager.SetContentDirectory("./content");
|
_contentManager.SetContentDirectory("./content");
|
||||||
|
|
||||||
// Todo: Sketchy...
|
// Todo: Sketchy...
|
||||||
Application.Get().[Friend]_contentManager = _contentManager;
|
Application.Get().[Friend]_contentManager = _contentManager;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private void InitGraphics()
|
private void InitGraphics()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,13 +7,12 @@ using GlitchyEngine.Content;
|
|||||||
|
|
||||||
namespace GlitchyEngine
|
namespace GlitchyEngine
|
||||||
{
|
{
|
||||||
public class Application
|
public abstract class Application
|
||||||
{
|
{
|
||||||
static Application s_Instance = null;
|
static Application s_Instance = null;
|
||||||
|
|
||||||
private Window _window;
|
private Window _window;
|
||||||
private RendererAPI _rendererApi;
|
private RendererAPI _rendererApi;
|
||||||
private EffectLibrary _effectLibrary;
|
|
||||||
|
|
||||||
private bool _running = true;
|
private bool _running = true;
|
||||||
private bool _isMinimized = false;
|
private bool _isMinimized = false;
|
||||||
@@ -31,8 +30,6 @@ namespace GlitchyEngine
|
|||||||
public bool IsRunning => _running;
|
public bool IsRunning => _running;
|
||||||
public Window Window => _window;
|
public Window Window => _window;
|
||||||
|
|
||||||
public EffectLibrary EffectLibrary => _effectLibrary;
|
|
||||||
|
|
||||||
public IContentManager ContentManager => _contentManager;
|
public IContentManager ContentManager => _contentManager;
|
||||||
|
|
||||||
public bool IsMinimized => _isMinimized;
|
public bool IsMinimized => _isMinimized;
|
||||||
@@ -56,19 +53,19 @@ namespace GlitchyEngine
|
|||||||
_window.EventCallback = new => OnEvent;
|
_window.EventCallback = new => OnEvent;
|
||||||
|
|
||||||
Input.Init();
|
Input.Init();
|
||||||
|
|
||||||
|
_contentManager = InitContentManager();
|
||||||
|
|
||||||
|
// TODO: RenderAPI in RenderCommand initialisieren?
|
||||||
_rendererApi = new RendererAPI();
|
_rendererApi = new RendererAPI();
|
||||||
_rendererApi.Context = _window.Context;
|
_rendererApi.Context = _window.Context;
|
||||||
|
|
||||||
//_contentManager = new ContentManager("./content");
|
|
||||||
|
|
||||||
SamplerStateManager.Init();
|
SamplerStateManager.Init();
|
||||||
|
|
||||||
|
// TODO: Rendercommmand in Renderer initialisieren?
|
||||||
RenderCommand.RendererAPI = _rendererApi;
|
RenderCommand.RendererAPI = _rendererApi;
|
||||||
|
|
||||||
_effectLibrary = new EffectLibrary();
|
Renderer.Init();
|
||||||
|
|
||||||
Renderer.Init(_effectLibrary);
|
|
||||||
|
|
||||||
#if IMGUI
|
#if IMGUI
|
||||||
_imGuiLayer = new ImGuiLayer();
|
_imGuiLayer = new ImGuiLayer();
|
||||||
@@ -79,6 +76,13 @@ namespace GlitchyEngine
|
|||||||
Settings.Apply();
|
Settings.Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Initializes the content manager.
|
||||||
|
protected abstract IContentManager InitContentManager();
|
||||||
|
//{
|
||||||
|
// TODO: init default content manager?
|
||||||
|
//_contentManager = new ContentManager("./content");
|
||||||
|
//}
|
||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
Profiler.ProfileFunction!();
|
Profiler.ProfileFunction!();
|
||||||
@@ -86,8 +90,6 @@ namespace GlitchyEngine
|
|||||||
SamplerStateManager.Uninit();
|
SamplerStateManager.Uninit();
|
||||||
Renderer.Deinit();
|
Renderer.Deinit();
|
||||||
|
|
||||||
delete _effectLibrary;
|
|
||||||
|
|
||||||
delete _contentManager;
|
delete _contentManager;
|
||||||
|
|
||||||
delete _rendererApi;
|
delete _rendererApi;
|
||||||
|
|||||||
@@ -56,24 +56,24 @@ namespace GlitchyEngine.Content
|
|||||||
/// @param config The configuration which specifies the settings used to load the asset.
|
/// @param config The configuration which specifies the settings used to load the asset.
|
||||||
/// @param contentManager The content manager used to load the asset.
|
/// @param contentManager The content manager used to load the asset.
|
||||||
/// @returns The loaded asset.
|
/// @returns The loaded asset.
|
||||||
Asset LoadAsset(Stream file, AssetLoaderConfig config, StringView? subAsset, IContentManager contentManager);
|
Asset LoadAsset(Stream file, AssetLoaderConfig config, StringView assetIdentifier, StringView? subAsset, IContentManager contentManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
/// Loads the specified asset with the given contentManager or the current applications content manager.
|
/// Loads the specified asset with the given contentManager or the current applications content manager.
|
||||||
public static T LoadAsset<T>(StringView assetIdentifier, IContentManager contentManager = null) where T : IRefCounted
|
public static T LoadAsset<T>(StringView assetIdentifier, IContentManager contentManager = null) where T : Asset
|
||||||
{
|
{
|
||||||
var contentManager;
|
var contentManager;
|
||||||
|
|
||||||
if (contentManager == null)
|
if (contentManager == null)
|
||||||
contentManager = Application.Get().ContentManager;
|
contentManager = Application.Get().ContentManager;
|
||||||
|
|
||||||
Object o = contentManager.LoadAsset(assetIdentifier);
|
Asset asset = contentManager.LoadAsset(assetIdentifier);
|
||||||
|
|
||||||
Log.EngineLogger.AssertDebug(o is T);
|
Log.EngineLogger.AssertDebug(asset is T);
|
||||||
|
|
||||||
return (T)o;
|
return (T)asset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ namespace GlitchyEngine.Content
|
|||||||
Stream GetStream(StringView assetIdentifier);
|
Stream GetStream(StringView assetIdentifier);
|
||||||
|
|
||||||
void RegisterAssetLoader<T>() where T : new, class, IAssetLoader;
|
void RegisterAssetLoader<T>() where T : new, class, IAssetLoader;
|
||||||
void SetAsDefaultAssetLoader<T>(params StringView[] fileExtensions) where T : IAssetLoader;
|
void SetAsDefaultAssetLoader<T>(params Span<StringView> fileExtensions) where T : IAssetLoader;
|
||||||
//void GetFilePath(String outFilename, String filename);
|
//void GetFilePath(String outFilename, String filename);
|
||||||
|
|
||||||
//Stream GetFile(String filename);
|
//Stream GetFile(String filename);
|
||||||
@@ -104,6 +104,11 @@ namespace GlitchyEngine.Content
|
|||||||
|
|
||||||
class RuntimeContentManager : IContentManager
|
class RuntimeContentManager : IContentManager
|
||||||
{
|
{
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
Runtime.NotImplemented();
|
||||||
|
}
|
||||||
|
|
||||||
public Asset LoadAsset(StringView assetIdentifier)
|
public Asset LoadAsset(StringView assetIdentifier)
|
||||||
{
|
{
|
||||||
Runtime.NotImplemented();
|
Runtime.NotImplemented();
|
||||||
@@ -134,7 +139,7 @@ namespace GlitchyEngine.Content
|
|||||||
Runtime.NotImplemented();
|
Runtime.NotImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAsDefaultAssetLoader<T>(params StringView[] fileExtensions) where T : IAssetLoader
|
public void SetAsDefaultAssetLoader<T>(params Span<StringView> fileExtensions) where T : IAssetLoader
|
||||||
{
|
{
|
||||||
Runtime.NotImplemented();
|
Runtime.NotImplemented();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System;
|
|||||||
using DirectX.D3D11;
|
using DirectX.D3D11;
|
||||||
using DirectX.D3DCompiler;
|
using DirectX.D3DCompiler;
|
||||||
using GlitchyEngine.Platform.DX11;
|
using GlitchyEngine.Platform.DX11;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
|
||||||
using internal GlitchyEngine.Renderer;
|
using internal GlitchyEngine.Renderer;
|
||||||
using internal GlitchyEngine.Platform.DX11;
|
using internal GlitchyEngine.Platform.DX11;
|
||||||
@@ -12,11 +13,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
extension PixelShader
|
extension PixelShader
|
||||||
{
|
{
|
||||||
public override void CompileFromSource(StringView code, StringView? fileName, String entryPoint, ShaderDefine[] macros = null)
|
public override void CompileFromSource(StringView code, StringView? fileName, String entryPoint, IContentManager contentManager, ShaderDefine[] macros = null)
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileRendererFunction!();
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
Shader.PlattformCompileShaderFromSource(code, fileName, macros, entryPoint, "ps_5_0", DefaultCompileFlags, out nativeCode);
|
Shader.PlattformCompileShaderFromSource(code, fileName, macros, entryPoint, "ps_5_0", DefaultCompileFlags, contentManager, out nativeCode);
|
||||||
|
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceScope!("CreateNativePixelShader");
|
Debug.Profiler.ProfileResourceScope!("CreateNativePixelShader");
|
||||||
|
|||||||
@@ -6,11 +6,106 @@ using DirectX.Common;
|
|||||||
using DirectX.D3D11;
|
using DirectX.D3D11;
|
||||||
using DirectX.D3DCompiler;
|
using DirectX.D3DCompiler;
|
||||||
using DirectX.D3D11Shader;
|
using DirectX.D3D11Shader;
|
||||||
|
using System.IO;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
using internal GlitchyEngine.Renderer;
|
using internal GlitchyEngine.Renderer;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
|
struct ContentManagerInclude : ID3DInclude, IDisposable
|
||||||
|
{
|
||||||
|
private VTable _vTable;
|
||||||
|
|
||||||
|
private IContentManager _contentManager;
|
||||||
|
|
||||||
|
private Dictionary<char8*, (String FileContent, void* Data, uint32 Length)> _loadedFiles;
|
||||||
|
|
||||||
|
private String _parentFileDirectory;
|
||||||
|
|
||||||
|
public this(IContentManager contentManager, String parentFileDirectory)
|
||||||
|
{
|
||||||
|
_contentManager = contentManager;
|
||||||
|
_parentFileDirectory = parentFileDirectory;
|
||||||
|
_loadedFiles = new Dictionary<char8*, (String FileContent, void* Data, uint32 Length)>();
|
||||||
|
|
||||||
|
_vTable.Open = => Open;
|
||||||
|
_vTable.Close = => Close;
|
||||||
|
|
||||||
|
_vt = &_vTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
delete _loadedFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HResult Open(ID3DInclude* self, IncludeType includeType, char8* fileName, void* parentData, void** data, uint32* bytes)
|
||||||
|
{
|
||||||
|
ContentManagerInclude* includer = (.)self;
|
||||||
|
|
||||||
|
if (includer._loadedFiles.TryGetValue(fileName, let value))
|
||||||
|
{
|
||||||
|
*data = value.Data;
|
||||||
|
*bytes = value.Length;
|
||||||
|
|
||||||
|
return .S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
String pathNextToParent = scope .();
|
||||||
|
|
||||||
|
Path.Combine(pathNextToParent, includer._parentFileDirectory, StringView(fileName));
|
||||||
|
|
||||||
|
Stream fileStream = Application.Get().ContentManager.GetStream(pathNextToParent);
|
||||||
|
|
||||||
|
if (fileStream == null)
|
||||||
|
{
|
||||||
|
fileStream = Application.Get().ContentManager.GetStream(StringView(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileStream == null)
|
||||||
|
{
|
||||||
|
Log.EngineLogger.Error($"Failed to include file \"{fileName}\"");
|
||||||
|
return .E_FILENOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileContent = new String();
|
||||||
|
|
||||||
|
{
|
||||||
|
StreamReader reader = scope .(fileStream);
|
||||||
|
|
||||||
|
reader.ReadToEnd(fileContent);
|
||||||
|
|
||||||
|
includer._loadedFiles.Add(fileName, (fileContent, fileContent.Ptr, (uint32)fileContent.Length));
|
||||||
|
}
|
||||||
|
|
||||||
|
delete fileStream;
|
||||||
|
|
||||||
|
*data = (void*)fileContent.Ptr;
|
||||||
|
*bytes = (uint32)fileContent.Length;
|
||||||
|
|
||||||
|
return .S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HResult Close(ID3DInclude* self, void** data)
|
||||||
|
{
|
||||||
|
ContentManagerInclude* includer = (.)self;
|
||||||
|
|
||||||
|
for (var v in includer._loadedFiles)
|
||||||
|
{
|
||||||
|
if (v.value.Data == data)
|
||||||
|
{
|
||||||
|
delete v.value.FileContent;
|
||||||
|
|
||||||
|
includer._loadedFiles.Remove(v.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return .S_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension Shader
|
extension Shader
|
||||||
{
|
{
|
||||||
internal ID3D11DeviceChild* nativeShader ~ _?.Release();
|
internal ID3D11DeviceChild* nativeShader ~ _?.Release();
|
||||||
@@ -27,7 +122,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
.OptimizationLevel3;
|
.OptimizationLevel3;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
internal static void PlattformCompileShaderFromSource(StringView code, StringView? fileName, ShaderDefine[] macros, String entryPoint, String target, ShaderCompileFlags compileFlags, out ID3DBlob* shaderBlob)
|
internal static void PlattformCompileShaderFromSource(StringView code, StringView? fileName, ShaderDefine[] macros, String entryPoint, String target, ShaderCompileFlags compileFlags, IContentManager contentManager, out ID3DBlob* shaderBlob)
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
@@ -44,12 +139,22 @@ namespace GlitchyEngine.Renderer
|
|||||||
|
|
||||||
ID3DBlob* errorBlob = null;
|
ID3DBlob* errorBlob = null;
|
||||||
|
|
||||||
shaderBlob = null;
|
String directory = scope .();
|
||||||
var result = D3DCompiler.D3DCompile(code.Ptr, (.)code.Length, fileName?.ToScopeCStr!(), nativeMacros, ID3DInclude.StandardInclude, entryPoint, target, compileFlags, .None, &shaderBlob, &errorBlob);
|
|
||||||
if(result.Failed)
|
Path.GetDirectoryPath(fileName.Value, directory);
|
||||||
|
|
||||||
|
using (ContentManagerInclude includer = .(contentManager, directory))
|
||||||
{
|
{
|
||||||
StringView str = StringView((char8*)errorBlob.GetBufferPointer(), (int)errorBlob.GetBufferSize());
|
//ID3DInclude.StandardInclude
|
||||||
Log.EngineLogger.Error($"Failed to compile Shader: Error Code({(int)result}): {result} | Error Message: {str}");
|
|
||||||
|
shaderBlob = null;
|
||||||
|
var result = D3DCompiler.D3DCompile(code.Ptr, (.)code.Length, fileName?.ToScopeCStr!(), nativeMacros, &includer, entryPoint, target, compileFlags, .None, &shaderBlob, &errorBlob);
|
||||||
|
|
||||||
|
if(result.Failed)
|
||||||
|
{
|
||||||
|
StringView str = StringView((char8*)errorBlob.GetBufferPointer(), (int)errorBlob.GetBufferSize());
|
||||||
|
Log.EngineLogger.Error($"Failed to compile Shader: Error Code({(int)result}): {result} | Error Message: {str}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.EngineLogger.Assert(shaderBlob != null, "Shader compilation failed.");
|
Log.EngineLogger.Assert(shaderBlob != null, "Shader compilation failed.");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using GlitchyEngine.Renderer;
|
|||||||
using DirectX.D3D11;
|
using DirectX.D3D11;
|
||||||
using DirectX.D3DCompiler;
|
using DirectX.D3DCompiler;
|
||||||
using GlitchyEngine.Platform.DX11;
|
using GlitchyEngine.Platform.DX11;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
|
||||||
using internal GlitchyEngine.Renderer;
|
using internal GlitchyEngine.Renderer;
|
||||||
using internal GlitchyEngine.Platform.DX11;
|
using internal GlitchyEngine.Platform.DX11;
|
||||||
@@ -13,11 +14,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
{
|
{
|
||||||
extension VertexShader
|
extension VertexShader
|
||||||
{
|
{
|
||||||
public override void CompileFromSource(StringView code, StringView? fileName, String entryPoint, ShaderDefine[] macros = null)
|
public override void CompileFromSource(StringView code, StringView? fileName, String entryPoint, IContentManager contentManager = null, ShaderDefine[] macros = null)
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
Shader.PlattformCompileShaderFromSource(code, fileName, macros, entryPoint, "vs_5_0", DefaultCompileFlags, out nativeCode);
|
Shader.PlattformCompileShaderFromSource(code, fileName, macros, entryPoint, "vs_5_0", DefaultCompileFlags, contentManager, out nativeCode);
|
||||||
|
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceScope!("CreateNativeVertexShader");
|
Debug.Profiler.ProfileResourceScope!("CreateNativeVertexShader");
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public class PixelShader : Shader
|
public class PixelShader : Shader
|
||||||
{
|
{
|
||||||
[AllowAppend]
|
[AllowAppend]
|
||||||
public this(StringView code, StringView? fileName, String entryPoint, ShaderDefine[] macros = null)
|
public this(StringView code, StringView? fileName, String entryPoint, IContentManager contentManager, ShaderDefine[] macros = null)
|
||||||
: base(code, fileName, entryPoint, macros) { }
|
: base(code, fileName, entryPoint, contentManager, macros) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
private Vector3 _padding;
|
private Vector3 _padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Init(EffectLibrary effectLibrary)
|
public static void Init()
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileFunction!();
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ namespace GlitchyEngine.Renderer
|
|||||||
Renderer2D.Init();
|
Renderer2D.Init();
|
||||||
FullscreenQuad.Init();
|
FullscreenQuad.Init();
|
||||||
|
|
||||||
InitLineRenderer(effectLibrary);
|
InitLineRenderer();
|
||||||
InitDeferredRenderer(effectLibrary);
|
InitDeferredRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Deinit()
|
public static void Deinit()
|
||||||
@@ -128,11 +128,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
Renderer2D.Deinit();
|
Renderer2D.Deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitLineRenderer(EffectLibrary effectLibrary)
|
static void InitLineRenderer()
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileFunction!();
|
Debug.Profiler.ProfileFunction!();
|
||||||
|
|
||||||
LineEffect = effectLibrary.Load("content\\Shaders\\lineShader.hlsl");
|
LineEffect = Content.LoadAsset<Effect>("Shaders\\lineShader.hlsl");
|
||||||
|
|
||||||
LineGeometry = new GeometryBinding();
|
LineGeometry = new GeometryBinding();
|
||||||
LineGeometry.SetPrimitiveTopology(.LineList);
|
LineGeometry.SetPrimitiveTopology(.LineList);
|
||||||
@@ -161,10 +161,10 @@ namespace GlitchyEngine.Renderer
|
|||||||
LineEffect.ReleaseRef();
|
LineEffect.ReleaseRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitDeferredRenderer(EffectLibrary effectLibrary)
|
static void InitDeferredRenderer()
|
||||||
{
|
{
|
||||||
TestFullscreenEffect = effectLibrary.Load("content\\Shaders\\simpleLight.hlsl");
|
TestFullscreenEffect = Content.LoadAsset<Effect>("Shaders\\simpleLight.hlsl");
|
||||||
s_tonemappingEffect = effectLibrary.Load("content\\Shaders\\SimpleTonemapping.hlsl");
|
s_tonemappingEffect = Content.LoadAsset<Effect>("Shaders\\SimpleTonemapping.hlsl");
|
||||||
|
|
||||||
_gBuffer = new GBuffer();
|
_gBuffer = new GBuffer();
|
||||||
BlendStateDescription gBufferBlendDesc = .Default;
|
BlendStateDescription gBufferBlendDesc = .Default;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using GlitchyEngine.Core;
|
using GlitchyEngine.Core;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
@@ -30,7 +31,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
public ShaderTextureCollection Textures => _textures;
|
public ShaderTextureCollection Textures => _textures;
|
||||||
|
|
||||||
[AllowAppend]
|
[AllowAppend]
|
||||||
public this(StringView code, StringView? fileName, String entryPoint, ShaderDefine[] macros = null)
|
public this(StringView code, StringView? fileName, String entryPoint, IContentManager contentManager, ShaderDefine[] macros = null)
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
_buffers = new BufferCollection();
|
_buffers = new BufferCollection();
|
||||||
_textures = new ShaderTextureCollection();
|
_textures = new ShaderTextureCollection();
|
||||||
|
|
||||||
CompileFromSource(code, fileName, entryPoint);
|
CompileFromSource(code, fileName, entryPoint, contentManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
@@ -47,19 +48,19 @@ namespace GlitchyEngine.Renderer
|
|||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static mixin FromFile<T>(String fileName, String entryPoint, ShaderDefine[] macros = null) where T : Shader
|
/*public static mixin FromFile<T>(String fileName, String entryPoint, IContentManager contentManager, ShaderDefine[] macros = null) where T : Shader
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
String fileContent = new String();
|
String fileContent = new String();
|
||||||
File.ReadAllText(fileName, fileContent, true);
|
File.ReadAllText(fileName, fileContent, true);
|
||||||
T shader = new T(fileContent, (StringView)fileName, entryPoint, macros);
|
T shader = new T(fileContent, (StringView)fileName, contentManager, entryPoint, macros);
|
||||||
|
|
||||||
delete fileContent;
|
delete fileContent;
|
||||||
|
|
||||||
shader
|
shader
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public abstract void CompileFromSource(StringView code, StringView? fileName, String entryPoint, ShaderDefine[] macros = null);
|
public abstract void CompileFromSource(StringView code, StringView? fileName, String entryPoint, IContentManager contentManager, ShaderDefine[] macros = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public class VertexShader : Shader
|
public class VertexShader : Shader
|
||||||
{
|
{
|
||||||
[AllowAppend]
|
[AllowAppend]
|
||||||
public this(StringView code, StringView? fileName, String entryPoint, ShaderDefine[] macros = null)
|
public this(StringView code, StringView? fileName, String entryPoint, IContentManager contentManager = null, ShaderDefine[] macros = null)
|
||||||
: base(code, fileName, entryPoint, macros) { }
|
: base(code, fileName, entryPoint, contentManager, macros) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using Box2D;
|
using Box2D;
|
||||||
using GlitchyEngine.Core;
|
using GlitchyEngine.Core;
|
||||||
|
using GlitchyEngine.Content;
|
||||||
|
|
||||||
namespace GlitchyEngine.World
|
namespace GlitchyEngine.World
|
||||||
{
|
{
|
||||||
@@ -75,7 +76,7 @@ namespace GlitchyEngine.World
|
|||||||
DepthTargetDescription = .(.D24_UNorm_S8_UInt)
|
DepthTargetDescription = .(.D24_UNorm_S8_UInt)
|
||||||
});
|
});
|
||||||
|
|
||||||
_gammaCorrectEffect = Application.Get().EffectLibrary.Load("content/Shaders/GammaCorrect.hlsl");
|
_gammaCorrectEffect = Content.LoadAsset<Effect>("Shaders/GammaCorrect.hlsl");//Application.Get().EffectLibrary.Load("content/Shaders/GammaCorrect.hlsl");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ~this()
|
public ~this()
|
||||||
|
|||||||
@@ -85,13 +85,13 @@ namespace Sandbox
|
|||||||
|
|
||||||
_context = Application.Get().Window.Context..AddRef();
|
_context = Application.Get().Window.Context..AddRef();
|
||||||
|
|
||||||
var effectLibrary = Application.Get().EffectLibrary;
|
//var effectLibrary = Application.Get().EffectLibrary;
|
||||||
|
|
||||||
effectLibrary.LoadNoRefInc("content\\Shaders\\basicShader.hlsl");
|
//effectLibrary.LoadNoRefInc("content\\Shaders\\basicShader.hlsl");
|
||||||
|
|
||||||
effectLibrary.LoadNoRefInc("content\\Shaders\\testShader.hlsl");
|
//effectLibrary.LoadNoRefInc("content\\Shaders\\testShader.hlsl");
|
||||||
|
|
||||||
var textureEffect = effectLibrary.Load("content\\Shaders\\textureShader.hlsl");
|
var textureEffect = Content.LoadAsset<Effect>("Shaders\\textureShader.hlsl");
|
||||||
|
|
||||||
_depthTarget = new DepthStencilTarget(_context.SwapChain.Width, _context.SwapChain.Height);
|
_depthTarget = new DepthStencilTarget(_context.SwapChain.Width, _context.SwapChain.Height);
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ namespace Sandbox
|
|||||||
|
|
||||||
void TestLoadModel()
|
void TestLoadModel()
|
||||||
{
|
{
|
||||||
var testEffect = Application.Get().EffectLibrary.Get("testShader");
|
var testEffect = Content.LoadAsset<Effect>("Shaders\\testShader.hlsl");//Application.Get().EffectLibrary.Get("testShader");
|
||||||
var materialTestMaterial = new Material(testEffect);
|
var materialTestMaterial = new Material(testEffect);
|
||||||
animationMat = materialTestMaterial;
|
animationMat = materialTestMaterial;
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ namespace Sandbox
|
|||||||
_world.Register<CameraComponent>();
|
_world.Register<CameraComponent>();
|
||||||
_world.Register<AnimationComponent>();
|
_world.Register<AnimationComponent>();
|
||||||
|
|
||||||
var basicEffect = Application.Get().EffectLibrary.Get("basicShader");
|
var basicEffect = Content.LoadAsset<Effect>("Shaders\\basicShader.hlsl");//Application.Get().EffectLibrary.Get("basicShader");
|
||||||
|
|
||||||
testMaterial1 = new Material(basicEffect);
|
testMaterial1 = new Material(basicEffect);
|
||||||
testMaterial1.SetVariable("BaseColor", _squareColor0);
|
testMaterial1.SetVariable("BaseColor", _squareColor0);
|
||||||
@@ -352,7 +352,7 @@ namespace Sandbox
|
|||||||
|
|
||||||
RenderCommand.SetBlendState(_opaqueBlendState);
|
RenderCommand.SetBlendState(_opaqueBlendState);
|
||||||
|
|
||||||
var basicEffect = Application.Get().EffectLibrary.Get("basicShader");
|
var basicEffect = Content.LoadAsset<Effect>("Shaders\\basicShader.hlsl");//Application.Get().EffectLibrary.Get("basicShader");
|
||||||
|
|
||||||
RenderCommand.SetRasterizerState(_rasterizerState);
|
RenderCommand.SetRasterizerState(_rasterizerState);
|
||||||
|
|
||||||
|
|||||||
@@ -32,5 +32,10 @@ namespace Sandbox
|
|||||||
{
|
{
|
||||||
return new SandboxApp();
|
return new SandboxApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IContentManager InitContentManager()
|
||||||
|
{
|
||||||
|
Runtime.NotImplemented();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user