예제 #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="displaySize">
        /// Size object describing the initial display resolution.
        /// </param>
        protected OpenGLRendererBase(Sizef displaySize)
        {
            d_displaySize = displaySize;

            Init();
            d_defaultTarget = new OpenGLViewportTarget(this);
        }
예제 #2
0
        /// <summary>
        /// Updates the rendering state for the specified \a item using the specified
        /// \a index as the data source.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="index"></param>
        /// <param name="maxWidth"></param>
        /// <param name="totalHeight"></param>
        private void UpdateItem(ListViewItemRenderingState item, ModelIndex index, ref float maxWidth, ref float totalHeight)
        {
            var text           = d_itemModel.GetData(index);
            var isSelected     = IsIndexSelected(index);
            var initialColours = isSelected ? _selectionTextColourRect : d_textColourRect;
            var renderedString = GetRenderedStringParser().Parse(text, GetFont(), initialColours);

            item.d_string = renderedString;
            item.d_index  = index;
            item.d_text   = text;
            item.d_icon   = d_itemModel.GetData(index, ItemDataRole.IDR_Icon);

            var iconSize = Sizef.Zero;

            if (!String.IsNullOrEmpty(item.d_icon))
            {
                iconSize = ImageManager.GetSingleton().Get(item.d_icon).GetRenderedSize();
            }

            var textSize = new Sizef(renderedString.GetHorizontalExtent(this), renderedString.GetVerticalExtent(this));

            item.d_size = new Sizef(iconSize.Width + textSize.Width, Math.Max(iconSize.Height, textSize.Height));

            maxWidth = Math.Max(item.d_size.Width, maxWidth);

            totalHeight += item.d_size.Height;

            item.d_isSelected = isSelected;//IsIndexSelected(index);
        }
예제 #3
0
 /// <summary>
 /// Constructor that wraps an existing GL texture.
 /// </summary>
 /// <param name="tex"></param>
 /// <param name="size"></param>
 protected internal void Initialise(int /*GLuint*/ tex, Sizef size)
 {
     d_ogltexture = tex;
     d_size       = size;
     d_dataSize   = size;
     InitInternalPixelFormatFields(PixelFormat.RGBA);
     UpdateCachedScaleValues();
 }
예제 #4
0
        /// <summary>
        /// set the size of the internal texture.
        /// </summary>
        /// <param name="sz">
        /// size for the internal texture, in pixels.
        /// </param>
        /// <remarks>
        /// Depending upon the hardware capabilities, the actual final size of the
        /// texture may be larger than what is specified when calling this function.
        /// The texture will never be smaller than what you request here.  To
        /// discover the actual size, call getSize.
        /// </remarks>
        /// <exception cref="InvalidOperationException">
        /// thrown if the hardware is unable to support a texture large enough to
        /// fulfill the requested size.
        /// </exception>
        public void SetTextureSize(Sizef sz)
        {
            InitInternalPixelFormatFields(PixelFormat.RGBA);

            SetTextureSizeImpl(sz);

            d_dataSize = d_size;
            UpdateCachedScaleValues();
        }
예제 #5
0
        /// <summary>
        /// helper to set display size with current viewport size.
        /// </summary>
        protected void InitialiseDisplaySizeWithViewportSize()
        {
            ThrowIfDisposed();

            var vp = new int[4];

            OpenGL.GL.GetInteger(OpenGL.GetPName.Viewport, vp);
            d_displaySize = new Sizef((float)vp[2], (float)vp[3]);
        }
