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

GetClosestAxiomFormat() public static method

Function to get the closest matching Axiom format to an internal GL format. To be precise, the format will be chosen that is most efficient to transfer to the card without losing precision. It is valid for this function to always return PixelFormat.A8R8G8B8.
public static GetClosestAxiomFormat ( OpenTK.Graphics.ES11 fmt ) : PixelFormat
fmt OpenTK.Graphics.ES11
return PixelFormat
		public static PixelFormat GetClosestAxiomFormat( GLES.All fmt )
		{
			switch ( fmt )
			{
#if GL_IMG_texture_compression_pvrtc
			case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
				return PixelFormat.PVRTC_RGB2;
			case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
				return PixelFormat.PVRTC_RGBA2;
			case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
				return PixelFormat.PVRTC_RGB4;
			case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
				return PixelFormat.PVRTC_RGBA4;
#endif
				case GLES.All.Luminance:
					return PixelFormat.L8;
				case GLES.All.Alpha:
					return PixelFormat.A8;
				case GLES.All.LuminanceAlpha:
					return PixelFormat.BYTE_LA;

				case GLES.All.Rgb:
					return PixelFormat.A8R8G8B8;
				case GLES.All.Rgba:
#if (AXIOM_PLATFORM_IPHONE)
				// seems that in iPhone we need this value to get the right color
				return PixelFormat.A8R8G8B8;
#else
					return PixelFormat.X8B8G8R8;
#endif
#if GL_BGRA
			case GLES.All.Rgba:
#endif
				//                return PixelFormat.X8B8G8R8;
				default:
					//TODO: not supported
					return PixelFormat.A8R8G8B8;
			};
		}

Usage Example

Example #1
0
        /// <summary>
        /// </summary>
        /// <param name="name"> </param>
        /// <param name="target"> </param>
        /// <param name="id"> </param>
        /// <param name="width"> </param>
        /// <param name="height"> </param>
        /// <param name="format"> </param>
        /// <param name="face"> </param>
        /// <param name="level"> </param>
        /// <param name="usage"> </param>
        /// <param name="crappyCard"> </param>
        /// <param name="writeGamma"> </param>
        /// <param name="fsaa"> </param>
        public GLESTextureBuffer(string basename, All targetfmt, int id, int width, int height, int format, int face, int level, BufferUsage usage, bool crappyCard, bool writeGamma, int fsaa)
            : base(0, 0, 0, Media.PixelFormat.Unknown, usage)
        {
            this._target         = targetfmt;
            this._textureId      = id;
            this._face           = face;
            this._level          = level;
            this._softwareMipmap = crappyCard;

            GLESConfig.GlCheckError(this);
            OpenGL.BindTexture(All.Texture2D, this._textureId);
            GLESConfig.GlCheckError(this);

            // Get face identifier
            this._faceTarget = this._target;

            // TODO verify who get this
            Width  = width;
            Height = height;
            Depth  = 1;

            _glInternalFormat = (All)format;
            Format            = GLESPixelUtil.GetClosestAxiomFormat(_glInternalFormat);

            RowPitch    = Width;
            SlicePitch  = Height * Width;
            sizeInBytes = PixelUtil.GetMemorySize(Width, Height, Depth, Format);

            // Set up a pixel box
            _buffer = new PixelBox(Width, Height, Depth, Format);
            if (Width == 0 || Height == 0 || Depth == 0)
            {
                /// We are invalid, do not allocate a buffer
                return;
            }

            // Is this a render target?
            if (((int)Usage & (int)TextureUsage.RenderTarget) != 0)
            {
                // Create render target for each slice
                for (int zoffset = 0; zoffset < Depth; zoffset++)
                {
                    string name = string.Empty;
                    name = "rtt/" + GetHashCode() + "/" + basename;
                    var target = new GLESSurfaceDescription();
                    target.Buffer  = this;
                    target.ZOffset = zoffset;
                    RenderTexture trt = GLESRTTManager.Instance.CreateRenderTexture(name, target, writeGamma, fsaa);
                    this._sliceTRT.Add(trt);
                    Root.Instance.RenderSystem.AttachRenderTarget(this._sliceTRT[zoffset]);
                }
            }
        }
All Usage Examples Of Axiom.RenderSystems.OpenGLES.GLESPixelUtil::GetClosestAxiomFormat