public static GetClosestAxiomFormat ( OpenTK.Graphics.ES11 fmt ) : PixelFormat | ||
fmt | OpenTK.Graphics.ES11 | |
return | PixelFormat |
/// <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]); } } }
/// <summary> /// </summary> /// <param name="format"> </param> /// <param name="width"> </param> /// <param name="height"> </param> /// <param name="numSamples"> </param> public GLESRenderBuffer(All format, int width, int height, int numSamples) : base(width, height, 1, GLESPixelUtil.GetClosestAxiomFormat(format), BufferUsage.WriteOnly) { _glInternalFormat = format; /// Generate renderbuffer OpenGLOES.GenRenderbuffers(1, ref this._renderbufferID); GLESConfig.GlCheckError(this); /// Bind it to FBO OpenGLOES.BindRenderbuffer(All.RenderbufferOes, this._renderbufferID); GLESConfig.GlCheckError(this); /// Allocate storage for depth buffer if (numSamples <= 0) { OpenGLOES.RenderbufferStorage(All.RenderbufferOes, format, width, height); GLESConfig.GlCheckError(this); } }