Exemple #1
0
 /// <summary>
 /// QuadTreeNode constructor
 /// </summary>
 /// <param name="rect">The rectangle of the QuadTreeNode</param>
 /// <param name="maxItems">Maximum number of items in the QuadTreeNode before partitioning</param>
 /// <param name="worldResize">The function to return the size</param>
 public QuadTreeNode(DRect rect, int maxItems, ResizeDelegate worldResize)
 {
     ParentNode    = null;
     Rect          = rect;
     MaxItems      = maxItems;
     WorldResize   = worldResize;
     IsPartitioned = false;
     Items         = new List <QuadTreePositionItem <T> >();
 }
        public static void Run(string sourceFileName, string outputFolderPath, double[] ratios)
        {
            using (var processor = ImageProcessor.FromFile(sourceFileName))
            {
                var countdown = new CountdownEvent(ratios.Length);

                foreach (var ratio in ratios)
                {
                    ResizeDelegate resizer = DoResize;

                    resizer.BeginInvoke(
                        processor,
                        ratio,
                        SaveImage(outputFolderPath, countdown),
                        null);
                }

                countdown.Wait();
            }
        }
Exemple #3
0
 unsafe public t_field_type(object foo, ResizeDelegate bar)
 {
 }
Exemple #4
0
    ///
    public static bool LoadPlugin(bool force_opencl)
    {
        bool use_nvidia = SystemInfo.graphicsDeviceName.Contains("NVIDIA") ||
                          SystemInfo.graphicsDeviceName.Contains("GeForce");

        function_ptrs = new IntPtr[function_names.Length];
    #if (UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX)
        if (use_nvidia && !force_opencl)
        {
        #if (UNITY_EDITOR)
            handle = dlopen("Assets/Rove/ImportedPlugins/x86_64/libRoveGLCUDA.so", 2);
        #else
            handle = dlopen(Application.dataPath + "/Rove/Data/libRoveGLCUDA.so", 2);
        #endif
            if (handle == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get library.");
                string error = Marshal.PtrToStringAuto(dlerror());
                Debug.LogError(error);
                return(false);
            }
        }
        else
        {
        #if (UNITY_EDITOR)
            handle = dlopen("Assets/Rove/ImportedPlugins/x86_64/libRoveGLCL.so", 2);
        #else
            handle = dlopen(Application.dataPath + "/Rove/Data/libRoveGLCL.so", 2);
        #endif
            if (handle == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get library.");
                string error = Marshal.PtrToStringAuto(dlerror());
                Debug.LogError(error);
                return(false);
            }
        }
        for (uint fi = 1; fi < function_names.Length; ++fi)
        {
            function_ptrs[fi] = dlsym(handle, function_names[fi]);
            if (function_ptrs[fi] == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get function pointer: " +
                               function_names[fi]);
                string error = Marshal.PtrToStringAuto(dlerror());
                Debug.LogError(error);
                return(false);
            }
        }
    #elif (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX)
        if (use_nvidia && !force_opencl)
        {
        #if (UNITY_EDITOR)
            handle = dlopen("Assets/Rove/ImportedPlugins/x86_64/RoveGLCUDA.bundle", 2);
        #else
            handle = dlopen(Application.dataPath + "/Rove/Data/RoveGLCUDA.bundle", 2);
        #endif
            if (handle == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get library.");
                string error = Marshal.PtrToStringAuto(dlerror());
                Debug.LogError(error);
                return(false);
            }
        }
        else
        {
        #if (UNITY_EDITOR)
            handle = dlopen("Assets/Rove/ImportedPlugins/x86_64/RoveGLCL.bundle", 2);
        #else
            handle = dlopen(Application.dataPath + "/Rove/Data/RoveGLCL.bundle", 2);
        #endif
            if (handle == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get library.");
                string error = Marshal.PtrToStringAuto(dlerror());
                Debug.LogError(error);
                return(false);
            }
        }
        for (uint fi = 1; fi < function_names.Length; ++fi)
        {
            function_ptrs[fi] = dlsym(handle, function_names[fi]);
            if (function_ptrs[fi] == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get function pointer: " +
                               function_names[fi]);
                string error = Marshal.PtrToStringAuto(dlerror());
                Debug.LogError(error);
                return(false);
            }
        }
    #elif (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
        if (use_nvidia && !force_opencl)
        {
        #if (ROVE_FORCE_GL)
          #if (UNITY_EDITOR)
            handle = LoadLibrary("Assets/Rove/ImportedPlugins/x86_64/RoveGLCUDA.dll");
          #else
            handle = LoadLibrary(Application.dataPath + "/Rove/Data/RoveGLCUDA.dll");
          #endif
        #else
          #if (UNITY_EDITOR)
            handle = LoadLibrary("Assets/Rove/ImportedPlugins/x86_64/RoveD3D11CUDA.dll");
          #else
            handle = LoadLibrary(Application.dataPath + "/Rove/Data/RoveD3D11CUDA.dll");
          #endif
        #endif
            if (handle == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get library.");
                Debug.LogError("Error code: " + GetLastError() + ".");
                return(false);
            }
        }
        else
        {
        #if (ROVE_FORCE_GL)
          #if (UNITY_EDITOR)
            handle = LoadLibrary("Assets/Rove/ImportedPlugins/x86_64/RoveGLCL.dll");
          #else
            handle = LoadLibrary(Application.dataPath + "/Rove/Data/RoveGLCL.dll");
          #endif
        #else
          #if (UNITY_EDITOR)
            handle = LoadLibrary("Assets/Rove/ImportedPlugins/x86_64/RoveD3D11CL.dll");
          #else
            handle = LoadLibrary(Application.dataPath + "/Rove/Data/RoveD3D11CL.dll");
          #endif
        #endif
            if (handle == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get library.");
                Debug.LogError("Error code: " + GetLastError() + ".");
                return(false);
            }
        }
      #if (ROVE_FORCE_GL)
        for (uint fi = 1; fi < function_names.Length; ++fi)
        {
      #else
        for (uint fi = 0; fi < function_names.Length; ++fi)
        {
      #endif
            function_ptrs[fi] = GetProcAddress(handle, function_names[fi]);
            if (function_ptrs[fi] == IntPtr.Zero)
            {
                Debug.LogError("Rove: Failed to get function pointer: " +
                               function_names[fi]);
                Debug.LogError("Error code: " + GetLastError() + ".");
                return(false);
            }
        }
#endif
        uint i = 0;
    #if ((!ROVE_FORCE_GL) && (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN))
        SetD3D11Device = (SetD3D11DeviceDelegate)
                         Marshal.GetDelegateForFunctionPointer(function_ptrs[i++],
                                                               typeof(SetD3D11DeviceDelegate));
    #else
        ++i;
    #endif
        GetLock = (GetLockDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(GetLockDelegate));
        Setup = (SetupDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(SetupDelegate));
        Shutdown = (ShutdownDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(ShutdownDelegate));
        Resize = (ResizeDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(ResizeDelegate));
        StartUpdate = (StartUpdateDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(StartUpdateDelegate));
        FinishUpdate = (FinishUpdateDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(FinishUpdateDelegate));
        ResetRenderAtStart =
            (ResetRenderAtStartDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(ResetRenderAtStartDelegate));
        ResetRenderAtEnd =
            (ResetRenderAtEndDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(ResetRenderAtEndDelegate));
        GetThreadCount =
            (GetThreadCountDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(GetThreadCountDelegate));
        GetComputeAPI =
            (GetComputeAPIDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(GetComputeAPIDelegate));
        GetDeviceCount =
            (GetDeviceCountDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(GetDeviceCountDelegate));
        GetDeviceName =
            (GetDeviceNameDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(GetDeviceNameDelegate));
        ImportMesh = (ImportMeshDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(ImportMeshDelegate));
        FreeMesh = (FreeMeshDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(FreeMeshDelegate));
        DefineSubMesh = (DefineSubMeshDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(DefineSubMeshDelegate));
        ChangeSubMeshMaterial =
            (ChangeSubMeshMaterialDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(ChangeSubMeshMaterialDelegate));
        SetMeshTransform =
            (SetMeshTransformDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMeshTransformDelegate));
        AddMaterial = (AddMaterialDelegate)Marshal.GetDelegateForFunctionPointer(
            function_ptrs[i++], typeof(AddMaterialDelegate));
        SetMaterialMapFlags =
            (SetMaterialMapFlagsDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialMapFlagsDelegate));
        SetMaterialDoubleSided =
            (SetMaterialDoubleSidedDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialDoubleSidedDelegate));
        SetMaterialAlbedo =
            (SetMaterialAlbedoDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialAlbedoDelegate));
        SetMaterialMetallic =
            (SetMaterialMetallicDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialMetallicDelegate));
        SetMaterialSmoothness =
            (SetMaterialSmoothnessDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialSmoothnessDelegate));
        SetMaterialGlass =
            (SetMaterialGlassDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialGlassDelegate));
        SetMaterialEmission =
            (SetMaterialEmissionDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialEmissionDelegate));
        SetMaterialAlbedoBounds =
            (SetMaterialAlbedoBoundsDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialAlbedoBoundsDelegate));
        SetMaterialNormalBounds =
            (SetMaterialNormalBoundsDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialNormalBoundsDelegate));
        SetMaterialMetallicBounds =
            (SetMaterialMetallicBoundsDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialMetallicBoundsDelegate));
        SetMaterialEmissionBounds =
            (SetMaterialEmissionBoundsDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaterialEmissionBoundsDelegate));
        SetAlbedoAtlas =
            (SetAlbedoAtlasDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetAlbedoAtlasDelegate));
        SetNormalAtlas =
            (SetNormalAtlasDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetNormalAtlasDelegate));
        SetMetallicAtlas =
            (SetMetallicAtlasDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMetallicAtlasDelegate));
        SetEmissionAtlas =
            (SetEmissionAtlasDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetEmissionAtlasDelegate));
        SetFieldOfView =
            (SetFieldOfViewDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetFieldOfViewDelegate));
        SetMaxBounces =
            (SetMaxBouncesDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetMaxBouncesDelegate));
        SetSamplesPerFrame =
            (SetSamplesPerFrameDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetSamplesPerFrameDelegate));
        SetImageProperties =
            (SetImagePropertiesDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetImagePropertiesDelegate));
        SetCameraApertureSize =
            (SetCameraApertureSizeDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetCameraApertureSizeDelegate));
        SetCameraFocalDepth =
            (SetCameraFocalDepthDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetCameraFocalDepthDelegate));
        SetCameraTransform =
            (SetCameraTransformDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetCameraTransformDelegate));
        SetEnvironmentType =
            (SetEnvironmentTypeDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetEnvironmentTypeDelegate));
        SetSunDirection =
            (SetSunDirectionDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetSunDirectionDelegate));
        SetSkyIntensity =
            (SetSkyIntensityDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetSkyIntensityDelegate));
        SetSunIntensity =
            (SetSunIntensityDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetSunIntensityDelegate));
        SetSunColor =
            (SetSunColorDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetSunColorDelegate));
        SetEnvironmentMap =
            (SetEnvironmentMapDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetEnvironmentMapDelegate));
        SetEnvironmentProperties =
            (SetEnvironmentPropertiesDelegate)Marshal.GetDelegateForFunctionPointer(
                function_ptrs[i++], typeof(SetEnvironmentPropertiesDelegate));
        return(true);
    }
 public void subscribeToResize(ResizeDelegate resizeDelegate)
 {
     this.resizeDelegate += resizeDelegate;
 }
 internal Error Resize(IntPtr src, ref IntPtr dst, int width, int height, ResizeMethod method)
 {
     this.ThrowIfDisposed();
     if(this._ResizeDelegate == null){
         this._ResizeDelegate = this.LoadMethod<ResizeDelegate>("gflResize");
     }
     return this._ResizeDelegate(src, ref dst, width, height, method, 0);
 }