mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2024-11-25 16:18:56 +08:00
Texture pixel format change
This commit is contained in:
parent
6bfc6c7721
commit
d2ce347caa
|
@ -450,7 +450,7 @@ namespace Strawberry
|
||||||
|
|
||||||
public this(int w, int h)
|
public this(int w, int h)
|
||||||
{
|
{
|
||||||
Texture = SDL.CreateTexture(Game.Renderer, (uint32)SDL.PIXELFORMAT_ARGB8888, (int32)SDL.TextureAccess.Static, (int32)w, (int32)h);
|
Texture = SDL.CreateTexture(Game.Renderer, (uint32)SDL.PIXELFORMAT_RGBA8888, (int32)SDL.TextureAccess.Static, (int32)w, (int32)h);
|
||||||
|
|
||||||
void* ptr;
|
void* ptr;
|
||||||
SDL.LockTexture(Texture, null, out ptr, out PixelsLength);
|
SDL.LockTexture(Texture, null, out ptr, out PixelsLength);
|
||||||
|
@ -577,12 +577,12 @@ namespace Strawberry
|
||||||
{
|
{
|
||||||
if (src.A != 0)
|
if (src.A != 0)
|
||||||
{
|
{
|
||||||
int a = dest[index];
|
int r = dest[index];
|
||||||
int r = dest[index + 1];
|
int g = dest[index + 1];
|
||||||
int g = dest[index + 2];
|
int b = dest[index + 2];
|
||||||
int b = dest[index + 3];
|
int a = dest[index + 3];
|
||||||
|
|
||||||
if (dest[index] == 0)
|
if (a == 0)
|
||||||
{
|
{
|
||||||
a = src.A;
|
a = src.A;
|
||||||
r = src.R;
|
r = src.R;
|
||||||
|
@ -594,16 +594,16 @@ namespace Strawberry
|
||||||
int sa = MUL_UN8(src.A, opacity);
|
int sa = MUL_UN8(src.A, opacity);
|
||||||
int ra = a + sa - MUL_UN8(a, sa);
|
int ra = a + sa - MUL_UN8(a, sa);
|
||||||
|
|
||||||
a = ra;
|
|
||||||
r = (r + (src.R - r) * sa / ra);
|
r = (r + (src.R - r) * sa / ra);
|
||||||
g = (g + (src.G - g) * sa / ra);
|
g = (g + (src.G - g) * sa / ra);
|
||||||
b = (b + (src.B - b) * sa / ra);
|
b = (b + (src.B - b) * sa / ra);
|
||||||
|
a = ra;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest[index] = (uint8)a;
|
dest[index] = (uint8)r;
|
||||||
dest[index + 1] = (uint8)r;
|
dest[index + 1] = (uint8)g;
|
||||||
dest[index + 2] = (uint8)g;
|
dest[index + 2] = (uint8)b;
|
||||||
dest[index + 3] = (uint8)b;
|
dest[index + 3] = (uint8)a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,8 +40,7 @@ namespace Strawberry
|
||||||
static public void Sprite(Sprite sprite, int frame, Point position)
|
static public void Sprite(Sprite sprite, int frame, Point position)
|
||||||
{
|
{
|
||||||
SDL.Rect src = Strawberry.Rect(0, 0, sprite.Width, sprite.Height);
|
SDL.Rect src = Strawberry.Rect(0, 0, sprite.Width, sprite.Height);
|
||||||
SDL.Rect dst = Strawberry.Rect(position.X, position.Y, sprite.Width, sprite.Height);
|
SDL.Rect dst = Strawberry.Rect(position.X - Camera.X, position.Y - Camera.Y, sprite.Width, sprite.Height);
|
||||||
|
|
||||||
SDL.RenderCopy(Game.Renderer, sprite[frame].Texture, &src, &dst);
|
SDL.RenderCopy(Game.Renderer, sprite[frame].Texture, &src, &dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user