Axiom.RenderSystems.OpenGLES.GLESPixelUtil.GetClosestGLInternalFormat C# (CSharp) Method

GetClosestGLInternalFormat() public static method

Takes the Axiom pixel format and returns the type that must be provided to GL as internal format. If no match exists, returns the closest match.
public static GetClosestGLInternalFormat ( PixelFormat mFormat, bool hwGamma = false ) : OpenTK.Graphics.ES11.All
mFormat PixelFormat mFormat The pixel format
hwGamma bool hwGamma Whether a hardware gamma-corrected version is requested
return OpenTK.Graphics.ES11.All
		public static GLES.All GetClosestGLInternalFormat( PixelFormat mFormat, bool hwGamma = false )
		{
			GLES.All format = GetGLInternalFormat( mFormat, hwGamma );
			if ( format == 0 )
			{
				if ( hwGamma )
				{
					// TODO not supported
					return 0;
				}
				else
				{
					return GLES.All.Rgba;
				}
			}
			else
			{
				return format;
			}
		}

Usage Example

Esempio n. 1
0
        /// <summary>
        /// </summary>
        /// <param name="data"> </param>
        /// <param name="dest"> </param>
        protected override void Upload(PixelBox data, BasicBox dest)
        {
            OpenGL.BindTexture(this._target, this._textureId);
            GLESConfig.GlCheckError(this);

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

                if (data.Format != Format || !data.IsConsecutive)
                {
                    throw new AxiomException("Compressed images must be consecutive, in the source format.");
                }

                All format = GLESPixelUtil.GetClosestGLInternalFormat(Format);
                // Data must be consecutive and at beginning of buffer as PixelStorei not allowed
                // for compressed formats
                if (dest.Left == 0 && dest.Top == 0)
                {
                    OpenGL.CompressedTexImage2D(All.Texture2D, this._level, format, dest.Width, dest.Height, 0, data.ConsecutiveSize, data.Data);
                }
                else
                {
                    OpenGL.CompressedTexSubImage2D(All.Texture2D, this._level, dest.Left, dest.Top, dest.Width, dest.Height, format, data.ConsecutiveSize, data.Data);
                }
                GLESConfig.GlCheckError(this);
            }
            else if (this._softwareMipmap)
            {
                if (data.Width != data.RowPitch)
                {
                    //TODO
                    throw new AxiomException("Unsupported Texture format!");
                }
                if (data.Height * data.Width != data.SlicePitch)
                {
                    //TODO
                    throw new AxiomException("Unsupported Texture format!");
                }

                OpenGL.PixelStore(All.UnpackAlignment, 1);
                GLESConfig.GlCheckError(this);
                BuildMipmaps(data);
            }
            else
            {
                if (data.Width != data.RowPitch)
                {
                    //TODO
                    throw new AxiomException("Unsupported Texture format!");
                }
                if (data.Height * data.Width != data.SlicePitch)
                {
                    //TODO
                    throw new AxiomException("Unsupported Texture format!");
                }

                if (((data.Width * PixelUtil.GetNumElemBytes(data.Format)) & 3) != 0)
                {
                    // Standard alignment of 4 is not right
                    OpenGL.PixelStore(All.UnpackAlignment, 1);
                    GLESConfig.GlCheckError(this);
                }
                All form = GLESPixelUtil.GetGLOriginFormat(data.Format);
                All pix  = GLESPixelUtil.GetGLOriginDataType(data.Format);
                GLESConfig.GlCheckError(this);
                GL.TexSubImage2D(this._faceTarget, this._level, dest.Left, dest.Top, dest.Width, dest.Height, GLESPixelUtil.GetGLOriginFormat(data.Format), GLESPixelUtil.GetGLOriginDataType(data.Format), data.Data);
                GLESConfig.GlCheckError(this);
            }

            OpenGL.PixelStore(All.UnpackAlignment, 4);
            GLESConfig.GlCheckError(this);
        }
All Usage Examples Of Axiom.RenderSystems.OpenGLES.GLESPixelUtil::GetClosestGLInternalFormat