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

GetGLOriginFormat() public static method

Takes the Axiom pixel format and returns the appropriate GL one
public static GetGLOriginFormat ( PixelFormat fmt ) : OpenTK.Graphics.ES11.All
fmt PixelFormat
return OpenTK.Graphics.ES11.All
		public static GLES.All GetGLOriginFormat( PixelFormat fmt )
		{
			switch ( fmt )
			{
				case PixelFormat.A8:
					return GLES.All.Alpha;

				case PixelFormat.L8:
				case PixelFormat.L16:
				case PixelFormat.FLOAT16_R:
				case PixelFormat.FLOAT32_R:
					return GLES.All.Luminance;

				case PixelFormat.BYTE_LA:
				case PixelFormat.SHORT_GR:
				case PixelFormat.FLOAT16_GR:
				case PixelFormat.FLOAT32_GR:
					return GLES.All.LuminanceAlpha;

				// PVRTC compressed formats
#if GL_IMG_texture_compression_pvrtc
			case PixelFormat.PVRTC_RGB2:
				return GLES.All.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
			case PixelFormat.PVRTC_RGB4:
				return GLES.All.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
			case PixelFormat.PVRTC_RGBA2:
				return GLES.All.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
			case PixelFormat.PVRTC_RGBA4:
				return GLES.All.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
#endif
				case PixelFormat.R3G3B2:
				case PixelFormat.R5G6B5:
				case PixelFormat.FLOAT16_RGB:
				case PixelFormat.FLOAT32_RGB:
				case PixelFormat.SHORT_RGB:
					return GLES.All.Rgb;

				case PixelFormat.X8R8G8B8:
				case PixelFormat.A8R8G8B8:
				case PixelFormat.B8G8R8A8:
				case PixelFormat.A1R5G5B5:
				case PixelFormat.A4R4G4B4:
				case PixelFormat.A2R10G10B10:
				// This case in incorrect, swaps R & B channels
				//return GLES.All.BGRA;

				case PixelFormat.X8B8G8R8:
				case PixelFormat.A8B8G8R8:
				case PixelFormat.A2B10G10R10:
				case PixelFormat.FLOAT16_RGBA:
				case PixelFormat.FLOAT32_RGBA:
				case PixelFormat.SHORT_RGBA:
					return GLES.All.Rgba;

#if AXIOM_ENDIAN_BIG
				// Formats are in native endian, so R8G8B8 on little endian is
				// BGR, on big endian it is RGB.
				case PixelFormat.R8G8B8:
					return GLES.All.Rgb;
				case PixelFormat.B8G8R8:
					return 0;
#else
				case PixelFormat.R8G8B8:
					return 0;
				case PixelFormat.B8G8R8:
					return GLES.All.Rgb;
#endif
				case PixelFormat.DXT1:
				case PixelFormat.DXT3:
				case PixelFormat.DXT5:
				case PixelFormat.B5G6R5:
				default:
					return 0;
			}
		}

Usage Example

Example #1
0
        protected static void BuildMipmaps(PixelBox data)
        {
            int      width  = 0;
            int      height = 0;
            int      logW   = 0;
            int      logH   = 0;
            int      level  = 0;
            PixelBox scaled = data;

            scaled.Data   = data.Data;
            scaled.Left   = data.Left;
            scaled.Right  = data.Right;
            scaled.Top    = data.Top;
            scaled.Bottom = data.Bottom;
            scaled.Front  = data.Front;
            scaled.Back   = data.Back;

            All format   = GLESPixelUtil.GetGLOriginFormat(data.Format);
            All dataType = GLESPixelUtil.GetGLOriginDataType(data.Format);

            width  = data.Width;
            height = data.Height;

            logW  = ComputeLog(width);
            logH  = ComputeLog(height);
            level = (logW > logH ? logW : logH);

            for (int mip = 0; mip <= level; mip++)
            {
                format   = GLESPixelUtil.GetGLOriginFormat(scaled.Format);
                dataType = GLESPixelUtil.GetGLOriginDataType(scaled.Format);

                OpenGL.TexImage2D(All.Texture2D, mip, (int)format, width, height, 0, format, dataType, scaled.Data);

                GLESConfig.GlCheckError(null);

                if (mip != 0)
                {
                    scaled.Data = IntPtr.Zero;
                }

                if (width > 1)
                {
                    width = width / 2;
                }
                if (height > 1)
                {
                    height = height / 2;
                }

                int sizeInBytes = PixelUtil.GetMemorySize(width, height, 1, data.Format);
                scaled = new PixelBox(width, height, 1, data.Format);
                var dataarr = new byte[sizeInBytes];
                scaled.Data = Memory.PinObject(dataarr);
                Image.Scale(data, scaled, ImageFilter.Linear);
            }
        }
All Usage Examples Of Axiom.RenderSystems.OpenGLES.GLESPixelUtil::GetGLOriginFormat