예제 #1
0
		/// <summary>
		/// </summary>
		/// <param name="data"> </param>
		/// <param name="outputFormat"> </param>
		/// <returns> </returns>
		public static PixelBox ConvertToGLformat( PixelBox data, out GLES.All outputFormat )
		{
			GLES.All glFormat = GetGLOriginFormat( data.Format );
			outputFormat = glFormat;
			if ( glFormat != 0 )
			{
				// format already supported
				return data;
			}

			PixelBox converted = null;

			if ( data.Format == PixelFormat.R8G8B8 )
			{
				converted = new PixelBox();
				// Convert BGR -> RGB
				converted.Format = PixelFormat.R8G8B8;
				outputFormat = GLES.All.Rgb;
				converted = new PixelBox( data.Width, data.Height, data.Depth, data.Format );
				converted.Data = data.Data;
				unsafe
				{
					var dataptr = (uint*) converted.Data;
					for ( uint i = 0; i < converted.Width * converted.Height; i++ )
					{
						uint* color = dataptr;
						*color = ( *color & 0x000000ff ) << 16 | ( *color & 0x0000FF00 ) | ( *color & 0x00FF0000 ) >> 16;
						dataptr += 1;
					}
				}
			}

			return converted;
		}
예제 #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="attachment"></param>
		/// <param name="zOffset"></param>
		public virtual void BindToFramebuffer( TK.All attachment, int zOffset )
		{
			throw new AxiomException( "Framebuffer bind not possible for this pixelbuffer type" );
		}
예제 #3
0
		/// <summary>
		///   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.
		///   <remarks>
		///     It is valid for this function to always return PixelFormat.A8R8G8B8.
		///   </remarks>
		/// </summary>
		/// <param name="fmt"> </param>
		/// <returns> </returns>
		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;
			}
			;
		}