예제 #6
0
        public override void AutoPositionSize(Lunatics.Mathematics.Vector2 position, Sizef ownerSize)
        {
            var view      = GetView();
            var totalArea = view.GetUnclippedOuterRect().Get();

            var contentArea           = _itemViewRenderer.GetViewRenderArea(view, false, false);
            var withScrollContentArea = _itemViewRenderer.GetViewRenderArea(view, true, true);

            var frameSize           = totalArea.Size - contentArea.Size;
            var withScrollFrameSize = totalArea.Size - withScrollContentArea.Size;
            var contentSize         = new Sizef(view.GetRenderedMaxWidth(), view.GetRenderedTotalHeight());

            var parentSize = view.GetParentPixelSize();
            var maxSize    =
                new Sizef(ownerSize.Width /*parentSize.Width - CoordConverter.AsAbsolute(view.GetXPosition(), parentSize.Width)*/,
                          0.8f * parentSize.Height /*CoordConverter.AsAbsolute(view.GetYPosition(), parentSize.Height)*/);

            var requiredSize = frameSize + contentSize + new Sizef(1, 1);

            if (requiredSize.Height > maxSize.Height)
            {
                requiredSize.Height = maxSize.Height;
                requiredSize.Width  = Math.Min(maxSize.Width,
                                               requiredSize.Width - frameSize.Width + withScrollFrameSize.Width);
                view.SetVertScrollbarDisplayMode(ScrollbarDisplayMode.Shown);
            }
            else
            {
                view.SetVertScrollbarDisplayMode(ScrollbarDisplayMode.Hidden);
            }

            requiredSize.Width = ownerSize.Width;
            if (requiredSize.Width > maxSize.Width)
            {
                requiredSize.Width  = maxSize.Width;
                requiredSize.Height = Math.Min(maxSize.Height,
                                               requiredSize.Height - frameSize.Height + withScrollFrameSize.Height);
                view.SetHorzScrollbarDisplayMode(ScrollbarDisplayMode.Shown);
            }
            else
            {
                view.SetHorzScrollbarDisplayMode(ScrollbarDisplayMode.Hidden);
            }

            var posY = position.Y + (ownerSize.Height - requiredSize.Height) / 2f;

            posY  = posY < 0f ? 0f : posY;
            posY -= posY + requiredSize.Height > parentSize.Height
                    //? parentSize.Height - (posY + requiredSize.Height + 1f)
                                  ? (posY + requiredSize.Height) - parentSize.Height
                                  : 0f;

            view.SetPosition(new UVector2(UDim.Absolute(position.X), UDim.Absolute(posY)));
            view.SetHeight(new UDim(0, requiredSize.Height));
            view.SetWidth(new UDim(0, requiredSize.Width));
        }
예제 #7
0
 public TreeViewItemRenderingState(TreeView attached_tree_view)
 {
     d_totalChildCount   = 0;
     d_size              = Sizef.Zero;
     d_isSelected        = false;
     d_childId           = 0;
     d_subtreeIsExpanded = false;
     d_nestedLevel       = 0;
     d_attachedTreeView  = attached_tree_view;
 }
