GetClosestPixelFormat() публичный статический Метод

Function to get the closest matching OGRE 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 GetClosestPixelFormat ( int format ) : PixelFormat
format int
Результат PixelFormat
Пример #1
0
        public GLRenderBuffer(int format, int width, int height, int fsaa)
            : base(width, height, 1, GLPixelUtil.GetClosestPixelFormat(format), BufferUsage.WriteOnly)
        {
            GLFormat = format;
            /// Generate renderbuffer
            Gl.glGenRenderbuffersEXT(1, out this._renderBufferId);
            /// Bind it to FBO
            Gl.glBindRenderbufferEXT(Gl.GL_RENDERBUFFER_EXT, this._renderBufferId);

            /// Allocate storage for depth buffer
            Gl.glRenderbufferStorageEXT(Gl.GL_RENDERBUFFER_EXT, format, width, height);
        }
Пример #2
0
        public GLTextureBuffer(string baseName, int target, int id, int face, int level, BufferUsage usage,
                               bool softwareMipmap, BaseGLSupport glSupport, bool writeGamma, int fsaa)
            : base(0, 0, 0, PixelFormat.Unknown, usage)
        {
            int value;

            this._glSupport = glSupport;

            this._target         = target;
            this._textureId      = id;
            this._face           = face;
            this._level          = level;
            this._softwareMipmap = softwareMipmap;

            Gl.glBindTexture(this._target, this._textureId);

            // Get face identifier
            this._faceTarget = this._target;
            if (this._target == Gl.GL_TEXTURE_CUBE_MAP)
            {
                this._faceTarget = Gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X + this._face;
            }

            // Get width
            Gl.glGetTexLevelParameteriv(this._faceTarget, this._level, Gl.GL_TEXTURE_WIDTH, out value);
            width = value;

            // Get height
            if (this._target == Gl.GL_TEXTURE_1D)
            {
                value = 1; // Height always 1 for 1D textures
            }
            else
            {
                Gl.glGetTexLevelParameteriv(this._faceTarget, this._level, Gl.GL_TEXTURE_HEIGHT, out value);
            }
            height = value;

            // Get depth
            if (this._target != Gl.GL_TEXTURE_3D)
            {
                value = 1; // Depth always 1 for non-3D textures
            }
            else
            {
                Gl.glGetTexLevelParameteriv(this._faceTarget, this._level, Gl.GL_TEXTURE_DEPTH, out value);
            }
            depth = value;

            // Get format
            Gl.glGetTexLevelParameteriv(this._faceTarget, this._level, Gl.GL_TEXTURE_INTERNAL_FORMAT, out value);
            GLFormat = value;
            format   = GLPixelUtil.GetClosestPixelFormat(value);

            // Default
            rowPitch    = Width;
            slicePitch  = Height * Width;
            sizeInBytes = PixelUtil.GetMemorySize(Width, Height, Depth, Format);

            // Set up 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 (((TextureUsage)Usage & TextureUsage.RenderTarget) == TextureUsage.RenderTarget)
            {
                // Create render target for each slice
                this._sliceTRT.Capacity = Depth;
                for (int zoffset = 0; zoffset < Depth; ++zoffset)
                {
                    String name;
                    name = String.Format("{0}/{1}/{2}/{3}", baseName, face, this._level, zoffset);

                    GLSurfaceDesc renderTarget;
                    renderTarget.Buffer  = this;
                    renderTarget.ZOffset = zoffset;
                    RenderTexture trt = GLRTTManager.Instance.CreateRenderTexture(name, renderTarget, writeGamma, fsaa);
                    this._sliceTRT.Add(trt);
                    Root.Instance.RenderSystem.AttachRenderTarget(this._sliceTRT[zoffset]);
                }
            }
        }