コード例 #1
0
ファイル: Texture2D.cs プロジェクト: 1144822034/sc2.2mobile
 public void AllocateTexture()
 {
     GL.GenTextures(1, out m_texture);
     GLWrapper.BindTexture(All.Texture2D, m_texture, forceBind: false);
     for (int i = 0; i < MipLevelsCount; i++)
     {
         int width  = MathUtils.Max(Width >> i, 1);
         int height = MathUtils.Max(Height >> i, 1);
         GL.TexImage2D(All.Texture2D, i, (int)m_pixelFormat, width, height, 0, m_pixelFormat, m_pixelType, IntPtr.Zero);
     }
 }
コード例 #2
0
ファイル: Texture2D.cs プロジェクト: 1144822034/sc2.2mobile
        public void SetData <T>(int mipLevel, T[] source, int sourceStartIndex = 0) where T : struct
        {
            VerifyParametersSetData(mipLevel, source, sourceStartIndex);
            GCHandle gCHandle = GCHandle.Alloc(source, GCHandleType.Pinned);

            try
            {
                int    width  = MathUtils.Max(Width >> mipLevel, 1);
                int    height = MathUtils.Max(Height >> mipLevel, 1);
                IntPtr pixels = gCHandle.AddrOfPinnedObject() + sourceStartIndex * Utilities.SizeOf <T>();
                GLWrapper.BindTexture(All.Texture2D, m_texture, forceBind: false);
                GL.TexImage2D(All.Texture2D, mipLevel, (int)m_pixelFormat, width, height, 0, m_pixelFormat, m_pixelType, pixels);
            }
            finally
            {
                gCHandle.Free();
            }
        }
コード例 #3
0
 public void GenerateMipMaps()
 {
     GLWrapper.BindTexture(All.Texture2D, m_texture, forceBind: false);
     GL.GenerateMipmap(All.Texture2D);
 }