Example #1
0
 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);
     }
 }
Example #2
0
        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();
            }
        }
Example #3
0
 public void GenerateMipMaps()
 {
     GLWrapper.BindTexture(All.Texture2D, m_texture, forceBind: false);
     GL.GenerateMipmap(All.Texture2D);
 }