public static Media.PixelFormat GetClosestSupported(Media.PixelFormat format) { if (ConvertEnum(format) != D3D9.Format.Unknown) { return(format); } switch (format) { case Media.PixelFormat.B5G6R5: return(Media.PixelFormat.R5G6B5); case Media.PixelFormat.B8G8R8: return(Media.PixelFormat.R8G8B8); case Media.PixelFormat.B8G8R8A8: return(Media.PixelFormat.A8R8G8B8); case Media.PixelFormat.FLOAT16_RGB: return(Media.PixelFormat.FLOAT16_RGBA); case Media.PixelFormat.FLOAT32_RGB: return(Media.PixelFormat.FLOAT32_RGBA); case Media.PixelFormat.Unknown: default: return(Media.PixelFormat.A8R8G8B8); } }
/// <summary> /// </summary> /// <param name="ttype"> </param> /// <param name="format"> </param> /// <param name="usage"> </param> /// <returns> </returns> public override Media.PixelFormat GetNativeFormat(TextureType ttype, Media.PixelFormat format, TextureUsage usage) { // Adjust requested parameters to capabilities RenderSystemCapabilities caps = Root.Instance.RenderSystem.HardwareCapabilities; #warning check TextureCompressionVTC == RSC_TEXTURE_COMPRESSION_PVRTC // Check compressed texture support // if a compressed format not supported, revert to A8R8G8B8 if (PixelUtil.IsCompressed(format) && !caps.HasCapability(Capabilities.TextureCompressionDXT) && !caps.HasCapability(Capabilities.TextureCompressionVTC)) { return(Media.PixelFormat.A8R8G8B8); } // if floating point textures not supported, revert to A8R8G8B8 if (PixelUtil.IsFloatingPoint(format) && !caps.HasCapability(Capabilities.TextureFloat)) { return(Media.PixelFormat.A8R8G8B8); } // Check if this is a valid rendertarget format if ((usage & TextureUsage.RenderTarget) != 0) { /// Get closest supported alternative /// If format is supported it's returned return(GLESRTTManager.Instance.GetSupportedAlternative(format)); } // Supported return(format); }
public static Bitmap PixelFormat(this Bitmap input, Media.PixelFormat format) { var result = new Bitmap(input.Width, input.Height, format.Imaging()); using (var g = Graphics.FromImage(result)) g.DrawImage(input, new Rectangle(0, 0, result.Width, result.Height)); return result; }
/// <summary> /// Construct an Bitmap from a section handle. /// </summary> /// <param name="section"></param> /// <param name="pixelWidth"></param> /// <param name="pixelHeight"></param> /// <param name="format"></param> /// <param name="stride"></param> /// <param name="offset"></param> /// <remarks> /// Callers must have UnmanagedCode permission to call this API. /// </remarks> unsafe public static BitmapSource CreateBitmapSourceFromMemorySection( IntPtr section, int pixelWidth, int pixelHeight, Media.PixelFormat format, int stride, int offset) { if (section == IntPtr.Zero) { throw new ArgumentNullException("section"); } return(new InteropBitmap(section, pixelWidth, pixelHeight, format, stride, offset)); }
/// <summary> /// </summary> /// <param name="format"> </param> /// <returns> </returns> public virtual Media.PixelFormat GetSupportedAlternative(Media.PixelFormat format) { if (CheckFormat(format)) { return(format); } /// Find first alternative PixelComponentType pct = PixelUtil.GetComponentType(format); switch (pct) { case PixelComponentType.Byte: format = Media.PixelFormat.A8R8G8B8; break; case PixelComponentType.Short: format = Media.PixelFormat.SHORT_RGBA; break; case PixelComponentType.Float16: format = Media.PixelFormat.FLOAT16_RGBA; break; case PixelComponentType.Float32: format = Media.PixelFormat.FLOAT32_RGBA; break; case PixelComponentType.Count: default: break; } if (CheckFormat(format)) { return(format); } // If none at all, return to default return(Media.PixelFormat.A8R8G8B8); }
/// <summary> /// Returns whether this render system has hardware filtering supported for the texture format requested with the given usage options. /// </summary> /// <param name="ttype"> The texture type requested </param> /// <param name="format"> The pixel format requested </param> /// <param name="usage"> the kind of usage this texture is intended for, a combination of the TextureUsage flags. </param> /// <param name="preciseFormatOnly"> Whether precise or fallback format mode is used to detecting. In case the pixel format doesn't supported by device, false will be returned if in precise mode, and natively used pixel format will be actually use to check if in fallback mode. </param> /// <returns> true if the texture filtering is supported. </returns> public override bool IsHardwareFilteringSupported(TextureType ttype, Media.PixelFormat format, int usage, bool preciseFormatOnly) { if (format == Media.PixelFormat.Unknown) { return(false); } // Check native format Media.PixelFormat nativeFormat = GetNativeFormat(ttype, format, (TextureUsage)usage); if (preciseFormatOnly && format != nativeFormat) { return(false); } // Assume non-floating point is supported always if (!PixelUtil.IsFloatingPoint(nativeFormat)) { return(true); } return(false); }
public static D3D9.Format ConvertEnum(Media.PixelFormat format) { switch (format) { case Media.PixelFormat.A8: return(D3D9.Format.A8); case Media.PixelFormat.L8: return(D3D9.Format.L8); case Media.PixelFormat.L16: return(D3D9.Format.L16); case Media.PixelFormat.A4L4: return(D3D9.Format.A4L4); case Media.PixelFormat.A8L8: return(D3D9.Format.A8L8); // Assume little endian here case Media.PixelFormat.R3G3B2: return(D3D9.Format.R3G3B2); case Media.PixelFormat.A1R5G5B5: return(D3D9.Format.A1R5G5B5); case Media.PixelFormat.A4R4G4B4: return(D3D9.Format.A4R4G4B4); case Media.PixelFormat.R5G6B5: return(D3D9.Format.R5G6B5); case Media.PixelFormat.R8G8B8: return(D3D9.Format.R8G8B8); case Media.PixelFormat.X8R8G8B8: return(D3D9.Format.X8R8G8B8); case Media.PixelFormat.A8R8G8B8: return(D3D9.Format.A8R8G8B8); case Media.PixelFormat.X8B8G8R8: return(D3D9.Format.X8B8G8R8); case Media.PixelFormat.A8B8G8R8: return(D3D9.Format.A8B8G8R8); case Media.PixelFormat.A2R10G10B10: return(D3D9.Format.A2R10G10B10); case Media.PixelFormat.A2B10G10R10: return(D3D9.Format.A2B10G10R10); case Media.PixelFormat.FLOAT16_R: return(D3D9.Format.R16F); case Media.PixelFormat.FLOAT16_GR: return(D3D9.Format.G16R16F); case Media.PixelFormat.FLOAT16_RGBA: return(D3D9.Format.A16B16G16R16F); case Media.PixelFormat.FLOAT32_R: return(D3D9.Format.R32F); case Media.PixelFormat.FLOAT32_GR: return(D3D9.Format.G32R32F); case Media.PixelFormat.FLOAT32_RGBA: return(D3D9.Format.A32B32G32R32F); case Media.PixelFormat.SHORT_RGBA: return(D3D9.Format.A16B16G16R16); case Media.PixelFormat.SHORT_GR: return(D3D9.Format.G16R16); case Media.PixelFormat.DXT1: return(D3D9.Format.Dxt1); case Media.PixelFormat.DXT2: return(D3D9.Format.Dxt2); case Media.PixelFormat.DXT3: return(D3D9.Format.Dxt3); case Media.PixelFormat.DXT4: return(D3D9.Format.Dxt4); case Media.PixelFormat.DXT5: return(D3D9.Format.Dxt5); default: return(D3D9.Format.Unknown); } ; }
public override bool CheckFormat(Media.PixelFormat format) { return(true); }
public static System.Drawing.Imaging.PixelFormat Imaging(this Media.PixelFormat format) { switch (format) { /* * case Drawing.PixelFormat.Bgr101010: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.BlackWhite: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Cmyk32: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Gray2: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Gray32Float: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Gray4: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Gray8: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Indexed2: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Prgba128Float: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Rgb128Float: * return System.Drawing.Imaging.PixelFormat.; * case Drawing.PixelFormat.Rgba128Float: * return System.Drawing.Imaging.PixelFormat.; */ case Media.PixelFormat.Bgr24: return(System.Drawing.Imaging.PixelFormat.Format24bppRgb); case Media.PixelFormat.Bgr32: return(System.Drawing.Imaging.PixelFormat.Format32bppRgb); case Media.PixelFormat.Bgr555: return(System.Drawing.Imaging.PixelFormat.Format16bppRgb555); case Media.PixelFormat.Bgr565: return(System.Drawing.Imaging.PixelFormat.Format16bppRgb565); case Media.PixelFormat.Bgra32: return(System.Drawing.Imaging.PixelFormat.Format32bppArgb); case Media.PixelFormat.Gray16: return(System.Drawing.Imaging.PixelFormat.Format16bppGrayScale); case Media.PixelFormat.Indexed1: return(System.Drawing.Imaging.PixelFormat.Format1bppIndexed); case Media.PixelFormat.Indexed4: return(System.Drawing.Imaging.PixelFormat.Format4bppIndexed); case Media.PixelFormat.Indexed8: return(System.Drawing.Imaging.PixelFormat.Format8bppIndexed); case Media.PixelFormat.Pbgra32: return(System.Drawing.Imaging.PixelFormat.Format32bppPArgb); case Media.PixelFormat.Prgba64: return(System.Drawing.Imaging.PixelFormat.Format64bppPArgb); case Media.PixelFormat.Rgb24: return(System.Drawing.Imaging.PixelFormat.Format24bppRgb); case Media.PixelFormat.Rgb48: return(System.Drawing.Imaging.PixelFormat.Format48bppRgb); case Media.PixelFormat.Rgba64: return(System.Drawing.Imaging.PixelFormat.Format64bppArgb); } return(default);
/// <summary> /// Check if a certain format is usable as rendertexture format /// </summary> /// <param name="format"> </param> /// <returns> </returns> public abstract bool CheckFormat(Media.PixelFormat format);
public override bool CheckFormat(Media.PixelFormat format) { throw new NotImplementedException(); }
/// <summary> /// </summary> private void Intialize() { // Release depth and stencil, if they were bound Manager.ReleaseRenderbuffer(this._depth); Manager.ReleaseRenderbuffer(this._stencil); Manager.ReleaseRenderbuffer(this._multisampleColorBuffer); /// First buffer must be bound if (this._color[0].Buffer == null) { throw new AxiomException("Attachment 0 must have surface attached"); } // If we're doing multisampling, then we need another FBO which contains a // renderbuffer which is set up to multisample, and we'll blit it to the final // FBO afterwards to perform the multisample resolve. In that case, the // mMultisampleFB is bound during rendering and is the one with a depth/stencil /// Store basic stats int width = this._color[0].Buffer.Width; int height = this._color[0].Buffer.Height; All format = this._color[0].Buffer.GLFormat; Media.PixelFormat axiomFormat = this._color[0].Buffer.Format; // Bind simple buffer to add colour attachments OpenGLOES.BindFramebuffer(All.FramebufferOes, this._fb); GLESConfig.GlCheckError(this); /// Bind all attachment points to frame buffer for (int x = 0; x < Configuration.Config.MaxMultipleRenderTargets; x++) { if (this._color[x].Buffer != null) { if (this._color[x].Buffer.Width != width || this._color[x].Buffer.Height != height) { string ss = string.Empty; ss += "Attachment " + x + " has incompatible size "; ss += this._color[x].Buffer.Width + "x" + this._color[0].Buffer.Height; ss += ". It must be of the same as the size of surface 0, "; ss += width + "x" + height; ss += "."; throw new AxiomException(ss); } if (this._color[x].Buffer.GLFormat != format) { string ss = string.Empty; ss += "Attachment " + x + " has incompatible format."; throw new AxiomException(ss); } this._color[x].Buffer.BindToFramebuffer(All.ColorAttachment0Oes + x, this._color[x].ZOffset); } else { // Detach OpenGLOES.FramebufferRenderbuffer(All.FramebufferOes, All.ColorAttachment0Oes + x, All.RenderbufferOes, 0); GLESConfig.GlCheckError(this); } } //end for x // Now deal with depth / stencil if (this._multiSampleFB != 0) { // Bind multisample buffer OpenGLOES.BindFramebuffer(All.FramebufferOes, this._multiSampleFB); GLESConfig.GlCheckError(this); // Create AA render buffer (color) // note, this can be shared too because we blit it to the final FBO // right after the render is finished this._multisampleColorBuffer = Manager.RequestRenderbuffer(format, width, height, this._numSamples); // Attach it, because we won't be attaching below and non-multisample has // actually been attached to other FBO this._multisampleColorBuffer.Buffer.BindToFramebuffer(All.ColorAttachment0Oes, this._multisampleColorBuffer.ZOffset); // depth & stencil will be dealt with below } /// Depth buffer is not handled here anymore. /// See GLESFrameBufferObject::attachDepthBuffer() & RenderSystem::setDepthBufferFor() /// Do glDrawBuffer calls var bufs = new All[Configuration.Config.MaxMultipleRenderTargets]; int n = 0; for (int x = 0; x < Configuration.Config.MaxMultipleRenderTargets; x++) { // Fill attached colour buffers if (this._color[x].Buffer != null) { bufs[x] = All.ColorAttachment0Oes + x; // Keep highest used buffer + 1 n = x + 1; } else { bufs[x] = All.Never; } } //end for x /// Check status All status = OpenGLOES.CheckFramebufferStatus(All.FramebufferOes); GLESConfig.GlCheckError(this); /// Bind main buffer #if AXIOM_PLATFORM_IPHONE // The screen buffer is 1 on iPhone OpenGLOES.BindFramebuffer(All.FramebufferOes, 1); #else OpenGLOES.BindFramebuffer(All.FramebufferOes, 0); #endif GLESConfig.GlCheckError(this); switch (status) { case All.FramebufferCompleteOes: // everything is fine break; case All.FramebufferUnsupportedOes: throw new AxiomException("All framebuffer formats with this texture internal format unsupported"); default: throw new AxiomException("Framebuffer incomplete or other FBO status error"); } }