mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
tests fix
This commit is contained in:
+33
-19
@@ -31,10 +31,6 @@ use fyrox::{
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
material::{shader::SamplerFallback, Material, PropertyValue, SharedMaterial},
|
||||
resource::{
|
||||
model::{ModelImportOptions, ModelResource},
|
||||
texture::{TextureImportOptions, TextureResource},
|
||||
},
|
||||
scene::{
|
||||
base::BaseBuilder,
|
||||
light::{point::PointLightBuilder, BaseLightBuilder},
|
||||
@@ -204,27 +200,45 @@ fn main() {
|
||||
},
|
||||
vsync: true,
|
||||
};
|
||||
let serialization_context = Arc::new(SerializationContext::new());
|
||||
let resource_manager = ResourceManager::new();
|
||||
|
||||
// Set up our custom loaders
|
||||
{
|
||||
let mut state = resource_manager.state();
|
||||
let containers = state.containers_mut();
|
||||
containers.set_model_loader(CustomModelLoader(Arc::new(ModelLoader {
|
||||
resource_manager: resource_manager.clone(),
|
||||
serialization_context: serialization_context.clone(),
|
||||
})));
|
||||
containers.set_texture_loader(CustomTextureLoader(Arc::new(TextureLoader)));
|
||||
}
|
||||
|
||||
let mut engine = Engine::new(EngineInitParams {
|
||||
graphics_context_params,
|
||||
resource_manager: ResourceManager::new(serialization_context.clone()),
|
||||
serialization_context,
|
||||
resource_manager: ResourceManager::new(),
|
||||
serialization_context: Arc::new(SerializationContext::new()),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// Set up our custom loaders
|
||||
{
|
||||
let mut state = engine.resource_manager.state();
|
||||
let containers = state.containers_mut();
|
||||
if let Some(pos) = containers
|
||||
.resources
|
||||
.loaders
|
||||
.iter()
|
||||
.position(|l| (**l).as_any().downcast_ref::<ModelLoader>().is_some())
|
||||
{
|
||||
containers.resources.loaders[pos] =
|
||||
Box::new(CustomModelLoader(Arc::new(ModelLoader {
|
||||
resource_manager: engine.resource_manager.clone(),
|
||||
serialization_context: engine.serialization_context.clone(),
|
||||
default_import_options: Default::default(),
|
||||
})));
|
||||
}
|
||||
|
||||
if let Some(pos) = containers
|
||||
.resources
|
||||
.loaders
|
||||
.iter()
|
||||
.position(|l| (**l).as_any().downcast_ref::<TextureLoader>().is_some())
|
||||
{
|
||||
containers.resources.loaders[pos] =
|
||||
Box::new(CustomTextureLoader(Arc::new(TextureLoader {
|
||||
default_import_options: Default::default(),
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
let scene = block_on(GameSceneLoader::load_with(engine.resource_manager.clone())).scene;
|
||||
engine.scenes.add(scene);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//!
|
||||
//! ```no_run
|
||||
//! use std::sync::{Mutex, Arc};
|
||||
//! use fyrox_sound::buffer::{SoundBufferResource, DataSource};
|
||||
//! use fyrox_sound::buffer::{SoundBufferResource, DataSource, SoundBufferResourceExtension};
|
||||
//!
|
||||
//! async fn make_buffer() -> SoundBufferResource {
|
||||
//! let data_source = DataSource::from_file("sound.wav").await.unwrap();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
//!
|
||||
//! ```no_run
|
||||
//! use std::sync::{Mutex, Arc};
|
||||
//! use fyrox_sound::buffer::{SoundBufferResource, DataSource};
|
||||
//! use fyrox_sound::buffer::{SoundBufferResource, DataSource, SoundBufferResourceExtension};
|
||||
//!
|
||||
//! async fn make_streaming_buffer() -> SoundBufferResource {
|
||||
//! let data_source = DataSource::from_file("some_long_sound.ogg").await.unwrap();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
//! SoundBufferResource
|
||||
//! },
|
||||
//! };
|
||||
//! use fyrox_sound::buffer::SoundBufferResourceExtension;
|
||||
//!
|
||||
//! let context = SoundContext::new();
|
||||
//!
|
||||
|
||||
+5
-4
@@ -805,8 +805,9 @@ impl Engine {
|
||||
///
|
||||
/// ```no_run
|
||||
/// use fyrox::{
|
||||
/// asset::manager::ResourceManager,
|
||||
/// engine::{
|
||||
/// resource_manager::ResourceManager, Engine, EngineInitParams, GraphicsContextParams,
|
||||
/// Engine, EngineInitParams, GraphicsContextParams,
|
||||
/// SerializationContext,
|
||||
/// },
|
||||
/// event_loop::EventLoop,
|
||||
@@ -821,11 +822,11 @@ impl Engine {
|
||||
/// },
|
||||
/// vsync: true,
|
||||
/// };
|
||||
/// let serialization_context = Arc::new(SerializationContext::new());
|
||||
///
|
||||
/// Engine::new(EngineInitParams {
|
||||
/// graphics_context_params,
|
||||
/// resource_manager: ResourceManager::new(serialization_context.clone()),
|
||||
/// serialization_context,
|
||||
/// resource_manager: ResourceManager::new(),
|
||||
/// serialization_context: Arc::new(SerializationContext::new()),
|
||||
/// })
|
||||
/// .unwrap();
|
||||
/// ```
|
||||
|
||||
+12
-8
@@ -289,10 +289,11 @@ impl Default for PropertyValue {
|
||||
/// ```no_run
|
||||
/// use fyrox::{
|
||||
/// material::shader::{ShaderResource, SamplerFallback},
|
||||
/// engine::resource_manager::ResourceManager,
|
||||
/// asset::manager::ResourceManager,
|
||||
/// material::{Material, PropertyValue},
|
||||
/// core::sstorage::ImmutableString,
|
||||
/// };
|
||||
/// use fyrox::resource::texture::Texture;
|
||||
///
|
||||
/// fn create_brick_material(resource_manager: ResourceManager) -> Material {
|
||||
/// let mut material = Material::standard();
|
||||
@@ -300,7 +301,7 @@ impl Default for PropertyValue {
|
||||
/// material.set_property(
|
||||
/// &ImmutableString::new("diffuseTexture"),
|
||||
/// PropertyValue::Sampler {
|
||||
/// value: Some(resource_manager.request_texture("Brick_DiffuseTexture.jpg")),
|
||||
/// value: Some(resource_manager.request::<Texture, _>("Brick_DiffuseTexture.jpg")),
|
||||
/// fallback: SamplerFallback::White
|
||||
/// })
|
||||
/// .unwrap();
|
||||
@@ -321,13 +322,14 @@ impl Default for PropertyValue {
|
||||
///
|
||||
/// ```no_run
|
||||
/// use fyrox::{
|
||||
/// engine::resource_manager::ResourceManager,
|
||||
/// asset::manager::ResourceManager,
|
||||
/// material::{Material, PropertyValue},
|
||||
/// core::{sstorage::ImmutableString, algebra::Vector3}
|
||||
/// };
|
||||
/// use fyrox::material::shader::Shader;
|
||||
///
|
||||
/// async fn create_grass_material(resource_manager: ResourceManager) -> Material {
|
||||
/// let shader = resource_manager.request_shader("my_grass_shader.ron").await.unwrap();
|
||||
/// let shader = resource_manager.request::<Shader, _>("my_grass_shader.ron").await.unwrap();
|
||||
///
|
||||
/// // Here we assume that the material really has the properties defined below.
|
||||
/// let mut material = Material::from_shader(shader, Some(resource_manager));
|
||||
@@ -401,10 +403,11 @@ impl Material {
|
||||
/// ```no_run
|
||||
/// use fyrox::{
|
||||
/// material::shader::{ShaderResource, SamplerFallback},
|
||||
/// engine::resource_manager::ResourceManager,
|
||||
/// asset::manager::ResourceManager,
|
||||
/// material::{Material, PropertyValue},
|
||||
/// core::sstorage::ImmutableString
|
||||
/// };
|
||||
/// use fyrox::resource::texture::Texture;
|
||||
///
|
||||
/// fn create_brick_material(resource_manager: ResourceManager) -> Material {
|
||||
/// let mut material = Material::standard();
|
||||
@@ -412,7 +415,7 @@ impl Material {
|
||||
/// material.set_property(
|
||||
/// &ImmutableString::new("diffuseTexture"),
|
||||
/// PropertyValue::Sampler {
|
||||
/// value: Some(resource_manager.request_texture("Brick_DiffuseTexture.jpg")),
|
||||
/// value: Some(resource_manager.request::<Texture, _>("Brick_DiffuseTexture.jpg")),
|
||||
/// fallback: SamplerFallback::White
|
||||
/// })
|
||||
/// .unwrap();
|
||||
@@ -441,13 +444,14 @@ impl Material {
|
||||
///
|
||||
/// ```no_run
|
||||
/// use fyrox::{
|
||||
/// engine::resource_manager::ResourceManager,
|
||||
/// asset::manager::ResourceManager,
|
||||
/// material::{Material, PropertyValue},
|
||||
/// core::{sstorage::ImmutableString, algebra::Vector3}
|
||||
/// };
|
||||
/// use fyrox::material::shader::Shader;
|
||||
///
|
||||
/// async fn create_grass_material(resource_manager: ResourceManager) -> Material {
|
||||
/// let shader = resource_manager.request_shader("my_grass_shader.ron").await.unwrap();
|
||||
/// let shader = resource_manager.request::<Shader, _>("my_grass_shader.ron").await.unwrap();
|
||||
///
|
||||
/// // Here we assume that the material really has the properties defined below.
|
||||
/// let mut material = Material::from_shader(shader, Some(resource_manager));
|
||||
|
||||
@@ -216,7 +216,7 @@
|
||||
//! flexible. To get standard shader instance, use [`ShaderResource::standard`]
|
||||
//!
|
||||
//! ```no_run
|
||||
//! # use fyrox::material::shader::ShaderResource;
|
||||
//! # use fyrox::material::shader::{ShaderResource, ShaderResourceExtension};
|
||||
//!
|
||||
//! let standard_shader = ShaderResource::standard();
|
||||
//! ```
|
||||
|
||||
+3
-2
@@ -711,10 +711,11 @@ impl ColorGradingLut {
|
||||
///
|
||||
/// ```no_run
|
||||
/// use fyrox::scene::camera::ColorGradingLut;
|
||||
/// use fyrox::engine::resource_manager::{ResourceManager};
|
||||
/// use fyrox::asset::manager::{ResourceManager};
|
||||
/// use fyrox::resource::texture::Texture;
|
||||
///
|
||||
/// async fn create_lut(resource_manager: ResourceManager) -> ColorGradingLut {
|
||||
/// ColorGradingLut::new(resource_manager.request_texture(
|
||||
/// ColorGradingLut::new(resource_manager.request::<Texture, _>(
|
||||
/// "your_lut.jpg",
|
||||
/// ))
|
||||
/// .await
|
||||
|
||||
+3
-2
@@ -58,7 +58,7 @@ use std::ops::{Deref, DerefMut};
|
||||
///
|
||||
/// ```
|
||||
/// use fyrox::{
|
||||
/// engine::resource_manager::ResourceManager,
|
||||
/// asset::manager::ResourceManager,
|
||||
/// core::pool::Handle,
|
||||
/// scene::{
|
||||
/// node::Node,
|
||||
@@ -69,6 +69,7 @@ use std::ops::{Deref, DerefMut};
|
||||
/// },
|
||||
/// core::algebra::Vector3
|
||||
/// };
|
||||
/// use fyrox::resource::texture::Texture;
|
||||
///
|
||||
/// fn create_bullet_hole(resource_manager: ResourceManager, graph: &mut Graph) -> Handle<Node> {
|
||||
/// DecalBuilder::new(
|
||||
@@ -78,7 +79,7 @@ use std::ops::{Deref, DerefMut};
|
||||
/// .with_local_scale(Vector3::new(2.0, 2.0, 2.0))
|
||||
/// .build()
|
||||
/// ))
|
||||
/// .with_diffuse_texture(resource_manager.request_texture("bullet_hole.png"))
|
||||
/// .with_diffuse_texture(resource_manager.request::<Texture, _>("bullet_hole.png"))
|
||||
/// .build(graph)
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//! emitter::sphere::SphereEmitter, ParticleSystemBuilder, emitter::Emitter,
|
||||
//! emitter::base::BaseEmitterBuilder, emitter::sphere::SphereEmitterBuilder
|
||||
//! };
|
||||
//! use fyrox::engine::resource_manager::ResourceManager;
|
||||
//! use fyrox::asset::manager::ResourceManager;
|
||||
//! use fyrox::core::algebra::Vector3;
|
||||
//! use fyrox::scene::graph::Graph;
|
||||
//! use fyrox::scene::node::Node;
|
||||
@@ -38,7 +38,7 @@
|
||||
//! use fyrox::scene::base::BaseBuilder;
|
||||
//! use fyrox::core::color::Color;
|
||||
//! use std::path::Path;
|
||||
//! use fyrox::resource::texture::TexturePixelKind;
|
||||
//! use fyrox::resource::texture::{Texture, TexturePixelKind};
|
||||
//!
|
||||
//! fn create_smoke(graph: &mut Graph, resource_manager: &mut ResourceManager, pos: Vector3<f32>) {
|
||||
//! ParticleSystemBuilder::new(BaseBuilder::new()
|
||||
@@ -65,7 +65,7 @@
|
||||
//! .with_radius(0.01)
|
||||
//! .build()
|
||||
//! ])
|
||||
//! .with_texture(resource_manager.request_texture(Path::new("data/particles/smoke_04.tga")))
|
||||
//! .with_texture(resource_manager.request::<Texture, _>(Path::new("data/particles/smoke_04.tga")))
|
||||
//! .build(graph);
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
+3
-2
@@ -51,13 +51,14 @@ use std::ops::{Deref, DerefMut};
|
||||
/// base::BaseBuilder,
|
||||
/// graph::Graph
|
||||
/// },
|
||||
/// engine::resource_manager::ResourceManager,
|
||||
/// asset::manager::ResourceManager,
|
||||
/// core::pool::{Handle},
|
||||
/// };
|
||||
/// use fyrox::resource::texture::Texture;
|
||||
///
|
||||
/// fn create_smoke(resource_manager: ResourceManager, graph: &mut Graph) -> Handle<Node> {
|
||||
/// SpriteBuilder::new(BaseBuilder::new())
|
||||
/// .with_texture(resource_manager.request_texture("smoke.png"))
|
||||
/// .with_texture(resource_manager.request::<Texture, _>("smoke.png"))
|
||||
/// .build(graph)
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
+3
-2
@@ -331,7 +331,7 @@ pub trait ScriptTrait: BaseScript + ComponentProvider {
|
||||
/// use fyrox::{
|
||||
/// core::{reflect::prelude::*, uuid::Uuid, visitor::prelude::*},
|
||||
/// impl_component_provider,
|
||||
/// scene::node::TypeUuidProvider,
|
||||
/// core::TypeUuidProvider,
|
||||
/// script::ScriptTrait,
|
||||
/// script::{ScriptContext, ScriptMessageContext, ScriptMessagePayload},
|
||||
/// };
|
||||
@@ -392,10 +392,11 @@ pub trait ScriptTrait: BaseScript + ComponentProvider {
|
||||
/// ```rust
|
||||
/// use std::str::FromStr;
|
||||
/// use fyrox::{
|
||||
/// /// core::visitor::prelude::*,
|
||||
/// core::visitor::prelude::*,
|
||||
/// core::reflect::prelude::*,
|
||||
/// core::uuid::Uuid,
|
||||
/// script::ScriptTrait,
|
||||
/// core::TypeUuidProvider,
|
||||
/// core::uuid::uuid, impl_component_provider
|
||||
/// };
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user