コード例 #1
0
 /// <summary>
 /// Set minimum size for resize to the minimum size of the window, set content size to that of the window.
 /// </summary>
 void adaptSizeToContent()
 {
     if (resizePanel != null)
     {
         resizePanel.minSize = minimumSize_.ToVector2() + margin.ToVector2();
     }
     (transform as RectTransform).sizeDelta = minimumSize_.ToVector2() + margin.ToVector2();
     if (content != null && content.GetComponent <DynamicXmlWidget>() != null)
     {
         (transform as RectTransform).sizeDelta = content.GetComponent <DynamicXmlWidget>().minimumSize.ToVector2() + margin.ToVector2();
     }
     else if (content != null && content.GetComponent <LayoutElement>() != null)
     {
         if (content.GetComponent <LayoutElement>().minWidth < 0 && content.GetComponent <LayoutElement>().minHeight < 0)
         {
             return;
         }
         Vector2 size = margin.ToVector2();
         if (content.GetComponent <LayoutElement>().minWidth >= 0)
         {
             size.x += content.GetComponent <LayoutElement>().minWidth;
         }
         if (content.GetComponent <LayoutElement>().minHeight >= 0)
         {
             size.y += content.GetComponent <LayoutElement>().minHeight;
         }
         (transform as RectTransform).sizeDelta = size;
         resizePanel.minSize = size;
     }
 }
