コード例 #1
0
ファイル: JTexture.cs プロジェクト: Sidneys1/VirusFactory
        /// <summary>
        /// Constructs a JTexture from a parent texture
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="topLeftX"></param>
        /// <param name="topLeftY"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public JTexture(JTexture parent, float topLeftX, float topLeftY, float width, float height, bool alpha)
        {
            if (topLeftX < 0 || topLeftY < 0 || topLeftX + width > parent.w || topLeftY + height > parent.h)
            {
                throw new ArgumentException("Attempted to define a sub JTexture outside the bounds of the parent");
            }


            isSubTexture = true;
            _GLTexID     = parent.GLTexID;
            _hasAlpha    = parent.hasAlpha;
            useAlpha     = alpha;

            _w = width;
            _h = height;

            float parentTextureW = parent.topRight.X - parent.bottomLeft.X;
            float parentTextureH = parent.topRight.Y - parent.bottomLeft.Y;

            bottomLeft.X = parent.bottomLeft.X + (float)topLeftX * parentTextureW / parent.w;
            topRight.X   = parent.bottomLeft.X + (float)(topLeftX + width) * parentTextureW / parent.w;

            bottomLeft.Y = parent.bottomLeft.Y + (1 - (float)(topLeftY + height) / parent.h) * parentTextureH;
            topRight.Y   = parent.bottomLeft.Y + (1 - (float)topLeftY / parent.h) * parentTextureH;
        }
コード例 #2
0
ファイル: JTexture.cs プロジェクト: Richy19/FimbulvetrEngine
        /// <summary>
        /// Constructs a JTexture from a parent texture
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="topLeftX"></param>
        /// <param name="topLeftY"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public JTexture(JTexture parent, float topLeftX, float topLeftY, float width, float height, bool alpha)
        {
            if (topLeftX < 0 || topLeftY < 0 || topLeftX + width > parent.w || topLeftY + height > parent.h)
            {
                throw new ArgumentException("Attempted to define a sub JTexture outside the bounds of the parent");
            }

            isSubTexture = true;
            _GLTexID = parent.GLTexID;
            _hasAlpha = parent.hasAlpha;
            useAlpha = alpha;

            _w = width;
            _h = height;

            float parentTextureW = parent.topRight.X - parent.bottomLeft.X;
            float parentTextureH = parent.topRight.Y - parent.bottomLeft.Y;

            bottomLeft.X = parent.bottomLeft.X + (float)topLeftX * parentTextureW / parent.w;
            topRight.X = parent.bottomLeft.X + (float)(topLeftX + width) * parentTextureW / parent.w;

            bottomLeft.Y = parent.bottomLeft.Y + (1 - (float)(topLeftY + height) / parent.h) * parentTextureH;
            topRight.Y = parent.bottomLeft.Y + (1 - (float)topLeftY / parent.h) * parentTextureH;
        }
コード例 #3
0
ファイル: JTextureManager.cs プロジェクト: law4x/stonevox3d
 public void Remove(JTexture textureToRemove)
 {
     textureList.Remove(textureToRemove);
     textureToRemove.Free();
 }
コード例 #4
0
ファイル: JTextureManager.cs プロジェクト: law4x/stonevox3d
 public JTexture Add(JTexture texture)
 {
     textureList.Add(texture);
     return texture;
 }
コード例 #5
0
 public void Remove(JTexture textureToRemove)
 {
     textureList.Remove(textureToRemove);
     textureToRemove.Free();
 }
コード例 #6
0
 public JTexture Add(JTexture texture)
 {
     textureList.Add(texture);
     return(texture);
 }