private void Init(GLContext context)
        {
            if (pickingBuffer == null)
            {
                pickingBuffer = new Framebuffer(FramebufferTarget.Framebuffer, context.Width, context.Height, PixelInternalFormat.Rgba, 1);
            }

            if (pickingBuffer.Width != context.Width || pickingBuffer.Height != context.Height)
            {
                pickingBuffer.Resize(context.Width, context.Height);
            }
        }
        public static GLTexture2D CreateTextureRender(GLTexture texture, int arrayLevel, int mipLevel, bool force = false)
        {
            if (!force && cubemapCache.ContainsKey(texture.ID.ToString()))
            {
                return(cubemapCache[texture.ID.ToString()]);
            }
            else
            {
                if (cubemapCache.ContainsKey(texture.ID.ToString()))
                {
                    cubemapCache[texture.ID.ToString()]?.Dispose();
                }
            }

            int width  = texture.Width * 4;
            int height = texture.Height * 3;

            width  = 512;
            height = 256;

            var shader        = GlobalShaders.GetShader("EQUIRECTANGULAR");
            var textureOutput = GLTexture2D.CreateUncompressedTexture(width, height, PixelInternalFormat.Rgba32f);

            textureOutput.MipCount = texture.MipCount;

            texture.Bind();

            textureOutput.Bind();
            textureOutput.GenerateMipmaps();
            textureOutput.Unbind();

            Framebuffer frameBuffer = new Framebuffer(FramebufferTarget.Framebuffer, width, height);

            frameBuffer.Bind();

            GL.Disable(EnableCap.Blend);

            shader.Enable();
            shader.SetBoolToInt("is_array", texture is GLTextureCubeArray);

            if (texture is GLTextureCubeArray)
            {
                GL.ActiveTexture(TextureUnit.Texture1);
                texture.Bind();
                shader.SetInt("dynamic_texture_array", 1);
            }
            else
            {
                GL.ActiveTexture(TextureUnit.Texture1);
                texture.Bind();
                shader.SetInt("dynamic_texture", 1);
            }

            for (int i = 0; i < textureOutput.MipCount; i++)
            {
                int mipWidth  = (int)(width * Math.Pow(0.5, i));
                int mipHeight = (int)(height * Math.Pow(0.5, i));
                frameBuffer.Resize(mipWidth, mipHeight);

                GL.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0,
                                      textureOutput.ID, i);

                shader.SetInt("arrayLevel", arrayLevel);
                shader.SetInt("mipLevel", mipLevel);

                GL.ClearColor(0, 0, 0, 0);
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                GL.Viewport(0, 0, mipWidth, mipHeight);

                //Draw the texture onto the framebuffer
                ScreenQuadRender.Draw();

                break;
            }

            //Disable shader and textures
            GL.UseProgram(0);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            if (cubemapCache.ContainsKey(texture.ID.ToString()))
            {
                cubemapCache[texture.ID.ToString()] = textureOutput;
            }
            else
            {
                cubemapCache.Add(texture.ID.ToString(), textureOutput);
            }
            return(textureOutput);
        }