コード例 #1
0
ファイル: GLES2TextureBuffer.cs プロジェクト: bostich83/axiom
        protected override void Download(PixelBox data)
        {
#if GL_NV_get_tex_image
            if (data.Width != Width || data.Height != Height || data.Depth != Depth)
            {
                throw new Core.AxiomException("only download of entire buffer is supported by GL");
            }

            GL.BindTexture(this.target, this.textureID);
            if (PixelUtil.IsCompressed(data.Format))
            {
                if (data.Format != format || !data.IsConsecutive)
                {
                    throw new Core.AxiomException("Compressed images must be consecutive, in the source format");
                }

                GL.GetCompressedTexImageNV(this.faceTarget, this.level, data.Data);
            }
            else
            {
                if ((data.Width * PixelUtil.GetNumElemBytes(data.Format) & 3) != 0)
                {
                    //Standard alignment of 4 is not right
                    GL.PixelStore(Glenum.PackAlignment, 1);
                }

                //We can only get the entire texture
                GL.GetTexImageNV(this.faceTarget, this.level, GLES2PixelUtil.GetGLOriginFormat(data.Format), GLES2PixelUtil.GetGLOriginDataType(data.Format), data.Data);

                //Restore defaults
                GL.PixelStore(Glenum.PackAlignment, 4);
            }
#else
            throw new Core.AxiomException("Downloading texture buffers is not supported by OpenGL ES");
#endif
        }