Exemple #1
0
        public int initTextureArray(ITextureProvider textureProvider)
        {
            if (!allTexturesLoaded(textureProvider))
            {
                return(-1);
            }

            ITexture[] textures = textureProvider.Textures;

            int textureArrayId = GLUtil.glGenTexture();

            GL.BindTexture(TextureTarget.Texture2DArray, textureArrayId);
            GL.TexStorage3D(TextureTarget3d.Texture2DArray, 1, SizedInternalFormat.Rgba8, TEXTURE_SIZE, TEXTURE_SIZE, textures.Length);

            GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)TextureMinFilter.Nearest);

            GL.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);

            // Set brightness to 1.0d to upload unmodified textures to GPU
            double save = textureProvider.Brightness;

            textureProvider.Brightness = 1.0d;

            updateTextures(textureProvider, textureArrayId);

            textureProvider.Brightness = save;

            GL.ActiveTexture(TextureUnit.Texture1);
            GL.BindTexture(TextureTarget.Texture2DArray, textureArrayId);
            GL.ActiveTexture(TextureUnit.Texture0);

            return(textureArrayId);
        }
Exemple #2
0
 public void freeTextureArray(int textureArrayId)
 {
     GLUtil.glDeleteTexture(textureArrayId);
 }