예제 #8
0
        public virtual Sizef getSize()
        {
            Sizef ret = new Sizef(solar_api_input_filesPINVOKE.IMarker2DSquared_getSize(swigCPtr), false);

            if (solar_api_input_filesPINVOKE.SWIGPendingException.Pending)
            {
                throw solar_api_input_filesPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
예제 #9
0
        public override void ResizeListToContent(bool fitWidth, bool fitHeight)
        {
            var lb = (Listbox)Window;

            var totalArea   = lb.GetUnclippedOuterRect().Get();
            var contentArea = GetItemRenderingArea(!fitWidth && lb.GetHorzScrollbar().IsVisible(),
                                                   !fitHeight && lb.GetVertScrollbar().IsVisible());

            var withScrollContentArea = GetItemRenderingArea(true, true);

            var frameSize           = totalArea.Size - contentArea.Size;
            var withScrollFrameSize = totalArea.Size - withScrollContentArea.Size;
            var contentSize         = new Sizef(lb.GetWidestItemWidth(),
                                                lb.GetTotalItemsHeight());

            var parentSize = lb.GetParentPixelSize();
            var maxSize    =
                new Sizef(parentSize.Width - CoordConverter.AsAbsolute(lb.GetXPosition(), parentSize.Width),
                          parentSize.Height - CoordConverter.AsAbsolute(lb.GetYPosition(), parentSize.Height));

            var requiredSize = frameSize + contentSize + new Sizef(1, 1);

            if (fitHeight)
            {
                if (requiredSize.Height > maxSize.Height)
                {
                    requiredSize.Height = maxSize.Height;
                    requiredSize.Width  = Math.Min(maxSize.Width,
                                                   requiredSize.Width - frameSize.Width +
                                                   withScrollFrameSize.Width);
                }
            }

            if (fitWidth)
            {
                if (requiredSize.Width > maxSize.Width)
                {
                    requiredSize.Width  = maxSize.Width;
                    requiredSize.Height = Math.Min(maxSize.Height,
                                                   requiredSize.Height - frameSize.Height +
                                                   withScrollFrameSize.Height);
                }
            }

            if (fitHeight)
            {
                lb.SetHeight(new UDim(0, requiredSize.Height));
            }

            if (fitWidth)
            {
                lb.SetWidth(new UDim(0, requiredSize.Width));
            }
        }
예제 #10
0
        /// <summary>
        /// Constructor for OpenGL Renderer objects.
        /// </summary>
        /// <param name="displaySize">
        /// Size object describing the initial display resolution.
        /// </param>
        protected OpenGL3Renderer(Sizef displaySize)
            : base(displaySize)
        {
            d_shaderWrapperTextured = null;
            d_openGLStateChanger    = null;
            d_shaderManager         = null;

            InitialiseRendererIDString();
            d_openGLStateChanger = new OpenGL3StateChangeWrapper();
            InitialiseTextureTargetFactory();
            InitialiseOpenGLShaders();
        }
예제 #11
0
        protected override int GetCompressedTextureSize(Sizef pixelSize)
        {
            var blocksize = 16;

            if (d_format == (OpenGL.PixelFormat) 0x83F0 /*GL_COMPRESSED_RGB_S3TC_DXT1_EXT*/ ||
                d_format == (OpenGL.PixelFormat) 0x83F1 /*GL_COMPRESSED_RGBA_S3TC_DXT1_EXT*/)
            {
                blocksize = 8;
            }

            return((int)(Math.Ceiling(pixelSize.Width / 4) * Math.Ceiling(pixelSize.Height / 4) * blocksize));
        }
예제 #12
0
        protected override void SetTextureSizeImpl(Sizef sz)
        {
            var size = _owner.GetAdjustedTextureSize(sz);

            d_size = size;

            // make sure size is within boundaries
            float /*GLfloat*/ maxSize;

            OpenGL.GL.GetFloat(OpenGL.GetPName.MaxTextureSize, out maxSize);

            if ((size.Width > maxSize) || (size.Height > maxSize))
            {
                throw new InvalidOperationException("size too big");
            }

            // save old texture binding
            int /*GLuint*/ oldTex;

            OpenGL.GL.GetInteger(OpenGL.GetPName.TextureBinding2D, out oldTex);

            // set texture to required size
            OpenGL.GL.BindTexture(OpenGL.TextureTarget.Texture2D, d_ogltexture);

            if (d_isCompressed)
            {
                var imageSize = GetCompressedTextureSize(size);
                OpenGL.GL.CompressedTexImage2D(OpenGL.TextureTarget.Texture2D,
                                               0,
                                               (OpenGL.PixelInternalFormat)d_format,
                                               (int)size.Width,
                                               (int)d_size.Height,
                                               0,
                                               imageSize,
                                               IntPtr.Zero);
            }
            else
            {
                OpenGL.GL.TexImage2D(OpenGL.TextureTarget.Texture2D,
                                     0,
                                     OpenGL.PixelInternalFormat.Rgba8,
                                     (int)size.Width,
                                     (int)d_size.Height,
                                     0,
                                     OpenGL.PixelFormat.Rgba,
                                     OpenGL.PixelType.UnsignedByte,
                                     IntPtr.Zero);;
            }

            // restore previous texture binding.
            OpenGL.GL.BindTexture(OpenGL.TextureTarget.Texture2D, oldTex);
        }
예제 #13
0
        public override Sizef GetAdjustedTextureSize(Sizef sz)
        {
            var @out = sz;

            // if we can't support non power of two sizes, get appropriate POT values.
            if (!GLEW_ARB_texture_non_power_of_two)
            {
                @out.Width  = GetNextPowerOfTwoSize(@out.Width);
                @out.Height = GetNextPowerOfTwoSize(@out.Height);
            }

            return(@out);
        }
예제 #14
0
        /// <summary>
        /// set the openGL texture that this Texture is based on to the specifiedSystem.Runtime.InteropServices.
        /// texture, with the specified size.
        /// </summary>
        /// <param name="tex"></param>
        /// <param name="size"></param>
        public void SetOpenGLTexture(int tex, Sizef size)
        {
            if (d_ogltexture != tex)
            {
                // cleanup the current state first.
                CleanupOpenGLTexture();

                d_ogltexture = tex;
            }

            d_dataSize = d_size = size;
            UpdateCachedScaleValues();
        }
예제 #15
0
        /// <summary>
        /// internal texture resize function (does not reset format or other fields)
        /// </summary>
        /// <param name="sz"></param>
        protected virtual void SetTextureSizeImpl(Sizef sz)
        {
            var size = _owner.GetAdjustedTextureSize(sz);

            d_size = size;

            // make sure size is within boundaries
            float maxSize;

            OpenGL.GL.GetFloat(OpenGL.GetPName.MaxTextureSize, out maxSize);
            if ((size.Width > maxSize) || (size.Height > maxSize))
            {
                throw new InvalidOperationException("size too big");
            }

            // save old texture binding
            int old_tex;

            OpenGL.GL.GetInteger(OpenGL.GetPName.TextureBinding2D, out old_tex);

            // set texture to required size
            OpenGL.GL.BindTexture(OpenGL.TextureTarget.Texture2D, d_ogltexture);

            if (d_isCompressed)
            {
                var image_size = GetCompressedTextureSize(size);
                OpenGL.GL.CompressedTexImage2D(OpenGL.TextureTarget.Texture2D,
                                               0,
                                               (Lunatics.SDLGL.OpenGL.PixelInternalFormat)d_format,
                                               (int)(size.Width),
                                               (int)(size.Height),
                                               0,
                                               image_size,
                                               IntPtr.Zero);
            }
            else
            {
                OpenGL.GL.TexImage2D(OpenGL.TextureTarget.Texture2D,
                                     0,
                                     (Lunatics.SDLGL.OpenGL.PixelInternalFormat)d_format,
                                     (int)(size.Width),
                                     (int)(size.Height),
                                     0,
                                     d_format,
                                     d_subpixelFormat,
                                     IntPtr.Zero);
            }

            // restore previous texture binding.
            OpenGL.GL.BindTexture(OpenGL.TextureTarget.Texture2D, old_tex);
        }
예제 #16
0
        public override void SetDisplaySize(Sizef size)
        {
            ThrowIfDisposed();

            if (size != d_displaySize)
            {
                d_displaySize = size;

                // update the default target's area
                var area = d_defaultTarget.GetArea();
                area.Size = size;
                d_defaultTarget.SetArea(area);
            }
        }
예제 #17
0
        /*!
         * \brief
         *  Create a texture that uses an existing OpenGL texture with the specified
         *  size.  Note that it is your responsibility to ensure that the OpenGL
         *  texture is valid and that the specified size is accurate.
         *
         * \param sz
         *  Size object that describes the pixel size of the OpenGL texture
         *  identified by \a tex.
         *
         * \param name
         *  String holding the name for the new texture.  Texture names must be
         *  unique within the Renderer.
         *
         * \return
         *  Texture object that wraps the OpenGL texture \a tex, and whose size is
         *  specified to be \a sz.
         *
         * \exceptions
         *  - AlreadyExistsException - thrown if a Texture object named \a name
         *    already exists within the system.
         */
        public Texture CreateTexture(string name, int tex, Sizef sz)
        {
            ThrowIfDisposed();
            ThrowIfTextureExists(name);

            var t = CreateTextureImpl(name);

            t.Initialise(tex, sz);
            d_textures[name] = t;

            LogTextureCreation(name);

            return(t);
        }
예제 #18
0
        public override Texture CreateTexture(string name, Sizef size)
        {
            ThrowIfDisposed();
            ThrowIfTextureExists(name);

            var tex = CreateTextureImpl(name);

            tex.Initialise(size);
            d_textures[name] = tex;

            LogTextureCreation(name);

            return(tex);
        }
예제 #19
0
        /*!
         * \brief
         *  Convenience function that creates the required objects to initialise the
         *  CEGUI system.
         *
         *  The created Renderer will use the current OpenGL viewport as it's
         *  default surface size.
         *
         *  This will create and initialise the following objects for you:
         *  - CEGUI::OpenGLRenderer
         *  - CEGUI::DefaultResourceProvider
         *  - CEGUI::System
         *
         * \param display_size
         *  Size object describing the initial display resolution.
         *
         * \param tt_type
         *  Specifies one of the TextureTargetType enumerated values indicating the
         *  desired TextureTarget type to be used.  Defaults to TTT_AUTO.
         *
         * \param abi
         *  This must be set to CEGUI_VERSION_ABI
         *
         * \return
         *  Reference to the CEGUI::OpenGLRenderer object that was created.
         */

        public static OpenGLRenderer BootstrapSystem(Sizef displaySize, TextureTargetType textureTargetType = TextureTargetType.TTT_AUTO /*, int abi = CEGUI_VERSION_ABI*/)
        {
            // TODO: System::performVersionTest(CEGUI_VERSION_ABI, abi, CEGUI_FUNCTION_NAME);

            if (Base.System.GetSingleton() != null)
            {
                throw new InvalidRequestException("CEGUI::System object is already initialised.");
            }

            var renderer = Create(displaySize, textureTargetType);

            Base.System.Create(renderer, new DefaultResourceProvider());

            return(renderer);
        }
예제 #20
0
        public override void LoadFromMemory(byte[] buffer, Sizef bufferSize, PixelFormat pixelFormat)
        {
            if (!IsPixelFormatSupported(pixelFormat))
            {
                throw new InvalidRequestException("Data was supplied in an unsupported pixel format.");
            }

            InitInternalPixelFormatFields(pixelFormat);
            SetTextureSizeImpl(bufferSize);

            // store size of original data we are loading
            d_dataSize = bufferSize;
            UpdateCachedScaleValues();

            BlitFromMemory(buffer, new Rectf(Vector2.Zero, bufferSize));
        }
예제 #21
0
        /// <summary>
        /// Constructor for OpenGL Renderer objects.
        /// </summary>
        /// <param name="displaySize">
        /// Size object describing the initial display resolution.
        /// </param>
        /// <param name="textureTargetType">
        /// Specifies one of the TextureTargetType enumerated values indicating the
        /// desired TextureTarget type to be used.
        /// </param>
        private OpenGLRenderer(Sizef displaySize, TextureTargetType textureTargetType)
            : base(displaySize)
        {
            InitialiseRendererIDString();
            InitialiseGLExtensions();
            InitialiseTextureTargetFactory(textureTargetType);
            InitialiseShaderWrappers();

            // we _really_ need separate rgb/alpha blend modes, if this support is not
            // available, add a note to the renderer ID string so that this fact is
            // logged.
            if (!GLEW_VERSION_1_4 && !GLEW_EXT_blend_func_separate)
            {
                d_rendererID += "  No glBlendFuncSeparate(EXT) support.";
            }
        }
        //! resize the texture
        private void ResizeRenderTexture()
        {
            // save old texture binding
            OpenGL.GL.GetInteger(OpenGL.GetPName.TextureBinding2D, out var old_tex);

            // Some drivers (hint: Intel) segfault when glTexImage2D is called with
            // any of the dimensions being 0. The downside of this workaround is very
            // small. We waste a tiny bit of VRAM on cards with sane drivers and
            // prevent insane drivers from crashing CEGUI.
            Sizef sz = d_area.Size;

            if (sz.Width < 1.0f || sz.Height < 1.0f)
            {
                sz.Width  = 1.0f;
                sz.Height = 1.0f;
            }

            // set the texture to the required size
            d_glStateChanger.BindTexture(OpenGL.TextureTarget.Texture2D, d_texture);

            OpenGL.GL.TexImage2D(OpenGL.TextureTarget.Texture2D,
                                 0,
                                 OpenGL.PixelInternalFormat.Rgba8,             //OpenGLInfo::getSingleton().isSizedInternalFormatSupported() ? GL_RGBA8 : GL_RGBA,
                                 (int)sz.Width,
                                 (int)sz.Height,
                                 0,
                                 OpenGL.PixelFormat.Rgba,
                                 OpenGL.PixelType.UnsignedByte,
                                 IntPtr.Zero);

            if (d_usesStencil)
            {
                OpenGL.GL.BindRenderbuffer(OpenGL.RenderbufferTarget.Renderbuffer, d_stencilBufferRBO);
                OpenGL.GL.RenderbufferStorage(OpenGL.RenderbufferTarget.Renderbuffer,
                                              OpenGL.RenderbufferStorage.StencilIndex8,
                                              (int)sz.Width,
                                              (int)sz.Height);
            }

            Clear();

            // ensure the CEGUI::Texture is wrapping the gl texture and has correct size
            d_CEGUITexture.SetOpenGLTexture(d_texture, sz);

            // restore previous texture binding.
            d_glStateChanger.BindTexture(OpenGL.TextureTarget.Texture2D, old_tex);
        }
예제 #23
0
        /// <summary>
        /// update string formatting using given area size.
        /// </summary>
        /// <param name="sz"></param>
        protected void UpdateFormatting(Sizef sz)
        {
            if (Window == null)
            {
                return;
            }

            if (_formattedRenderedString == null)
            {
                SetupStringFormatter();
            }

            // 'touch' the window's rendered string to ensure it's re-parsed if needed.
            _formattedRenderedString.SetRenderedString(Window.GetRenderedString());

            _formattedRenderedString.Format(Window, sz);
            _formatValid = true;
        }
예제 #24
0
        public void ResizeViewToContent(ItemView view, bool fitWidth, bool fitHeight)
        {
            var totalArea   = view.GetUnclippedOuterRect().Get();
            var contentArea = GetViewRenderArea(view,
                                                !fitWidth && view.GetHorzScrollbar().IsVisible(),
                                                !fitHeight && view.GetVertScrollbar().IsVisible());
            var withScrollContentArea = GetViewRenderArea(view, true, true);

            var frameSize           = totalArea.Size - contentArea.Size;
            var withScrollFrameSize = totalArea.Size - withScrollContentArea.Size;
            var contentSize         = new Sizef(view.GetRenderedMaxWidth(), view.GetRenderedTotalHeight());

            var parentSize = view.GetParentPixelSize();
            var maxSize    =
                new Sizef(parentSize.Width - CoordConverter.AsAbsolute(view.GetXPosition(), parentSize.Width),
                          parentSize.Height - CoordConverter.AsAbsolute(view.GetYPosition(), parentSize.Height));

            var requiredSize = frameSize + contentSize + new Sizef(1, 1);

            if (fitHeight && requiredSize.Height > maxSize.Height)
            {
                requiredSize.Height = maxSize.Height;
                requiredSize.Width  = Math.Min(maxSize.Width,
                                               requiredSize.Width - frameSize.Width + withScrollFrameSize.Width);
            }

            if (fitWidth && requiredSize.Width > maxSize.Width)
            {
                requiredSize.Width  = maxSize.Width;
                requiredSize.Height = Math.Min(maxSize.Height,
                                               requiredSize.Height - frameSize.Height + withScrollFrameSize.Height);
            }

            if (fitHeight)
            {
                view.SetHeight(new UDim(0, requiredSize.Height));
            }

            if (fitWidth)
            {
                view.SetWidth(new UDim(0, requiredSize.Width));
            }
        }
예제 #25
0
 /// <summary>
 /// initialise method that creates a Texture with a given size.
 /// </summary>
 /// <param name="size"></param>
 protected internal void Initialise(Sizef size)
 {
     InitInternalPixelFormatFields(PixelFormat.RGBA);
     GenerateOpenGLTexture();
     SetTextureSize(size);
 }
예제 #26
0
 public virtual void AutoPositionSize(Lunatics.Mathematics.Vector2 position, Sizef size)
 {
 }
예제 #27
0
        protected virtual int /*GLsizei*/ GetCompressedTextureSize(Sizef pixelSize)
        {
            const int blocksize = 16;

            return((int)(Math.Ceiling(pixelSize.Width / 4f) * Math.Ceiling(pixelSize.Height / 4f) * blocksize));
        }
예제 #28
0
        /// <summary>
        /// Configure scrollbars
        /// </summary>
        /// <param name="docSize"></param>
        protected void ConfigureScrollbars(Sizef docSize)
        {
            var v = GetVertScrollbar();
            var h = GetHorzScrollbar();

            var oldVertVisible = v.IsVisible();
            var oldHorzVisible = h.IsVisible();

            var renderAreaSize = GetItemRenderArea().Size;

            // setup the pane size
            var paneSizeWidth = Math.Max(docSize.Width, renderAreaSize.Width);
            var paneSize      = new USize(UDim.Absolute(paneSizeWidth), UDim.Absolute(docSize.Height));

            Pane.SetMinSize(paneSize);
            Pane.SetMaxSize(paneSize);

            // "fix" scrollbar visibility
            if (_forceVScroll || docSize.Height > renderAreaSize.Height)
            {
                v.Show();
            }
            else
            {
                v.Hide();
            }

            if (_forceHScroll || docSize.Width > renderAreaSize.Width)
            {
                h.Show();
            }
            else
            {
                h.Hide();
            }

            // if some change occurred, invalidate the inner rect area caches.
            if ((oldVertVisible != v.IsVisible()) ||
                (oldHorzVisible != h.IsVisible()))
            {
                d_unclippedInnerRect.InvalidateCache();
                d_innerRectClipperValid = false;
            }

            // get a fresh item render area
            var renderArea = GetItemRenderArea();

            renderAreaSize = renderArea.Size;

            // update the pane clipper area
            ((ClippedContainer)Pane).SetClipArea(renderArea);

            // setup vertical scrollbar
            v.SetDocumentSize(docSize.Height);
            v.SetPageSize(renderAreaSize.Height);
            v.SetStepSize(Math.Max(1.0f, renderAreaSize.Height / 10.0f));
            v.SetScrollPosition(v.GetScrollPosition());

            // setup horizontal scrollbar
            h.SetDocumentSize(docSize.Width);
            h.SetPageSize(renderAreaSize.Width);
            h.SetStepSize(Math.Max(1.0f, renderAreaSize.Width / 10.0f));
            h.SetScrollPosition(h.GetScrollPosition());
        }
예제 #29
0
        public static Mesh CreatePlane(Vector2f location, Sizef size)
        {
            Vector3f[] vertices = new Vector3f[]
            {
                new Vector3f(location.X, 0, location.Y),
                new Vector3f(location.X + size.Width, 0, location.Y),
                new Vector3f(location.X + size.Width, 0, location.Y + size.Height),
                new Vector3f(location.X, 0, location.Y + size.Height)
            };

            Vector2f[] uvs = new Vector2f[]
            {
                new Vector2f(0, 0),
                new Vector2f(1, 0),
                new Vector2f(1, 1),
                new Vector2f(0, 1)
            };

            int[] indices = new int[] { 2, 1, 0, 0, 3, 2 };

            Vector3f[] normals = CalculateNormals(vertices, indices);

            MeshEntry plane = new MeshEntry();

            plane.BaseIndex  = 0;
            plane.BaseVertex = 0;
            plane.NumIndices = indices.Length;
            plane.Name       = "Plane";

            // Create the VAO
            uint _vao = GL.GenVertexArray();

            GL.BindVertexArray(_vao);

            VBO <Vector3f> vertex  = new VBO <Vector3f>(vertices);
            VBO <Vector2f> texture = new VBO <Vector2f>(uvs);
            VBO <Vector3f> normal  = new VBO <Vector3f>(normals);
            VBO <int>      element = new VBO <int>(indices, BufferTarget.ElementArrayBuffer, BufferUsageHint.StaticRead);

            GL.BindBuffer(vertex.BufferTarget, vertex.ID);
            GL.EnableVertexAttribArray(GL.VERTEX_POSITION_LOCATION);
            GL.VertexAttribPointer(GL.VERTEX_POSITION_LOCATION, vertex.Size, vertex.PointerType, false, 0, 0);

            GL.BindBuffer(texture.BufferTarget, texture.ID);
            GL.EnableVertexAttribArray(GL.VERTEX_NORMAL_LOCATION);
            GL.VertexAttribPointer(GL.VERTEX_NORMAL_LOCATION, texture.Size, texture.PointerType, false, 0, 0);

            GL.BindBuffer(normal.BufferTarget, normal.ID);
            GL.EnableVertexAttribArray(GL.VERTEX_NORMAL_LOCATION);
            GL.VertexAttribPointer(GL.VERTEX_NORMAL_LOCATION, normal.Size, normal.PointerType, false, 0, 0);

            GL.BindBuffer(element.BufferTarget, element.ID);

            // Make sure this VAO is not modified from the outside
            GL.BindVertexArray(0);

            // Add a dispose event to delete the generated VAO
            Resources.ResourcesManager.AddOnDisposeEvent(() => GL.DeleteVertexArrays(1, _vao));

            return(new Mesh(_vao, plane));
        }
 public override void DeclareRenderSize(Sizef sz)
 {
     SetArea(new Rectf(d_area.Position, Owner.GetAdjustedTextureSize(sz)));
     ResizeRenderTexture();
 }