CalculateMipLevels() 정적인 개인적인 메소드

static private CalculateMipLevels ( int width, int height, int depth ) : int
width int
height int
depth int
리턴 int
예제 #1
0
 internal TextureCube(GraphicsDevice graphicsDevice, int size, bool mipMap, SurfaceFormat format, bool renderTarget)
 {
     if (graphicsDevice == null)
     {
         throw new ArgumentNullException("graphicsDevice");
     }
     this.GraphicsDevice = graphicsDevice;
     this.size           = size;
     this.format         = format;
     this.levelCount     = mipMap ? Texture.CalculateMipLevels(size, 0, 0) : 1;
     this.glTarget       = TextureTarget.TextureCubeMap;
     GL.GenTextures(1, out this.glTexture);
     GL.BindTexture(TextureTarget.TextureCubeMap, this.glTexture);
     GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, mipMap ? 9987 : 9729);
     GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMagFilter, 9729);
     GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapS, 33071);
     GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapT, 33071);
     GraphicsExtensions.GetGLFormat(format, out this.glInternalFormat, out this.glFormat, out this.glType);
     for (int index = 0; index < 6; ++index)
     {
         TextureTarget glCubeFace = this.GetGLCubeFace((CubeMapFace)index);
         if (this.glFormat == (PixelFormat)34467)
         {
             throw new NotImplementedException();
         }
         GL.TexImage2D(glCubeFace, 0, this.glInternalFormat, size, size, 0, this.glFormat, this.glType, IntPtr.Zero);
     }
     if (!mipMap)
     {
         return;
     }
     GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.GenerateMipmap, 1);
 }
예제 #2
0
        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);
            }));
        }
예제 #3
0
 internal void GenerateMipmaps()
 {
     Threading.BlockOnUIThread((Action)(() =>
     {
         int local_0 = GraphicsExtensions.GetBoundTexture2D();
         GL.ActiveTexture(TextureUnit.Texture0);
         GL.BindTexture(TextureTarget.Texture2D, this.glTexture);
         GL.Hint(HintTarget.GenerateMipmapHint, HintMode.Nicest);
         GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
         this.levelCount = Texture.CalculateMipLevels(this.width, this.height, 0);
         GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, 9987);
         GL.BindTexture(TextureTarget.Texture2D, local_0);
     }));
 }