Jump to page: 1 2 3
Thread overview
Help making a game with transparency
Sep 27, 2019
Murilo
Sep 27, 2019
matheus
Sep 27, 2019
Adam D. Ruppe
Sep 27, 2019
Murilo
Sep 28, 2019
GreatSam4sure
Sep 28, 2019
Adam D. Ruppe
Sep 30, 2019
Murilo
Oct 01, 2019
Adam D. Ruppe
Oct 01, 2019
Murilo
Sep 30, 2019
Murilo
Oct 01, 2019
Adam D. Ruppe
Oct 02, 2019
Murilo
Sep 27, 2019
Murilo
Sep 27, 2019
matheus
Sep 27, 2019
Murilo
Sep 27, 2019
matheus
Sep 27, 2019
Adam D. Ruppe
Sep 27, 2019
Murilo
Sep 28, 2019
Mike Parker
Sep 28, 2019
Murilo
Sep 27, 2019
Murilo
Sep 28, 2019
matheus
Sep 28, 2019
Mike Parker
Sep 30, 2019
Murilo
September 27, 2019
Hi guys, I am making a game but for some reason the sprites do not show with the transparent background that they were supposed to. I'm using the arsd library. Can anyone help me?
September 27, 2019
On Friday, 27 September 2019 at 02:54:27 UTC, Murilo wrote:
> Hi guys, I am making a game but for some reason the sprites do not show with the transparent background that they were supposed to. I'm using the arsd library. Can anyone help me?

Sorry this is a bit vague. I suppose you're using engine.d or screen.d directly right?

Depending on your setup (OpenGL or Software) transparency will be different.

For example take a look at line 733, putpixel function and you'll see that It handle Color differently if it's OpenGL x Software and for the latter it checks if 32bpp or less.

Now if it's OpenGL take a look for "Alpha".

Matheus.
September 27, 2019
On Friday, 27 September 2019 at 11:28:35 UTC, matheus wrote:
> Sorry this is a bit vague. I suppose you're using engine.d or screen.d directly right?

those two are obsolete, new stuff should use simpledisplay

but with simpledisplay you need to use opengl for transparency since the xlib/gdi+ impl doesn't support it (though they probably could if someone wanted to write some code)

i just am doing 4 other things at once right now and can't do it myself at the moment
September 27, 2019
> Sorry this is a bit vague. I suppose you're using engine.d or screen.d directly right?
>
> Depending on your setup (OpenGL or Software) transparency will be different.
>
> For example take a look at line 733, putpixel function and you'll see that It handle Color differently if it's OpenGL x Software and for the latter it checks if 32bpp or less.
>
> Now if it's OpenGL take a look for "Alpha".
>
> Matheus.

Thanks for the reply. Do you know the arsd library?
September 27, 2019
On Friday, 27 September 2019 at 11:32:53 UTC, Adam D. Ruppe wrote:
> On Friday, 27 September 2019 at 11:28:35 UTC, matheus wrote:
>> Sorry this is a bit vague. I suppose you're using engine.d or screen.d directly right?
>
> those two are obsolete, new stuff should use simpledisplay
>
> but with simpledisplay you need to use opengl for transparency since the xlib/gdi+ impl doesn't support it (though they probably could if someone wanted to write some code)
>
> i just am doing 4 other things at once right now and can't do it myself at the moment

Alright, thanks, the problem is that I was unable to figure out the opengl functions. Later when you have the time see if you can help me out, then I will add this to your library's tutorial.
September 27, 2019
On Friday, 27 September 2019 at 16:36:14 UTC, Murilo wrote:
> ...Do you know the arsd library?

Yes but I use mostly terminal.d and others.

On the other hand I use to code games too using SDL and OpenGL.

I know for example in OpenGL you can do: glEnable(GL_ALPHA_TEST); to enable alpha channel and set transparency.

Matheus.
September 27, 2019
On Friday, 27 September 2019 at 17:53:33 UTC, matheus wrote:
> On Friday, 27 September 2019 at 16:36:14 UTC, Murilo wrote:
>> ...Do you know the arsd library?
>
> Yes but I use mostly terminal.d and others.
>
> On the other hand I use to code games too using SDL and OpenGL.
>
> I know for example in OpenGL you can do: glEnable(GL_ALPHA_TEST); to enable alpha channel and set transparency.
>
> Matheus.

Thanks, but I don't know how that will fit in my code. I will show up a code snippet and you tell me how I can use your idea in it, okay?

import arsd.image, arsd.simpledisplay;

void main()
{
    auto memImgShip = loadImageFromFile("ship.png"), memImgBackground = loadImageFromFile("background.png");
    auto imgShip = Image.fromMemoryImage(memImgShip), imgBackground = Image.fromMemoryImage(memImgBackground);
    auto window = new SimpleWindow;
    window.eventLoop(10,
    {
        auto painter = window.draw;
        painter.drawImage(Point(0, 0), imgBackground);
        painter.drawImage(Point(100, 100), imgShip);
    });
}

Here it is, how do I make the ship have a transparent background?
September 27, 2019
On Friday, 27 September 2019 at 21:16:07 UTC, Murilo wrote:
> ...
> Here it is, how do I make the ship have a transparent background?

First: Your PNG file has transparency data information right?

Second: I was Looking into the drawImage function (Line 854):

https://github.com/adamdruppe/arsd/blob/b0d21de148ef0b23ea845be322af5e6931ca4cb6/screen.d

And I'd suggest you to try to add the glEnable(GL_ALPHA_TEST); before glBegin(GL_QUADS);

In fact you should do this only once, maybe inside the constructor, but just try it there to see if it works.

Matheus.
September 27, 2019
On Friday, 27 September 2019 at 22:13:43 UTC, matheus wrote:
> https://github.com/adamdruppe/arsd/blob/b0d21de148ef0b23ea845be322af5e6931ca4cb6/screen.d

I really should just remove that file as it is no longer well maintained. I haven't used it for anything in years and doubt anyone else is either.

He's using the simpledisplay.d lib which DOES NOT SUPPORT transparency in its drawImage function. It does NOT use opengl functions and are not compatible with them.

To do opengl stuff with simpledisplay, there is a separate flow. You use opengl functions on a redraw scene delegate instead of using any of the Image or Painter objects. It is quite different and there is no easy fix on that end.

but the gdi+ functions in sdpy MIGHT be able to be ported to alpha blend on Windows easily enough. I just haven't gotten around to it yet.
September 27, 2019
On Friday, 27 September 2019 at 22:13:43 UTC, matheus wrote:
> On Friday, 27 September 2019 at 21:16:07 UTC, Murilo wrote:
>> ...
>> Here it is, how do I make the ship have a transparent background?
>
> First: Your PNG file has transparency data information right?
>
> Second: I was Looking into the drawImage function (Line 854):
>
> https://github.com/adamdruppe/arsd/blob/b0d21de148ef0b23ea845be322af5e6931ca4cb6/screen.d
>
> And I'd suggest you to try to add the glEnable(GL_ALPHA_TEST); before glBegin(GL_QUADS);
>
> In fact you should do this only once, maybe inside the constructor, but just try it there to see if it works.
>
> Matheus.

Thanks for trying to help me but unfortunately you are suggesting I use arsd.screen which is supposed to be obsolete, I am using arsd.simpledisplay instead and it is very different although many functions have the same name.
« First   ‹ Prev
1 2 3