/// <summary> /// Create the texture, using this technique. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> used for allocating resources. /// </param> public override void Create(GraphicsContext ctx) { int internalFormat = Pixel.GetGlInternalFormat(_PixelFormat, ctx); uint width = _Images[0].Width, height = _Images[0].Height; Gl.TexImage3D(_Target, 0, internalFormat, (int)width, (int)height, _Images.Length, 0, /* Unused */ OpenGL.PixelFormat.Red, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero); for (int i = 0; i < _Images.Length; i++) { Image image = _Images[i]; PixelFormat format = Pixel.GetGlFormat(image.PixelLayout); PixelType type = Pixel.GetPixelType(image.PixelLayout); // Set pixel transfer foreach (int alignment in new int[] { 8, 4, 2, 1 }) { if ((image.Stride % alignment) != 0) { continue; } Gl.PixelStore(PixelStoreParameter.UnpackAlignment, alignment); break; } // Upload texture contents Gl.TexSubImage3D(_Target, 0, 0, 0, i, (int)width, (int)height, 1, format, type, image.ImageBuffer); } // Define texture properties _Texture3d.DefineExtents(_PixelFormat, width, height, (uint)_Images.Length, 0); }
/// <summary> /// Create the texture, using this technique. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> used for allocating resources. /// </param> public override void Create(GraphicsContext ctx) { PixelFormat format = Pixel.GetGlFormat(_PixelFormat); int internalFormat = Pixel.GetGlInternalFormat(_PixelFormat, ctx); // Define empty texture Gl.TexImage3D(_Target, (int)_Level, internalFormat, (int)_Width, (int)_Height, (int)_Depth, 0, format, /* Unused */ PixelType.UnsignedByte, null); // Define texture properties _Texture3d.DefineExtents(_PixelFormat, _Width, _Height, _Depth, _Level); }