internal Texture2D(GraphicsDevice graphicsDevice, int width, int height, bool mipmap, SurfaceFormat format, bool renderTarget) { Texture2D texture2D = this; if (graphicsDevice == null) { throw new ArgumentNullException("Graphics Device Cannot Be Null"); } this.GraphicsDevice = graphicsDevice; this.width = width; this.height = height; this.format = format; this.levelCount = mipmap ? Texture.CalculateMipLevels(width, height, 0) : 1; this.glTarget = TextureTarget.Texture2D; Threading.BlockOnUIThread((Action)(() => { int local_0 = GraphicsExtensions.GetBoundTexture2D(); texture2D.GenerateGLTextureIfRequired(); GraphicsExtensions.GetGLFormat(format, out texture2D.glInternalFormat, out texture2D.glFormat, out texture2D.glType); if (texture2D.glFormat == (OpenTK.Graphics.OpenGL.PixelFormat) 34467) { int local_1_1; switch (format) { case SurfaceFormat.Dxt1: local_1_1 = (texture2D.width + 3) / 4 * ((texture2D.height + 3) / 4) * 8; break; case SurfaceFormat.Dxt3: case SurfaceFormat.Dxt5: local_1_1 = (texture2D.width + 3) / 4 * ((texture2D.height + 3) / 4) * 16; break; case SurfaceFormat.RgbPvrtc2Bpp: case SurfaceFormat.RgbaPvrtc2Bpp: local_1_1 = (Math.Max(texture2D.width, 8) * Math.Max(texture2D.height, 8) * 2 + 7) / 8; break; case SurfaceFormat.RgbPvrtc4Bpp: case SurfaceFormat.RgbaPvrtc4Bpp: local_1_1 = (Math.Max(texture2D.width, 16) * Math.Max(texture2D.height, 8) * 4 + 7) / 8; break; default: throw new NotImplementedException(); } GL.CompressedTexImage2D(TextureTarget.Texture2D, 0, texture2D.glInternalFormat, texture2D.width, texture2D.height, 0, local_1_1, IntPtr.Zero); } else { GL.TexImage2D(TextureTarget.Texture2D, 0, texture2D.glInternalFormat, texture2D.width, texture2D.height, 0, texture2D.glFormat, texture2D.glType, IntPtr.Zero); } GL.BindTexture(TextureTarget.Texture2D, local_0); })); }