public override void AddToRenderGeometry(GeometryBuffer geomBuffer, ref Rectf renderArea, ref Rectf?clipArea, ColourRect colours)
        {
            Rectf texRect = Rectf.Zero, finalRect;
            var   isFullClipped = CalculateTextureAndRenderAreas(renderArea, ref clipArea, out finalRect, ref texRect);

            if (isFullClipped)
            {
                return;
            }
            var vbuffer = new TexturedColouredVertex[6];

            CreateTexturedQuadVertices(vbuffer, colours, ref finalRect, ref texRect);
            geomBuffer.AppendGeometry(vbuffer);
        }
 /// <summary>
 /// Append a single vertex to the buffer.
 /// </summary>
 /// <param name="vertex">
 /// Vertex object describing the vertex to be added to the GeometryBuffer.
 /// </param>
 public virtual void AppendVertex(TexturedColouredVertex vertex)
 {
     AppendGeometry(new[]
     {
         vertex.Position.X,
         vertex.Position.Y,
         vertex.Position.Z,
         vertex.Colour.X,
         vertex.Colour.Y,
         vertex.Colour.Z,
         vertex.Colour.W,
         vertex.TextureCoordinates.X,
         vertex.TextureCoordinates.Y
     }, 9);
 }
Exemple #3
0
        /// <summary>
        /// default generates geometry to draw window as a single quad.
        /// </summary>
        protected virtual void RealiseGeometryImpl()
        {
            var tex = d_textarget.GetTexture();

            var tu      = d_size.Width * tex.GetTexelScaling().X;
            var tv      = d_size.Height * tex.GetTexelScaling().Y;
            var texRect = d_textarget.IsRenderingInverted()
                               ? new Rectf(0, 1, tu, 1 - tv)
                               : new Rectf(0, 0, tu, tv);

            var area    = new Rectf(0, 0, d_size.Width, d_size.Height);
            var c       = new Lunatics.Mathematics.Vector4(1f, 1f, 1f, 1f);
            var vbuffer = new TexturedColouredVertex[6];

            // vertex 0
            vbuffer[0].Position           = new Lunatics.Mathematics.Vector3(area.d_min.X, area.d_min.Y, 0.0f);
            vbuffer[0].Colour             = c;
            vbuffer[0].TextureCoordinates = new Lunatics.Mathematics.Vector2(texRect.d_min.X, texRect.d_min.Y);

            // vertex 1
            vbuffer[1].Position           = new Lunatics.Mathematics.Vector3(area.d_min.X, area.d_max.Y, 0.0f);
            vbuffer[1].Colour             = c;
            vbuffer[1].TextureCoordinates = new Lunatics.Mathematics.Vector2(texRect.d_min.X, texRect.d_max.Y);

            // vertex 2
            vbuffer[2].Position           = new Lunatics.Mathematics.Vector3(area.d_max.X, area.d_max.Y, 0.0f);
            vbuffer[2].Colour             = c;
            vbuffer[2].TextureCoordinates = new Lunatics.Mathematics.Vector2(texRect.d_max.X, texRect.d_max.Y);

            // vertex 3
            vbuffer[3].Position           = new Lunatics.Mathematics.Vector3(area.d_max.X, area.d_min.Y, 0.0f);
            vbuffer[3].Colour             = c;
            vbuffer[3].TextureCoordinates = new Lunatics.Mathematics.Vector2(texRect.d_max.X, texRect.d_min.Y);

            // vertex 4
            vbuffer[4].Position           = new Lunatics.Mathematics.Vector3(area.d_min.X, area.d_min.Y, 0.0f);
            vbuffer[4].Colour             = c;
            vbuffer[4].TextureCoordinates = new Lunatics.Mathematics.Vector2(texRect.d_min.X, texRect.d_min.Y);

            // vertex 5
            vbuffer[5].Position           = new Lunatics.Mathematics.Vector3(area.d_max.X, area.d_max.Y, 0.0f);
            vbuffer[5].Colour             = c;
            vbuffer[5].TextureCoordinates = new Lunatics.Mathematics.Vector2(texRect.d_max.X, texRect.d_max.Y);

            d_geometry.SetTexture("texture0", tex);
            d_geometry.AppendGeometry(vbuffer);
        }
        public override List <GeometryBuffer> CreateRenderGeometry(ImageRenderSettings renderSettings)
        {
            Rectf texRect = Rectf.Zero, finalRect;

            var isFullClipped = CalculateTextureAndRenderAreas(renderSettings.DestArea, ref renderSettings.ClipArea, out finalRect, ref texRect);

            if (isFullClipped)
            {
                return(new List <GeometryBuffer>());
            }

            var vbuffer = new TexturedColouredVertex[6];
            var colours = renderSettings.MultiplyColours;

            CreateTexturedQuadVertices(vbuffer, colours, ref finalRect, ref texRect);

            #region original code
            var buffer = System.GetSingleton().GetRenderer().CreateGeometryBufferTextured();

            buffer.SetClippingActive(renderSettings.IsClippingEnabled);
            if (renderSettings.IsClippingEnabled && renderSettings.ClipArea.HasValue)
            {
                buffer.SetClippingRegion(renderSettings.ClipArea.Value);
            }
            buffer.SetTexture("texture0", _texture);
            buffer.AppendGeometry(vbuffer);
            buffer.SetAlpha(renderSettings.Alpha);

            var geomBuffers = new List <GeometryBuffer> {
                buffer
            };
            return(geomBuffers);

            #endregion

            #region xdinos new code

            //GeometryBuffer buffer = imageGeometryBuffers.Count > 0
            //                                ? imageGeometryBuffers[imageGeometryBuffers.Count - 1]
            //                                : null;
            //if (buffer != null)
            //{
            //    if (_lastTexture != _texture ||
            //        (_lastClippingEnabled.HasValue && _lastClippingEnabled.Value != renderSettings.clippingEnabled) ||
            //        (_lastClipArea != renderSettings.clipArea) ||
            //        (_lastAlpha.HasValue && _lastAlpha.Value != renderSettings.alpha))
            //        buffer = null;
            //}

            //if (buffer == null)
            //{
            //    buffer = System.GetSingleton().GetRenderer().CreateGeometryBufferTextured();
            //    imageGeometryBuffers.Add(buffer);

            //    buffer.SetClippingActive(renderSettings.clippingEnabled);
            //    if (renderSettings.clippingEnabled && renderSettings.clipArea.HasValue)
            //        buffer.SetClippingRegion(renderSettings.clipArea.Value);
            //    buffer.SetTexture("texture0", _texture);
            //    buffer.SetAlpha(renderSettings.alpha);

            //    _lastClippingEnabled = renderSettings.clippingEnabled;
            //    _lastClipArea = renderSettings.clipArea;
            //    _lastAlpha = renderSettings.alpha;
            //    _lastTexture = _texture;
            //}

            //buffer.AppendGeometry(vbuffer);

            #endregion
        }