/// <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 = _PixelFormat.GetGlInternalFormat(); PixelFormat format = _PixelFormat.GetGlFormat(); // Define empty texture Gl.TexImage3D(_Target, 0, internalFormat, (int)_Width, (int)_Height, (int)_Layers, 0, format, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero); // Define texture properties _TextureArray2d.DefineExtents(_PixelFormat, _Width, _Height, _Layers, 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) { int internalFormat = _PixelFormat.GetGlInternalFormat(); // Define texture storage, if required if (_ResetLayers) { Gl.TexImage3D(_Target, 0, internalFormat, (int)_Images[0].Width, (int)_Images[0].Height, _Images.Length, 0, /* Unused */ OpenGL.PixelFormat.Rgb, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero); } // Define array layers uint width = 0, height = 0; for (int layer = 0; layer < _Images.Length; layer++) { // Allow partial definition if (_Images[layer] == null) { continue; } PixelFormat format = _Images[layer].PixelLayout.GetGlFormat(); PixelType type = _Images[layer].PixelLayout.GetPixelType(); // Set pixel transfer foreach (int alignment in new int[] { 8, 4, 2, 1 }) { if ((_Images[layer].Stride % alignment) != 0) { continue; } Gl.PixelStore(PixelStoreParameter.UnpackAlignment, alignment); break; } width = _Images[layer].Width; height = _Images[layer].Height; // Upload texture contents Gl.TexSubImage3D(_Target, 0, 0, 0, layer, (int)_Images[layer].Width, (int)_Images[layer].Height, 1, format, type, _Images[layer].ImageBuffer); } // Define texture properties if (_ResetLayers) { _TextureArray2d.DefineExtents(_PixelFormat, _Images[0].Width, _Images[0].Height, 1, 0); } }