From: <bor...@us...> - 2011-03-02 21:05:12
|
Revision: 269 http://axiomcontrib.svn.sourceforge.net/axiomcontrib/?rev=269&view=rev Author: borrillis Date: 2011-03-02 21:05:04 +0000 (Wed, 02 Mar 2011) Log Message: ----------- Added Sample Browser and 2 Samples Modified Paths: -------------- Axiom.SharpGorilla/trunk/lib/Axiom.dll Added Paths: ----------- Axiom.SharpGorilla/trunk/lib/Axiom.Samples.Common.dll Axiom.SharpGorilla/trunk/lib/SharpInputSystem.dll Axiom.SharpGorilla/trunk/src/SharpGorilla/Caption.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Colors/ Axiom.SharpGorilla/trunk/src/SharpGorilla/Converter.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/DynamicBuffer.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Enums.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Glyph.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/GlyphData.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Helper.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/ILayerContainer.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Layer.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/LayerContainer.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/LineList.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/MarkupText.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Polygon.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Properties/ Axiom.SharpGorilla/trunk/src/SharpGorilla/QuadList.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Rectangle.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Screen.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/ScreenRendable.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla.csproj Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla.sln Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla2008.csproj Axiom.SharpGorilla/trunk/src/SharpGorilla/Silverback.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Sprite.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/Structs.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/TextureAtlas.cs Axiom.SharpGorilla/trunk/src/SharpGorilla_2008.sln Axiom.SharpGorilla/trunk/src/SharpGorilla_2010.sln Removed Paths: ------------- Axiom.SharpGorilla/trunk/lib/Axiom.Platforms.Win32.dll Axiom.SharpGorilla/trunk/lib/Axiom.Plugins.CgProgramManager.dll Axiom.SharpGorilla/trunk/lib/Axiom.Plugins.DevILCodecs.dll Axiom.SharpGorilla/trunk/lib/Axiom.Plugins.ParticleFX.dll Axiom.SharpGorilla/trunk/lib/Axiom.RenderSystems.DirectX9.dll Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Caption.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Colors/ Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Converter.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/DynamicBuffer.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Enums.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Glyph.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/GlyphData.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Helper.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/ILayerContainer.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Layer.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/LayerContainer.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/LineList.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/MarkupText.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Polygon.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Properties/ Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/QuadList.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Rectangle.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Screen.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/ScreenRendable.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/SharpGorilla.csproj Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/SharpGorilla.sln Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/SharpGorilla2008.csproj Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Silverback.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Sprite.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Structs.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/TextureAtlas.cs Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla_2008.sln Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla_2010.sln Axiom.SharpGorilla/trunk/src/SharpGorilla.Demo/ Deleted: Axiom.SharpGorilla/trunk/lib/Axiom.Platforms.Win32.dll =================================================================== (Binary files differ) Deleted: Axiom.SharpGorilla/trunk/lib/Axiom.Plugins.CgProgramManager.dll =================================================================== (Binary files differ) Deleted: Axiom.SharpGorilla/trunk/lib/Axiom.Plugins.DevILCodecs.dll =================================================================== (Binary files differ) Deleted: Axiom.SharpGorilla/trunk/lib/Axiom.Plugins.ParticleFX.dll =================================================================== (Binary files differ) Deleted: Axiom.SharpGorilla/trunk/lib/Axiom.RenderSystems.DirectX9.dll =================================================================== (Binary files differ) Added: Axiom.SharpGorilla/trunk/lib/Axiom.Samples.Common.dll =================================================================== (Binary files differ) Property changes on: Axiom.SharpGorilla/trunk/lib/Axiom.Samples.Common.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: Axiom.SharpGorilla/trunk/lib/Axiom.dll =================================================================== (Binary files differ) Added: Axiom.SharpGorilla/trunk/lib/SharpInputSystem.dll =================================================================== (Binary files differ) Property changes on: Axiom.SharpGorilla/trunk/lib/SharpInputSystem.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/Caption.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Caption.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/Caption.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/Caption.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,473 @@ +#region License +/* + Gorilla + ------- + + Copyright (c) 2010 Robin Southern + + This is a c# (Axiom) port of Gorrilla, developed by Robin Southern, ported by me (bostich) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +#endregion + +#region SVN Version Information +// <file> +// <id value="$Id: 2118 2010-09-26 23:56:56Z bostich $"/> +// </file> +#endregion SVN Version Information + +#region Namespace Declarations +using System; +using Axiom.Math; +using Axiom.Core; +#endregion + +namespace SharpGorilla +{ + /// <summary> + /// A single line piece of text + /// </summary> + public class Caption + { + protected Layer _layer; + protected GlyphData _glyphData; + protected Real _left; + protected Real _top; + protected Real _width; + protected Real _height; + protected TextAlignment _algignment; + protected VerticalAlignment _verticalAlignment; + protected string _text; + protected ColorEx _color; + protected ColorEx _backgroundColor; + internal bool _isDirty; + internal DynamicBuffer<Vertex> _vertices = new DynamicBuffer<Vertex>(); + protected int _clippedLeftIndex; + protected int _clippedRightIndex; + + /// <summary> + /// Gets or sets where the text should be drawn vertically. + /// Note:<para></para> + /// If the TextAlignment is Right Aligned, then this will be the right-side of the last character drawn (with in width limits).<para></para> + /// If the TextAlignment is Centre Aligned, then this will be the center of the drawn text drawn (with in width limits). + /// </summary> + public Real Left + { + get { return _left; } + set + { + _left = value; + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Gets or sets where the text should be drawn vertically. + /// </summary> + public Real Top + { + get { return _top; } + set + { + _top = value; + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Gets or sets the maximum width of the text can draw into. + /// </summary> + public Real Width + { + get { return _width; } + set + { + _width = value; + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Gets or sets the maximum height of the text can draw into. + /// </summary> + public Real Height + { + get { return _height; } + set + { + _height = value; + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Gets or sets the text indented to show. + /// </summary> + public string Text + { + get { return _text; } + set + { + _text = value; + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Gets or sets the alignment of text. + /// </summary> + public TextAlignment HorizontalAlign + { + get { return _algignment; } + set + { + _algignment = value; + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Gets or sets the vertical alignment of text. + /// </summary> + public VerticalAlignment VerticalAlign + { + get { return _verticalAlignment; } + set + { + _verticalAlignment = value; + _isDirty = true; + _layer.MarkDirty(); + + } + } + /// <summary> + /// Gets the index (character position), of the first character that could not be drawn due to the limits<para></para> + /// of the width of the text, to the left.<para></para> + /// Note:<para></para> + /// The index if the first clipped character, or -1 if there was no clipping and<para></para> + /// the text was drawn fully within the given space.<para></para> + /// </summary> + public int ClippedLeftIndex + { + get { return _clippedLeftIndex; } + } + /// <summary> + /// Gets the index (character position), of the first character that could not be drawn due to the limits<para></para> + /// of the width of the text, to the right.<para></para> + /// Note:<para></para> + /// The index if the first clipped character, or -1 if there was no clipping and<para></para> + /// the text was drawn fully within the given space.<para></para> + /// </summary> + public int ClippedRightIndex + { + get { return _clippedRightIndex; } + } + /// <summary> + /// Gets or sets the text color + /// </summary> + public ColorEx Color + { + get { return _color; } + set + { + _color = new ColorEx( value.r, value.g, value.b, value.a ); + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Sets the color as web color + /// </summary> + public Colors.Color WebColor + { + set + { + ColorEx val = Converter.ToWebColor( value ); + _color = new ColorEx( val.r, val.g, val.b, val.a ); + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Gets or sets the background color + /// </summary> + public ColorEx BackgroundColor + { + get { return _backgroundColor; } + set + { + _backgroundColor = value; + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// Sets the Background color as web color + /// </summary> + public Colors.Color BackgroundWebColor + { + set + { + if (value == Colors.Color.None) + _backgroundColor.a = 0; + else + _backgroundColor = Converter.ToWebColor(value); + + _isDirty = true; + _layer.MarkDirty(); + } + } + /// <summary> + /// + /// </summary> + /// <param name="glyphDataIndex"></param> + /// <param name="left"></param> + /// <param name="top"></param> + /// <param name="caption"></param> + /// <param name="parent"></param> + internal Caption(int glyphDataIndex, Real left, Real top, string caption, Layer parent) + { + _isDirty = true; + _layer = parent; + _layer.MarkDirty(); + _glyphData = _layer.GetGlyphData(glyphDataIndex); + _left = left; + _top = top; + _width = 0; + _height = 0; + _text = caption; + _color = ColorEx.White; + _backgroundColor.a = 0; + _algignment = TextAlignment.Left; + _verticalAlignment = VerticalAlignment.Top; + + } + /// <summary> + /// Does a set of coordinates lie within this caption? + /// </summary> + /// <param name="coordinates">coordinates to check for intersection</param> + /// <returns>true if intersects</returns> + public bool Intersects(Vector2 coordinates) + { + return ((coordinates.x >= _left && coordinates.x <= _left + _width) && (coordinates.y >= _top && coordinates.y <= _top + _height)); + } + /// <summary> + /// Set the maximum width and height of the text can draw into. + /// </summary> + /// <param name="width">width of the text</param> + /// <param name="height">height of the text</param> + public void SetSize(Real width, Real height) + { + _width = width; + _height = height; + _isDirty = true; + _layer.MarkDirty(); + } + internal void CalculateDrawSize(out Vector2 retSize) + { + Real cursor = 0; + Real kerning = 0; + char thisChar = (char)0; + char lastChar = (char)0; + Glyph glyph = null; + retSize = new Vector2(); + retSize.x = 0; + retSize.y = _glyphData.LineHeight; + + for (int i = 0; i < Text.Length; i++) + { + thisChar = Text[i]; + if (thisChar == ' ') + { + lastChar = thisChar; + cursor += _glyphData.SpaceLength; + continue; + } + + if (thisChar < _glyphData.RangeBegin || thisChar > _glyphData.RangeEnd) + { + lastChar = (char)0; + continue; + } + + glyph = _glyphData.GetGlyph((int)thisChar); + kerning = glyph.GetKerning(lastChar); + if (kerning == 0) + kerning = _glyphData.LetterSpacing; + + cursor += glyph.GlyphAdvance + kerning; + lastChar = thisChar; + }//end for i + + retSize.x = cursor - kerning; + } + + /// <summary> + /// + /// </summary> + public void Redraw() + { + if (!_isDirty) + return; + + _vertices.Clear(); + + Vector2 uv = _layer.SolidUV; + Vertex temp = new Vertex(); + if (BackgroundColor.a > 0) + { + Vector2 a, b, c, d = Vector2.Zero; + a.x = _left; a.y = _top; + b.x = _left + _width; b.y = _top; + c.x = _left; c.y = _top + _height; + d.x = _left + _width; d.y = c.y = _top + _height; + + Helper.AddTriangle(ref _vertices, temp, c, b, a, uv, _backgroundColor); + Helper.AddTriangle(ref _vertices, temp, c, d, b, uv, _backgroundColor); + } + + Real left = 0, top = 0, right = 0, bottom = 0, cursorX = 0, cursorY = 0, kerning = 0, texelOffsetX = _layer.TexelX, texelOffsetY = _layer.TexelY; + Vector2 knownSize = Vector2.Zero; + Glyph glyph = null; + bool clipleft = false, clipRight = false; + Real clipLeftPos = 0, clipRightPos = 0; + + if (_algignment == TextAlignment.Left) + { + cursorX = _left; + if (_width != 0) + { + clipRight = true; + clipRightPos = _left + _width; + } + } + else if (_algignment == TextAlignment.Center) + { + CalculateDrawSize(out knownSize); + cursorX = _left + (_width * 0.5f) - (knownSize.x * 0.5f); + + if (_width != 0) + { + clipleft = true; + clipLeftPos = _left; + clipRight = true; + clipRightPos = _left + _width; + } + } + else if (_algignment == TextAlignment.Right) + { + CalculateDrawSize(out knownSize); + cursorX = _left + _width - knownSize.x; + if (_width != 0) + { + clipleft = true; + clipLeftPos = _left; + } + } + + if (_verticalAlignment == VerticalAlignment.Top) + { + cursorY = _top; + } + else if (_verticalAlignment == VerticalAlignment.Middle) + { + cursorY = _top + (_height * 0.5f) - (_glyphData.LineHeight * 0.5f); + } + else if (_verticalAlignment == VerticalAlignment.Bottom) + { + cursorY = _top + _height - _glyphData.LineHeight; + } + + char thisChar = (char)0; + char lastChar = (char)0; + _clippedLeftIndex = -1; + _clippedRightIndex = -1; + + for (int i = 0; i < _text.Length; i++) + { + thisChar = _text[i]; + + if (thisChar == ' ') + { + lastChar = thisChar; + cursorX += _glyphData.SpaceLength; + continue; + } + if (thisChar < _glyphData.RangeBegin || thisChar > _glyphData.RangeEnd) + { + lastChar = (char)0; + continue; + } + + glyph = _glyphData.GetGlyph((int)thisChar); + kerning = glyph.GetKerning(lastChar); + if (kerning == 0) + kerning = _glyphData.LetterSpacing; + + left = cursorX - texelOffsetX; + top = cursorY - texelOffsetY; + right = left + glyph.GlyphWidth + texelOffsetX; + bottom = top + glyph.GlyphHeight + texelOffsetY; + + if (clipleft) + { + if (left < clipLeftPos) + { + if (_clippedLeftIndex == -1) + _clippedLeftIndex = i; + + cursorX += glyph.GlyphAdvance + kerning; + lastChar = thisChar; + continue; + } + } + + if (clipRight) + { + if (right > clipRightPos) + { + if (_clippedRightIndex == -1) + _clippedRightIndex = i; + + cursorX += glyph.GlyphAdvance + kerning; + lastChar = thisChar; + continue; + } + } + + // Triangle A + Helper.AddVertex(ref _vertices, temp, left, bottom, glyph.TexCoords[(int)QuadCorner.BottomLeft], _color); // Left/Bottom 3 + Helper.AddVertex(ref _vertices, temp, right, top, glyph.TexCoords[(int)QuadCorner.TopRight], _color); // Right/Top 1 + Helper.AddVertex(ref _vertices, temp, left, top, glyph.TexCoords[(int)QuadCorner.TopLeft], _color); // Left/Top 0 + + // Triangle B + Helper.AddVertex(ref _vertices, temp, left, bottom, glyph.TexCoords[(int)QuadCorner.BottomLeft], _color); // Left/Bottom 3 + Helper.AddVertex(ref _vertices, temp, right, bottom, glyph.TexCoords[(int)QuadCorner.BottomRight], _color); // Right/Bottom 2 + Helper.AddVertex(ref _vertices, temp, right, top, glyph.TexCoords[(int)QuadCorner.TopRight], _color); // Right/Top 1 + + + cursorX += glyph.GlyphAdvance + kerning; + lastChar = thisChar; + }//end for + + _isDirty = false; + } + } +} Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/Converter.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Converter.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/Converter.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/Converter.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,108 @@ +#region License +/* + Gorilla + ------- + + Copyright (c) 2010 Robin Southern + + This is a c# (Axiom) port of Gorrilla, developed by Robin Southern, ported by me (bostich) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +#endregion + +#region SVN Version Information +// <file> +// <id value="$Id: 2118 2010-09-26 23:56:56Z bostich $"/> +// </file> +#endregion SVN Version Information + +#region Namespace Declarations + +using System; +using SharpGorilla.Colors; +using Axiom.Core; +using Axiom.Math; + +#endregion +namespace SharpGorilla +{ + public class Converter + { + public static Real Inv255 = new Real(0.00392156863); + public static Double InvHight = 0.00392156863; + + /// <summary> + /// Convert three/four RGBA values into an ColorEx + /// </summary> + /// <param name="r"></param> + /// <param name="g"></param> + /// <param name="b"></param> + /// <returns></returns> + public static ColorEx ToRGB(byte r, byte g, byte b) + { + return ToRGB(r,g,b,255); + } + /// <summary> + /// Convert three/four RGBA values into an ColorEx + /// </summary> + /// <param name="r"></param> + /// <param name="g"></param> + /// <param name="b"></param> + /// <param name="a"></param> + /// <returns></returns> + public static ColorEx ToRGB(byte r, byte g, byte b, byte a) + { + double av = a *InvHight; + double gv = g * InvHight; + double rv = r * InvHight; + double bv = b * InvHight; + ColorEx ret = new ColorEx( new Real( r ) * Inv255, new Real( g ) * Inv255, new Real( b ) * Inv255, new Real( a ) * Inv255 ); + //ColorEx ret = new ColorEx( new Real( a ) * Inv255, new Real( r ) * Inv255, new Real( r ) * Inv255, new Real( b ) * Inv255 ); + return ret; + } + + /// <summary> + /// Turn a webcolor from the SharpGorilla.Colors.Color enum into an ColorEx + /// </summary> + /// <param name="color"></param> + /// <returns></returns> + public static ColorEx ToWebColor( Color color) + { + return ToWebColor(color,1.0f); + } + + /// <summary> + /// Turn a webcolor from the SharpGorilla.Colors.Color enum into an ColorEx + /// </summary> + /// <param name="color"></param> + /// <param name="alpha"></param> + /// <returns></returns> + public static ColorEx ToWebColor( Color color, float alpha ) + { + int intCol = (int)color; + ColorEx ret = new ColorEx(); + ret.b = ( intCol & 0xFF ) * Inv255; + ret.g = ( ( intCol >> 8 ) & 0xFF ) * Inv255; + ret.r = ( ( intCol >> 16 ) & 0xFF ) * Inv255; + ret.a = alpha; + return ret; + } + } +} Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/DynamicBuffer.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/DynamicBuffer.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/DynamicBuffer.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/DynamicBuffer.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,341 @@ +#region License +/* + Gorilla + ------- + + Copyright (c) 2010 Robin Southern + + This is a c# (Axiom) port of Gorrilla, developed by Robin Southern, ported by me (bostich) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +#endregion + +#region SVN Version Information +// <file> +// <id value="$Id: 2118 2010-09-26 23:56:56Z bostich $"/> +// </file> +#endregion SVN Version Information + +#region Namespace Declarations +using System; + +#endregion +namespace SharpGorilla +{ + //public class DynamicBuffer + //{ + // /// <summary> + // /// + // /// </summary> + // protected dynamic _buffer; + // /// <summary> + // /// + // /// </summary> + // protected int _used; + // /// <summary> + // /// + // /// </summary> + // protected int _capacity; + // /// <summary> + // /// + // /// </summary> + // public int Size + // { + // get + // { + // return _used; + // } + // } + // /// <summary> + // /// + // /// </summary> + // public int Capacity + // { + // get + // { + // return _capacity; + // } + // } + // /// <summary> + // /// + // /// </summary> + // public dynamic First + // { + // get + // { + // return _buffer == null ? null :_buffer[0]; + // } + // } + // /// <summary> + // /// + // /// </summary> + // public dynamic Last + // { + // get + // { + // return _buffer == null ? null : _buffer[_used - 1]; + // } + // } + // /// <summary> + // /// + // /// </summary> + // /// <param name="index"></param> + // /// <returns></returns> + // public dynamic this[int index] + // { + // get + // { + // return _buffer[index]; + // } + // } + // /// <summary> + // /// + // /// </summary> + // /// <param name="index"></param> + // /// <returns></returns> + // public dynamic At(int index) + // { + // return _buffer[index]; + // } + // /// <summary> + // /// + // /// </summary> + // public void Clear() + // { + // _used = 0; + // } + // /// <summary> + // /// + // /// </summary> + // /// <param name="capacity"></param> + // public void Resize(int capacity) + // { + // dynamic newBuffer = new dynamic[capacity]; + + // if (_used != 0) + // { + // if (_used < capacity)// copy all + // { + // for (int i = 0; i < _used; i++) + // { + // newBuffer[i] = _buffer[i]; + // } + // } + // else if (_used >= capacity) // copy some + // { + // for (int i = 0; i < _capacity;i++ ) + // { + // newBuffer[i] = _buffer[i]; + // } + // } + // } + + // _capacity = capacity; + // _buffer = newBuffer; + // } + // /// <summary> + // /// + // /// </summary> + // /// <param name="value"></param> + // public void Add(dynamic value) + // { + // if (_used == _capacity) + // { + // Resize(_used == 0 ? 1 : _used * 2); + // } + + // _buffer[_used] = value; + // _used++; + // } + // /// <summary> + // /// + // /// </summary> + // public void PopBack() + // { + // if (_used != 0) + // _used--; + // } + // /// <summary> + // /// + // /// </summary> + // /// <param name="index"></param> + // public void Remove(int index) + // { + // _buffer[index] = _buffer[_used - 1]; + // _used--; + // } + //} + + public class DynamicBuffer<T> + { + /// <summary> + /// + /// </summary> + protected T[] _buffer; + /// <summary> + /// + /// </summary> + protected int _used; + /// <summary> + /// + /// </summary> + protected int _capacity; + /// <summary> + /// + /// </summary> + public int Size + { + get + { + return _used; + } + } + /// <summary> + /// + /// </summary> + public int Capacity + { + get + { + return _capacity; + } + } + /// <summary> + /// + /// </summary> + public T First + { + get + { + return _buffer == null ? default(T) : _buffer[0]; + } + } + /// <summary> + /// + /// </summary> + public T Last + { + get + { + return _buffer == null ? default(T) : _buffer[_used - 1]; + } + } + /// <summary> + /// + /// </summary> + /// <param name="index"></param> + /// <returns></returns> + public T this[int index] + { + get + { + return _buffer[index]; + } + set + { + _buffer[index] = value; + } + } + public T[] ToArray() + { + return _buffer; + } + public void SetData( T[] data ) + { + _buffer = data; + } + /// <summary> + /// + /// </summary> + /// <param name="index"></param> + /// <returns></returns> + public T At(int index) + { + return _buffer[index]; + } + /// <summary> + /// + /// </summary> + public void Clear() + { + _used = 0; + } + /// <summary> + /// + /// </summary> + /// <param name="capacity"></param> + public void Resize(int capacity) + { + T[] newBuffer = new T[capacity]; + + if (_used != 0) + { + if (_used < capacity)// copy all + { + for (int i = 0; i < _used; i++) + { + newBuffer[i] = _buffer[i]; + } + } + else if (_used >= capacity) // copy some + { + for (int i = 0; i < _capacity; i++) + { + newBuffer[i] = _buffer[i]; + } + } + } + + _capacity = capacity; + _buffer = newBuffer; + } + /// <summary> + /// + /// </summary> + /// <param name="value"></param> + public void Add(T value) + { + if (_used == _capacity) + { + Resize(_used == 0 ? 1 : _used * 2); + } + + _buffer[_used] = value; + _used++; + } + /// <summary> + /// + /// </summary> + public void PopBack() + { + if (_used != 0) + _used--; + } + /// <summary> + /// + /// </summary> + /// <param name="index"></param> + public void Remove(int index) + { + _buffer[index] = _buffer[_used - 1]; + _used--; + } + } +} Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/Enums.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Enums.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/Enums.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/Enums.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,113 @@ +#region License +/* + Gorilla + ------- + + Copyright (c) 2010 Robin Southern + + This is a c# (Axiom) port of Gorrilla, developed by Robin Southern, ported by me (bostich) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +#endregion + +#region SVN Version Information +// <file> +// <id value="$Id: 2118 2010-09-26 23:56:56Z bostich $"/> +// </file> +#endregion SVN Version Information + +#region Namespace Declarations +#endregion +namespace SharpGorilla +{ + /// <summary> + /// Directions for background gradients + /// </summary> + public enum Gradient + { + NorthSouth, + WestEast, + Diagonal, + } + /// <summary> + /// Border Directions + /// <remarks> + /// <para>+---------------------+</para> + /// <para>|\ NORTH /|</para> + /// <para>| \ / |</para> + /// <para>| +---------------+ |</para> + /// <para>| | | |</para> + /// <para>| W| |E |</para> + /// <para>| E| |A |</para> + /// <para>| S| |S |</para> + /// <para>| T| |T |</para> + /// <para>| | | |</para> + /// <para>| +---------------+ |</para> + /// <para>| / SOUTH \ |</para> + /// <para>|/ \|</para> + /// <para>+---------------------+</para> + /// </remarks> + /// </summary> + public enum Border + { + North = 0, + South = 1, + East = 2, + West = 3, + } + /// <summary> + /// Names of each corner/vertex of a Quad + /// </summary> + public enum QuadCorner + { + TopLeft = 0, + TopRight = 1, + BottomRight = 2, + BottomLeft = 3, + } + /// <summary> + /// Horizontal text alignment for captions. + /// </summary> + public enum TextAlignment + { + /// <summary> + /// Place the text to where left is (X = left) + /// </summary> + Left, + /// <summary> + /// Place the text to the right of left (X = left - text_width) + /// </summary> + Right, + /// <summary> + /// Place the text centered at left (X = left - (text_width / 2 ) ) + /// </summary> + Center + } + /// <summary> + /// Vertical text alignment for captions. + /// </summary> + public enum VerticalAlignment + { + Top, + Middle, + Bottom, + } + +} Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/Glyph.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Glyph.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/Glyph.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/Glyph.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,159 @@ +#region License +/* + Gorilla + ------- + + Copyright (c) 2010 Robin Southern + + This is a c# (Axiom) port of Gorrilla, developed by Robin Southern, ported by me (bostich) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +#endregion + +#region SVN Version Information +// <file> +// <id value="$Id: 2118 2010-09-26 23:56:56Z bostich $"/> +// </file> +#endregion SVN Version Information + +#region Namespace Declarations +using System; +using Axiom.Math; +#endregion +namespace SharpGorilla +{ + /// <summary> + /// Texture and size information about a single character loaded from a TextureAtlas. + /// </summary> + public class Glyph + { + private Vector2[] _texCoords = new Vector2[4]; + /// <summary> + /// + /// </summary> + public DynamicBuffer<Kerning> Kerning + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Vector2[] TexCoords + { + get { return _texCoords; } + set { _texCoords = value; } + } + /// <summary> + /// + /// </summary> + public Real UVTop + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real UVWidth + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real UVBottom + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real UVHeight + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real UVLeft + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real UVRight + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real GlyphWidth + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real GlyphHeight + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real GlyphAdvance + { + get; + set; + } + public Glyph() + { + Kerning = new DynamicBuffer<Kerning>(); + } + /// <summary> + /// + /// </summary> + /// <param name="leftof"></param> + /// <returns></returns> + public Real GetKerning(char leftof) + { + if (Kerning.Size == 0) + return 0; + + for (int i = 0; i < Kerning.Size; i++) + { + if (Kerning[i].Character == leftof) + return Kerning[i].kerning; + } + + return 0; + } + } +} Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/GlyphData.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/GlyphData.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/GlyphData.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/GlyphData.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,136 @@ +#region License +/* + Gorilla + ------- + + Copyright (c) 2010 Robin Southern + + This is a c# (Axiom) port of Gorrilla, developed by Robin Southern, ported by me (bostich) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +#endregion + +#region SVN Version Information +// <file> +// <id value="$Id: 2118 2010-09-26 23:56:56Z bostich $"/> +// </file> +#endregion SVN Version Information + +#region Namespace Declarations +using System; +using System.Collections.Generic; + +using Axiom.Math; +#endregion +namespace SharpGorilla +{ + /// <summary> + /// Collection of glyphs of the same size. + /// </summary> + public class GlyphData + { + /// <summary> + /// + /// </summary> + public List<Glyph> Glyphs + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real RangeBegin + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real RangeEnd + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real SpaceLength + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real LineHeight + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real Baseline + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real LetterSpacing + { + get; + set; + } + /// <summary> + /// + /// </summary> + public Real MonoWidth + { + get; + set; + } + /// <summary> + /// + /// </summary> + public GlyphData() + { + Glyphs = new List<Glyph>(); + } + /// <summary> + /// Get a glyph (character information) from a specific character. + /// </summary> + /// <param name="character"></param> + /// <returns> + /// If the character doesn't exist then a null pointer is returned. + /// Do not delete the Glyph pointer. + /// </returns> + public Glyph GetGlyph(int character) + { + character = character - (int)RangeBegin; + if (character > RangeEnd) + return null; + return Glyphs[character]; + } + } +} Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/Helper.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Helper.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/Helper.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/Helper.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,117 @@ +#region License +/* + Gorilla + ------- + + Copyright (c) 2010 Robin Southern + + This is a c# (Axiom) port of Gorrilla, developed by Robin Southern, ported by me (bostich) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +#endregion + +#region SVN Version Information +// <file> +// <id value="$Id: 2118 2010-09-26 23:56:56Z bostich $"/> +// </file> +#endregion SVN Version Information + +#region Namespace Declarations +using System; +using Axiom.Math; +using Axiom.Core; +#endregion +namespace SharpGorilla +{ + public static class Helper + { + /// <summary> + /// + /// </summary> + /// <param name="vertices"></param> + /// <param name="vertex"></param> + /// <param name="x"></param> + /// <param name="y"></param> + /// <param name="uv"></param> + /// <param name="color"></param> + public static void AddVertex(ref DynamicBuffer<Vertex> vertices, Vertex vertex, Real x, Real y, Vector2 uv, ColorEx color) + { + vertex.Position.x = x; + vertex.Position.y = y; + vertex.Position.z = 0; + vertex.UV.x = uv.x; + vertex.UV.y = uv.y; + vertex.Color = color; + vertices.Add(vertex); + } + /// <summary> + /// + /// </summary> + /// <param name="vertices"></param> + /// <param name="vertex"></param> + /// <param name="a"></param> + /// <param name="b"></param> + /// <param name="c"></param> + /// <param name="uv"></param> + /// <param name="color"></param> + public static void AddTriangle(ref DynamicBuffer<Vertex> vertices, Vertex vertex, Vector2 a, Vector2 b, Vector2 c, Vector2 uv, ColorEx color) + { + AddVertex(ref vertices, vertex, a.x, a.y, uv, color); + AddVertex(ref vertices, vertex, b.x, b.y, uv, color); + AddVertex(ref vertices, vertex, c.x, c.y, uv, color); + } + /// <summary> + /// + /// </summary> + /// <param name="vertices"></param> + /// <param name="vertex"></param> + /// <param name="positions"></param> + /// <param name="colors"></param> + /// <param name="uv"></param> + public static void AddQuad(ref DynamicBuffer<Vertex> vertices, Vertex vertex, Vector2[] positions, ColorEx[] colors, Vector2[] uv) + { + AddVertex(ref vertices, vertex, positions[3].x, positions[3].y, uv[3], colors[3]); + AddVertex(ref vertices, vertex, positions[1].x, positions[1].y, uv[1], colors[1]); + AddVertex(ref vertices, vertex, positions[0].x, positions[0].y, uv[0], colors[0]); + + AddVertex(ref vertices, vertex, positions[3].x, positions[3].y, uv[3], colors[3]); + AddVertex(ref vertices, vertex, positions[2].x, positions[2].y, uv[2], colors[2]); + AddVertex(ref vertices, vertex, positions[1].x, positions[1].y, uv[1], colors[1]); + } + /// <summary> + /// + /// </summary> + /// <param name="vertices"></param> + /// <param name="vertex"></param> + /// <param name="positions"></param> + /// <param name="colors"></param> + /// <param name="uv"></param> + public static void AddQuad2(ref DynamicBuffer<Vertex> vertices, Vertex vertex, Vector2[] positions, ColorEx color, Vector2[] uv) + { + AddVertex(ref vertices, vertex, positions[3].x, positions[3].y, uv[3], color); + AddVertex(ref vertices, vertex, positions[1].x, positions[1].y, uv[1], color); + AddVertex(ref vertices, vertex, positions[0].x, positions[0].y, uv[0], color); + + AddVertex(ref vertices, vertex, positions[3].x, positions[3].y, uv[3], color); + AddVertex(ref vertices, vertex, positions[2].x, positions[2].y, uv[2], color); + AddVertex(ref vertices, vertex, positions[1].x, positions[1].y, uv[1], color); + } + } +} Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/ILayerContainer.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/ILayerContainer.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/ILayerContainer.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/ILayerContainer.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,127 @@ +#region License +/* + Gorilla + ------- + + Copyright (c) 2010 Robin Southern + + This is a c# (Axiom) port of Gorrilla, developed by Robin Southern, ported by me (bostich) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ +#endregion + +#region SVN Version Information +// <file> +// <id value="$Id: 2118 2010-09-26 23:56:56Z bostich $"/> +// </file> +#endregion SVN Version Information + +#region Namespace Declarations +using System; +using Axiom.Math; +#endregion + +namespace SharpGorilla +{ + public interface ILayerContainer + { + /// <summary> + /// + /// </summary> + TextureAtlas Atlas + { + get; + } + /// <summary> + /// + /// </summary> + Real TexelOffsetX + { + get; + } + /// <summary> + /// + /// </summary> + Real TexelOffsetY + { + get; + } + /// <summary> + /// + /// </summary> + /// <param name="index"></param> + /// <returns></returns> + Layer CreateLayer(int index); + /// <summary> + /// + /// </summary> + /// <param name="layer"></param> + void Destroy(ref Layer layer); + /// <summary> + /// + /// </summary> + /// <param name="initialSize"></param> + void CreateVertexBuffer(int initialSize); + /// <summary> + /// + /// </summary> + void DestroyVertexBuffer(); + /// <summary> + /// + /// </summary> + void ResizeVertexBuffer(int requestedSize); + /// <summary> + /// + /// </summary> + void ReCalculateIndexes(); + /// <summary> + /// + /// </summary> + /// <param name="id"></param> + /// <param name="force"></param> + void RedrawIndex(int id, bool force); + /// <summary> + /// + /// </summary> + /// <param name="force"></param> + void RedrawAllIndexs(bool force); + /// <summary> + /// + /// </summary> + /// <param name="index"></param> + void RequestIndexRedraw(int index); + /// <summary> + /// + /// </summary> + /// <param name="force"></param> + void RenderVertices(bool force); + /// <summary> + /// + /// </summary> + void RenderOnce(); + /// <summary> + /// + /// </summary> + /// <param name="vertices"></param> + /// <param name="begin"></param> + /// <param name="end"></param> + void Transform(ref DynamicBuffer<Vertex> vertices, int begin, int end); + } +} Copied: Axiom.SharpGorilla/trunk/src/SharpGorilla/Layer.cs (from rev 268, Axiom.SharpGorilla/trunk/src/SharpGorilla/SharpGorilla/Layer.cs) =================================================================== --- Axiom.SharpGorilla/trunk/src/SharpGorilla/Layer.cs (rev 0) +++ Axiom.SharpGorilla/trunk/src/SharpGorilla/Layer.cs 2011-03-02 21:05:04 UTC (rev 269) @@ -0,0 +1,617 @@ +#region License +/* + Gorilla + ------- + + Copyright... [truncated message content] |