Browse Source

Merge pull request #8734 from jp2masa/gl-active-texture

Fixed glActiveTexture calls
pull/8739/head
Nikita Tsukanov 4 years ago
committed by GitHub
parent
commit
fcf4270389
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs
  2. 12
      src/Skia/Avalonia.Skia/Gpu/OpenGl/OpenGlBitmapImpl.cs

1
src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs

@ -84,6 +84,7 @@ namespace Avalonia.OpenGL.Controls
using (_context.MakeCurrent())
{
var gl = _context.GlInterface;
gl.ActiveTexture(GL_TEXTURE0);
gl.BindTexture(GL_TEXTURE_2D, 0);
gl.BindFramebuffer(GL_FRAMEBUFFER, 0);
gl.DeleteFramebuffer(_fb);

12
src/Skia/Avalonia.Skia/Gpu/OpenGl/OpenGlBitmapImpl.cs

@ -118,7 +118,7 @@ namespace Avalonia.Skia
{
var gl = _context.GlInterface;
var textures = new int[2];
Span<int> textures = stackalloc int[2];
fixed (int* ptex = textures)
gl.GenTextures(2, ptex);
_texture = textures[0];
@ -139,7 +139,6 @@ namespace Avalonia.Skia
gl.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture, 0);
gl.BindTexture(GL_TEXTURE_2D, oldTexture);
}
}
}
@ -161,15 +160,15 @@ namespace Avalonia.Skia
gl.GetIntegerv(GL_ACTIVE_TEXTURE, out var oldActive);
gl.BindFramebuffer(GL_FRAMEBUFFER, _fbo);
gl.BindTexture(GL_TEXTURE_2D, _frontBuffer);
gl.ActiveTexture(GL_TEXTURE0);
gl.BindTexture(GL_TEXTURE_2D, _frontBuffer);
gl.CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, _bitmap.PixelSize.Width,
_bitmap.PixelSize.Height);
gl.BindFramebuffer(GL_FRAMEBUFFER, oldFbo);
gl.BindTexture(GL_TEXTURE_2D, oldTexture);
gl.ActiveTexture(oldActive);
gl.BindTexture(GL_TEXTURE_2D, oldTexture);
gl.Finish();
}
@ -192,9 +191,8 @@ namespace Avalonia.Skia
if(_disposed)
return;
_disposed = true;
var tex = new[] { _texture, _frontBuffer };
fixed (int* ptex = tex)
gl.DeleteTextures(2, ptex);
var ptex = stackalloc[] { _texture, _frontBuffer };
gl.DeleteTextures(2, ptex);
}
}

Loading…
Cancel
Save