public static extern InteropBool WindowFactory_AlterViewport(
     IntPtr failReason,
     ViewportHandle viewportHandle,
     uint topLeftX,
     uint topLeftY,
     uint widthPx,
     uint heightPx
     );
示例#2
0
        // No lock on WindowTarget.WindowMutationLock here because it's an internal method, only accessible from Window.AddViewport.
        // If that changes in the future, add a lock!
        internal SceneViewport(Window targetWindow, ViewportAnchoring anchoring, Vector2 anchorOffset, Vector2 size,
                               float nearPlaneDist, float farPlaneDist)
        {
            if (targetWindow == null)
            {
                throw new ArgumentNullException("targetWindow");
            }
            if (!Enum.IsDefined(typeof(ViewportAnchoring), anchoring))
            {
                throw new ArgumentException("Invalid enum value.", "anchoring");
            }
            //if (anchorOffset.X < 0f || anchorOffset.X > 1f || anchorOffset.Y < 0f || anchorOffset.Y > 1f) {
            //	throw new ArgumentException("Both anchor offset dimensions must be between 0f and 1f.", "anchorOffset");
            //}
            //if (size.X < 0f || size.X > 1f - anchorOffset.X || size.Y < 0f || size.Y > 1f - anchorOffset.Y) {
            //	throw new ArgumentException("combination of size and anchor offset in either dimension must be between 0f and 1f.", "size");
            //}
            if (nearPlaneDist <= 0f)
            {
                throw new ArgumentException("Near plane must be greater than 0f.", "nearPlaneDist");
            }
            if (farPlaneDist <= 0f)
            {
                throw new ArgumentException("Far plane must be greater than 0f.", "farPlaneDist");
            }

            this.TargetWindow  = targetWindow;
            this.Anchoring     = anchoring;
            this.AnchorOffset  = anchorOffset;
            this.Size          = size;
            this.NearPlaneDist = nearPlaneDist;
            this.FarPlaneDist  = farPlaneDist;

            if (targetWindow.IsClosed)
            {
                ViewportHandle = ViewportHandle.NULL;
                isDisposed     = true;
            }
            else
            {
                ViewportHandle outViewportHandle;
                unsafe {
                    InteropUtils.CallNative(NativeMethods.WindowFactory_CreateViewport,
                                            (IntPtr)(&outViewportHandle)
                                            ).ThrowOnFailure();
                }
                ViewportHandle = outViewportHandle;
            }

            TargetWindow_WindowResized(TargetWindow, TargetWindow.Width, TargetWindow.Height);
            TargetWindow.WindowResized += TargetWindow_WindowResized;
        }
 public static extern InteropBool WindowFactory_DestroyViewport(
     IntPtr failReason,
     ViewportHandle viewportHandle
     );