public static void Draw(RenderTask task, IntPtr[] selectedActors, GPUTexture target = null, GPUContext context = null, GPUTexture depthBuffer = null, bool enableDepthTest = false) { #if UNIT_TEST_COMPILANT throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set."); #else Internal_Draw(FlaxEngine.Object.GetUnmanagedPtr(task), selectedActors, FlaxEngine.Object.GetUnmanagedPtr(target), FlaxEngine.Object.GetUnmanagedPtr(context), FlaxEngine.Object.GetUnmanagedPtr(depthBuffer), enableDepthTest); #endif }
public void DrawScene(RenderTask task, GPUTexture output, RenderBuffers buffers, ref RenderView view, List <Actor> customActors = null, ActorsSources actorsSource = ActorsSources.ScenesAndCustomActors, HashSet <PostProcessEffect> customPostFx = null) { #if UNIT_TEST_COMPILANT throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set."); #else // Get unmanaged actors var actors = GetActors(customActors, out int actorsCount); // Get unmanaged postFx var postFx = GetPostFx(customPostFx, out int postFxCount); Internal_DrawScene(unmanagedPtr, GetUnmanagedPtr(task), GetUnmanagedPtr(output), GetUnmanagedPtr(buffers), ref view, actors, actorsCount, actorsSource, postFx, postFxCount); #endif }
/// <summary> /// Executes the draw calls. /// </summary> /// <param name="context">The GPU command context.</param> /// <param name="task">The render task.</param> /// <param name="output">The output texture.</param> /// <param name="outputDepth">The output depth texture.</param> /// <param name="pass">The rendering pass mode.</param> public void ExecuteDrawCalls(GPUContext context, RenderTask task, GPUTexture output, GPUTexture outputDepth, DrawPass pass) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (task == null) { throw new ArgumentNullException(nameof(task)); } if (output == null) { throw new ArgumentNullException(nameof(output)); } GPUContext.Internal_ExecuteDrawCalls(context.unmanagedPtr, task.unmanagedPtr, output.unmanagedPtr, Object.GetUnmanagedPtr(outputDepth), DrawCalls, pass); }
/// <summary> /// Initializes Flax API. Called before everything else from native code. /// </summary> /// <param name="flags">The packed flags with small meta for the API.</param> /// <param name="platform">The runtime platform.</param> internal static void Init(int flags, PlatformType platform) { Application._is64Bit = (flags & 0x01) != 0; Application._isEditor = (flags & 0x02) != 0; Application._mainThreadId = Thread.CurrentThread.ManagedThreadId; Application._platform = platform; UnhandledExceptionHandler.RegisterCatcher(); Globals.Init(); if (!Application.IsEditor) { CreateGuiStyle(); } MainRenderTask.Instance = RenderTask.Create <MainRenderTask>(); }
/// <summary> /// Initializes Flax API. Called before everything else from native code. /// </summary> /// <param name="flags">The packed flags with small meta for the API.</param> /// <param name="platform">The runtime platform.</param> internal static void Init(int flags, PlatformType platform) { Application._is64Bit = (flags & 0x01) != 0; Application._isEditor = (flags & 0x02) != 0; Application._platform = platform; UnhandledExceptionHandler.RegisterCatcher(); FlaxLogWriter.Init(); Globals.Init(); Input.Init(); if (!Application.IsEditor) { CreateGuiStyle(); } MainRenderTask.Instance = RenderTask.Create <MainRenderTask>(); }
public static void Draw(RenderTask task, Actor[] selectedActors) { #if UNIT_TEST_COMPILANT throw new NotImplementedException("Unit tests, don't support methods calls. Only properties can be get or set."); #else // Get unmanaged pointers IntPtr[] actors = null; if (selectedActors != null && selectedActors.Length > 0) { actors = new IntPtr[selectedActors.Length]; for (int i = 0; i < selectedActors.Length; i++) { actors[i] = Object.GetUnmanagedPtr(selectedActors[i]); } } Internal_Draw(Object.GetUnmanagedPtr(task), actors, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, false); #endif }
/// <summary> /// Adds the draw calls. Calculates target mesh level of detail and picks a proper meshes to draw. /// </summary> /// <param name="model">The model mesh to render. Cannot be null.</param> /// <param name="material">The material to apply during rendering. Cannot be null.</param> /// <param name="bounds">The bounds of the model instance that is being drawn (model instance bounds).</param> /// <param name="world">The world matrix used to transform mesh geometry during rendering. Use <see cref="Matrix.Identity"/> to render mesh 'as is'.</param> /// <param name="flags">The static flags. Used to describe type of the geometry.</param> /// <param name="receiveDecals">True if rendered geometry can receive decals, otherwise false.</param> public void AddDrawCall(Model model, MaterialBase material, ref BoundingSphere bounds, ref Matrix world, StaticFlags flags = StaticFlags.None, bool receiveDecals = true) { if (model == null) { throw new ArgumentNullException(nameof(model)); } // Pick a proper LOD int lodIndex = RenderTask.Internal_ComputeModelLOD(model.unmanagedPtr, ref bounds, IntPtr.Zero); var lods = model.LODs; if (lods == null || lods.Length < lodIndex || lodIndex < 0) { return; } var lod = lods[lodIndex]; // Draw meshes for (int i = 0; i < lod.Meshes.Length; i++) { AddDrawCall(lod.Meshes[i], material, ref world, flags); } }