/// <summary> /// Uploads the contents of a bitmap to the given texture layer and level.<br/> /// Will result in an OpenGL error if the given bitmap is incompatible with the textures storage. /// </summary> public static void LoadBitmap(this LayeredTexture texture, Bitmap bitmap, int layer, int level = 0) { texture.Bind(); var data = LockBits(bitmap); try { var map = BitmapFormat.Get(bitmap); GL.TexSubImage3D(texture.TextureTarget, level, 0, 0, layer, data.Width, data.Height, 1, map.PixelFormat, map.PixelType, data.Scan0); } finally { bitmap.UnlockBits(data); } CheckError(); }
/// <summary> /// Attaches a single layer of the given texture level to an attachment point. /// </summary> /// <remarks> /// Note that for cube maps and cube map arrays the <paramref name="layer"/> parameter actually indexes the layer-faces.<br/> /// Thus for cube maps the layer parameter equals the face to be bound.<br/> /// For cube map arrays the layer parameter can be calculated as 6 * arrayLayer + face, which is done automatically when using /// the corresponding overload <see cref="Attach(FramebufferTarget, FramebufferAttachment, TextureCubemapArray, int, int, int)"/>. /// </remarks> /// <param name="target">The framebuffer target to bind to.</param> /// <param name="attachment">The attachment point to attach to.</param> /// <param name="texture">The texture to attach.</param> /// <param name="layer">The layer of the texture to attach.</param> /// <param name="level">The level of the texture to attach.</param> public void Attach(FramebufferTarget target, FramebufferAttachment attachment, LayeredTexture texture, int layer, int level = 0) { texture.AssertLevel(level); AssertActive(target); GL.FramebufferTextureLayer(target, attachment, texture.Handle, level, layer); CheckState(target); }