Example #1
0
        public static RendererTexture CreateCubeArrayShadowMap(PixelInternalFormat internalformat, int width, int height, int layers, int border, PixelFormat format, PixelType type, IntPtr pixels)
        {
            int handle;

            GL.GenTextures(1, out handle);
            var txt = new RendererTexture(handle, TextureTarget.TextureCubeMapArray, width, height);

            txt.Bind();
            txt.ObjectLabel = "CubeShadowMapArray";
            txt.AddRef();
            GL.TexImage3D(TextureTarget.TextureCubeMapArray, 0, PixelInternalFormat.DepthComponent16, width, height, layers * 6, border, format, type, pixels);

            txt.SetNearestFilter();
            txt.SetClampToEdgeWrap();
            return(txt);
        }
Example #2
0
        public static unsafe RendererTexture LoadCubeMap(string path)
        {
            //var faces = new string[] { "right", "left", "back", "front", "top", "bottom" };
            //var faces = new string[] { "left", "right", "top", "top", "top", "top" };
            //var faces = new string[] { "top", "top", "top", "top", "left", "top" };
            //var faces = new string[] { "right", "left", "top", "bottom", "back", "front" };
            var faces = new string[] { "right", "left", "top", "bottom", "front", "back" };
            //var faces = new string[] { "right", "left", "front", "back", "top", "bottom" };
            var images = new List <Image>();

            foreach (var face in faces)
            {
                images.Add(LoadBitmap(path.Replace("#", face)));
            }

            var name = Path.GetDirectoryName(path);

            // images[1].RotateFlip(RotateFlipType.Rotate90FlipY);
            // images[3].RotateFlip(RotateFlipType.RotateNoneFlipX);
            // images[2].RotateFlip(RotateFlipType.Rotate180FlipX);
            // images[0].RotateFlip(RotateFlipType.Rotate90FlipX);
            // images[4].RotateFlip(RotateFlipType.RotateNoneFlipY);

            int handle;

            GL.GenTextures(1, out handle);
            var txt = new RendererTexture(handle, TextureTarget.TextureCubeMap, images[0].Width, images[0].Height);

            //txt.ObjectLabel = Path.GetFileName(path);
            txt.Bind();
            txt.ObjectLabel = name;
            txt.AddRef();

            for (var i = 0; i < images.Count; i++)
            {
                images[i].UseData(ptr =>
                {
                    GL.TexImage2D(TextureTarget.TextureCubeMapPositiveX + i, 0, PixelInternalFormat.Rgba, txt.Width, txt.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, ptr);
                });
                images[i].Dispose();
            }
            txt.SetNearestFilter();
            txt.SetClampToEdgeWrap();

            //Console.WriteLine($"Loaded Cubemap #{txt.Handle} {path}");
            return(txt);
        }
Example #3
0
        public static RendererTexture CreateCubeShadowMap(PixelInternalFormat internalformat, int width, int height, int border, PixelFormat format, PixelType type, IntPtr pixels)
        {
            int handle;

            GL.GenTextures(1, out handle);
            var txt = new RendererTexture(handle, TextureTarget.TextureCubeMap, width, height);

            txt.Bind();
            txt.ObjectLabel = "CubeShadowMap";
            txt.AddRef();
            for (var i = 0; i < 6; i++)
            {
                GL.TexImage2D(TextureTarget.TextureCubeMapPositiveX + i, 0, PixelInternalFormat.DepthComponent16, txt.Width, txt.Height, border, format, type, pixels);
            }

            txt.SetNearestFilter();
            txt.SetClampToEdgeWrap();
            return(txt);
        }