Skip to content

Commit 1ba0458

Browse files
committed
Fix a bug causing TextureAtlas to be premultiplied twice
1 parent 250bd36 commit 1ba0458

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed
11.9 KB
Loading
Loading
11.9 KB
Loading

TwistedLogik.Ultraviolet.OpenGL/Graphics/OpenGLSurface2D.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ public override Texture2D CreateTexture(Boolean premultiplyAlpha)
204204

205205
using (var copysurf = new SDL_Surface(Width, Height))
206206
{
207-
if (SDL.SetSurfaceBlendMode(nativesurf.Native, SDL_BlendMode.NONE) < 0)
208-
throw new SDL2Exception();
209-
210207
if (SDL.BlitSurface(nativesurf.Native, null, copysurf.Native, null) < 0)
211208
throw new SDL2Exception();
212209

@@ -330,9 +327,6 @@ private static void BlitInternal(OpenGLSurface2D src, Rectangle srcRect, OpenGLS
330327
var sdlSrcRect = new SDL_Rect() { x = srcRect.X, y = srcRect.Y, w = srcRect.Width, h = srcRect.Height };
331328
var sdlDstRect = new SDL_Rect() { x = dstRect.X, y = dstRect.Y, w = dstRect.Width, h = dstRect.Height };
332329

333-
if (SDL.SetSurfaceBlendMode(src.nativesurf.Native, SDL_BlendMode.NONE) < 0)
334-
throw new SDL2Exception();
335-
336330
if (srcRect.Width != dstRect.Width || srcRect.Height != dstRect.Height)
337331
{
338332
if (SDL.BlitScaled(src.nativesurf.Native, &sdlSrcRect, dst.nativesurf.Native, &sdlDstRect) < 0)

TwistedLogik.Ultraviolet.SDL2/Native/SDL_Surface.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public SDL_Surface(Int32 width, Int32 height)
1919
{
2020
if ((this.ptr = SDL.CreateRGBSurface(0, width, height, 32, rmask, gmask, bmask, amask)) == null)
2121
throw new SDL2Exception();
22+
23+
if (SDL.SetSurfaceBlendMode(this.ptr, SDL_BlendMode.NONE) < 0)
24+
throw new SDL2Exception();
2225
}
2326

2427
/// <summary>
@@ -34,6 +37,9 @@ public SDL_Surface(SDL_Surface_Native* src)
3437
if (dst == null)
3538
throw new SDL2Exception();
3639

40+
if (SDL.SetSurfaceBlendMode(dst, SDL_BlendMode.NONE) < 0)
41+
throw new SDL2Exception();
42+
3743
if (SDL.BlitSurface(src, null, dst, null) < 0)
3844
throw new SDL2Exception();
3945

0 commit comments

Comments
 (0)