コード例 #2
0
        public DepthStencil(IDisposableResource parent, int width, int height, DepthStencilFormats depthStencilFormats)
            : base(parent)
        {
            try
            {
                var video = parent.FindParentOrSelfWithException <Video>();
                Size  = new Size2(width, height);
                SizeF = Size.ToVector2();

                int depthBit = 16, stencilBit = 0;
                switch (depthStencilFormats)
                {
                case DepthStencilFormats.Defualt:
                    depthBit   = 24;
                    stencilBit = 0;
                    break;

                case DepthStencilFormats.Depth24Stencil8:
                    depthBit   = 24;
                    stencilBit = 8;
                    break;

                case DepthStencilFormats.Depth16:
                    depthBit   = 16;
                    stencilBit = 0;
                    break;

                case DepthStencilFormats.Depth24:
                    depthBit   = 24;
                    stencilBit = 0;
                    break;

                case DepthStencilFormats.Depth32:
                    depthBit   = 32;
                    stencilBit = 0;
                    break;

                default:
                    Debug.ThrowError("Video", "Unsuported DepthStencilFormat type");
                    break;
                }

                com = new DepthStencilCom();
                var error = com.Init(video.com, width, height, depthBit, stencilBit);

                switch (error)
                {
                case DepthStencilErrors.Textrue: Debug.ThrowError("DepthStencil", "Failed to create Texture2D"); break;

                case DepthStencilErrors.DepthStencilView: Debug.ThrowError("DepthStencil", "Failed to create DepthStencilView"); break;
                }
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }
コード例 #3
0
ファイル: DepthStencil.cs プロジェクト: reignstudios/ReignSDK
        public DepthStencil(IDisposableResource parent, int width, int height, DepthStencilFormats depthStencilFormats)
            : base(parent)
        {
            try
            {
                var video = parent.FindParentOrSelfWithException<Video>();
                Size = new Size2(width, height);
                SizeF = Size.ToVector2();

                int depthBit = 16, stencilBit = 0;
                switch (depthStencilFormats)
                {
                    case DepthStencilFormats.Defualt:
                        depthBit = 24;
                        stencilBit = 0;
                        break;

                    case DepthStencilFormats.Depth24Stencil8:
                        depthBit = 24;
                        stencilBit = 8;
                        break;

                    case DepthStencilFormats.Depth16:
                        depthBit = 16;
                        stencilBit = 0;
                        break;

                    case DepthStencilFormats.Depth24:
                        depthBit = 24;
                        stencilBit = 0;
                        break;

                    case DepthStencilFormats.Depth32:
                        depthBit = 32;
                        stencilBit = 0;
                        break;

                    default:
                        Debug.ThrowError("Video", "Unsuported DepthStencilFormat type");
                        break;
                }

                com = new DepthStencilCom();
                var error = com.Init(video.com, width, height, depthBit, stencilBit);

                switch (error)
                {
                    case DepthStencilErrors.Textrue: Debug.ThrowError("DepthStencil", "Failed to create Texture2D"); break;
                    case DepthStencilErrors.DepthStencilView: Debug.ThrowError("DepthStencil", "Failed to create DepthStencilView"); break;
                }
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }
コード例 #4
0
ファイル: DepthStencil.cs プロジェクト: damian-666/ReignSDK
        private void init(IDisposableResource parent, int width, int height, DepthStencilFormats depthStencilFormats)
        {
            try
            {
                this.width  = width;
                this.height = height;
                this.depthStencilFormats = depthStencilFormats;

                video = parent.FindParentOrSelfWithException <Video>();
                Size  = new Size2(width, height);
                SizeF = Size.ToVector2();

                int depthBit = 16, stencilBit = 0;
                switch (depthStencilFormats)
                {
                case DepthStencilFormats.Defualt:
                    depthBit   = 24;
                    stencilBit = 0;
                    break;

                case DepthStencilFormats.Depth24Stencil8:
                    depthBit   = 24;
                    stencilBit = 8;
                    break;

                case DepthStencilFormats.Depth16:
                    depthBit   = 16;
                    stencilBit = 0;
                    break;

                case DepthStencilFormats.Depth24:
                    depthBit   = 24;
                    stencilBit = 0;
                    break;

                case DepthStencilFormats.Depth32:
                    depthBit   = 32;
                    stencilBit = 0;
                    break;

                default:
                    Debug.ThrowError("Video", "Unsuported DepthStencilFormat type");
                    break;
                }

                com = new DepthStencilCom();
                var error = com.Init(video.com, width, height, depthBit, stencilBit);

                switch (error)
                {
                case DepthStencilErrors.DepthStencilSurface: Debug.ThrowError("DepthStencil", "Failed to create DepthStencil Surface"); break;
                }

                if (!video.Caps.ExDevice && !video.deviceReseting)
                {
                    video.DeviceLost  += deviceLost;
                    video.DeviceReset += deviceReset;
                }
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }
コード例 #5
0
ファイル: DepthStencil.cs プロジェクト: reignstudios/ReignSDK
        private void init(IDisposableResource parent, int width, int height, DepthStencilFormats depthStencilFormats)
        {
            try
            {
                this.width = width;
                this.height = height;
                this.depthStencilFormats = depthStencilFormats;

                video = parent.FindParentOrSelfWithException<Video>();
                Size = new Size2(width, height);
                SizeF = Size.ToVector2();

                int depthBit = 16, stencilBit = 0;
                switch (depthStencilFormats)
                {
                    case DepthStencilFormats.Defualt:
                        depthBit = 24;
                        stencilBit = 0;
                        break;

                    case DepthStencilFormats.Depth24Stencil8:
                        depthBit = 24;
                        stencilBit = 8;
                        break;

                    case DepthStencilFormats.Depth16:
                        depthBit = 16;
                        stencilBit = 0;
                        break;

                    case DepthStencilFormats.Depth24:
                        depthBit = 24;
                        stencilBit = 0;
                        break;

                    case DepthStencilFormats.Depth32:
                        depthBit = 32;
                        stencilBit = 0;
                        break;

                    default:
                        Debug.ThrowError("Video", "Unsuported DepthStencilFormat type");
                        break;
                }

                com = new DepthStencilCom();
                var error = com.Init(video.com, width, height, depthBit, stencilBit);

                switch (error)
                {
                    case DepthStencilErrors.DepthStencilSurface: Debug.ThrowError("DepthStencil", "Failed to create DepthStencil Surface"); break;
                }

                if (!video.Caps.ExDevice && !video.deviceReseting)
                {
                    video.DeviceLost += deviceLost;
                    video.DeviceReset += deviceReset;
                }
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }
コード例 #6
0
ファイル: DepthStencil.cs プロジェクト: reignstudios/ReignSDK
        public unsafe DepthStencil(IDisposableResource parent, int width, int height, DepthStencilFormats depthStencilFormats)
            : base(parent)
        {
            try
            {
                uint depthBit = GL.DEPTH_COMPONENT16, stencilBit = 0;
                switch (depthStencilFormats)
                {
                    case DepthStencilFormats.Defualt:
                        #if iOS || ANDROID || NaCl || RPI
                        depthBit = GL.DEPTH_COMPONENT16;
                        stencilBit = 0;
                        #else
                        depthBit = GL.DEPTH_COMPONENT24;
                        stencilBit = 0;
                        #endif
                        break;

                    case DepthStencilFormats.Depth24Stencil8:
                        depthBit = GL.DEPTH_COMPONENT24;
                        stencilBit = GL.STENCIL_INDEX8;
                        break;

                    case DepthStencilFormats.Depth16:
                        depthBit = GL.DEPTH_COMPONENT16;
                        stencilBit = 0;
                        break;

                    case DepthStencilFormats.Depth24:
                        depthBit = GL.DEPTH_COMPONENT24;
                        stencilBit = 0;
                        break;

                    case DepthStencilFormats.Depth32:
                        depthBit = GL.DEPTH_COMPONENT32;
                        stencilBit = 0;
                        break;

                    default:
                        Debug.ThrowError("DepthStencil", "Unsuported DepthStencilFormat type");
                        break;
                }

                Size = new Size2(width, height);
                SizeF = Size.ToVector2();

                // create depth
                uint surfaceTEMP = 0;
                GL.GenRenderbuffers(1, &surfaceTEMP);
                if (surfaceTEMP == 0) Debug.ThrowError("DpethStencil", "Failed to create DepthBuffer");
                depthBuffer = surfaceTEMP;

                GL.BindRenderbuffer(GL.RENDERBUFFER, depthBuffer);
                GL.RenderbufferStorage(GL.RENDERBUFFER, depthBit, width, height);

                // create stencil
                if (stencilBit != 0)
                {
                    surfaceTEMP = 0;
                    GL.GenRenderbuffers(1, &surfaceTEMP);
                    if (surfaceTEMP == 0) Debug.ThrowError("DpethStencil", "Failed to create StencilBuffer");
                    stencilBuffer = surfaceTEMP;

                    GL.BindRenderbuffer(GL.RENDERBUFFER, stencilBuffer);
                    GL.RenderbufferStorage(GL.RENDERBUFFER, stencilBit, width, height);
                }

                uint error;
                string errorName;
                if (Video.checkForError(out error, out errorName)) Debug.ThrowError("DepthStencil", string.Format("{0} {1}: Failed to create DepthStencil", error, errorName));
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }
コード例 #7
0
ファイル: DepthStencil.cs プロジェクト: damian-666/ReignSDK
        public unsafe DepthStencil(IDisposableResource parent, int width, int height, DepthStencilFormats depthStencilFormats)
            : base(parent)
        {
            try
            {
                uint depthBit = GL.DEPTH_COMPONENT16, stencilBit = 0;
                switch (depthStencilFormats)
                {
                case DepthStencilFormats.Defualt:
                                                #if iOS || ANDROID || NaCl || RPI
                    depthBit   = GL.DEPTH_COMPONENT16;
                    stencilBit = 0;
                                                #else
                    depthBit   = GL.DEPTH_COMPONENT24;
                    stencilBit = 0;
                                                #endif
                    break;

                case DepthStencilFormats.Depth24Stencil8:
                    depthBit   = GL.DEPTH_COMPONENT24;
                    stencilBit = GL.STENCIL_INDEX8;
                    break;

                case DepthStencilFormats.Depth16:
                    depthBit   = GL.DEPTH_COMPONENT16;
                    stencilBit = 0;
                    break;

                case DepthStencilFormats.Depth24:
                    depthBit   = GL.DEPTH_COMPONENT24;
                    stencilBit = 0;
                    break;

                case DepthStencilFormats.Depth32:
                    depthBit   = GL.DEPTH_COMPONENT32;
                    stencilBit = 0;
                    break;

                default:
                    Debug.ThrowError("DepthStencil", "Unsuported DepthStencilFormat type");
                    break;
                }

                Size  = new Size2(width, height);
                SizeF = Size.ToVector2();

                // create depth
                uint surfaceTEMP = 0;
                GL.GenRenderbuffers(1, &surfaceTEMP);
                if (surfaceTEMP == 0)
                {
                    Debug.ThrowError("DpethStencil", "Failed to create DepthBuffer");
                }
                depthBuffer = surfaceTEMP;

                GL.BindRenderbuffer(GL.RENDERBUFFER, depthBuffer);
                GL.RenderbufferStorage(GL.RENDERBUFFER, depthBit, width, height);

                // create stencil
                if (stencilBit != 0)
                {
                    surfaceTEMP = 0;
                    GL.GenRenderbuffers(1, &surfaceTEMP);
                    if (surfaceTEMP == 0)
                    {
                        Debug.ThrowError("DpethStencil", "Failed to create StencilBuffer");
                    }
                    stencilBuffer = surfaceTEMP;

                    GL.BindRenderbuffer(GL.RENDERBUFFER, stencilBuffer);
                    GL.RenderbufferStorage(GL.RENDERBUFFER, stencilBit, width, height);
                }

                uint   error;
                string errorName;
                if (Video.checkForError(out error, out errorName))
                {
                    Debug.ThrowError("DepthStencil", string.Format("{0} {1}: Failed to create DepthStencil", error, errorName));
                }
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }