Skip to content

Commit

Permalink
TrueColor: fix translucency blending (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
JNechaevsky authored Sep 15, 2024
1 parent 6e5c5b4 commit 3201b93
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,10 @@ static void SetVideoMode(void)
if (argbbuffer == NULL)
{
#ifdef CRISPY_TRUECOLOR
int bpp;

SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB8888, &bpp,
&rmask, &gmask, &bmask, &amask);

This comment has been minimized.

Copy link
@fabiangreffrath

fabiangreffrath Sep 16, 2024

Owner

Strictly speaking, these don't have to be variables anymore. Since we are always allocating ARGB8888 surfaces now, we could just turn them into constant macros.

This comment has been minimized.

Copy link
@JNechaevsky

JNechaevsky Sep 16, 2024

Author Collaborator

Like this?

-static unsigned int rmask, gmask, bmask, amask; // [crispy] moved up here
+static const unsigned int rmask, gmask, bmask, amask; // [crispy] moved up here

But it leads to a bunch of warnings:

R:/MSYS/home/Julia/crispy-doom/src/i_video.c:1637:36: warning: passing argument 3 of 'SDL_PixelFormatEnumToMasks' discards 'const' qualifier from pointer target type [-Wdiscarded-q
ualifiers]
 1637 |                                    &rmask, &gmask, &bmask, &amask);
      |                                    ^~~~~~
In file included from R:/MSYS/mingw64/include/SDL2/SDL_video.h:32,
                 from R:/MSYS/mingw64/include/SDL2/SDL_events.h:33,
                 from R:/MSYS/mingw64/include/SDL2/SDL.h:41,
                 from R:/MSYS/home/Julia/crispy-doom/src/i_video.c:23:
R:/MSYS/mingw64/include/SDL2/SDL_pixels.h:399:70: note: expected 'Uint32 *' {aka 'unsigned int *'} but argument is of type 'const unsigned int *'
  399 |                                                             Uint32 * Rmask,
      |                                                             ~~~~~~~~~^~~~~

Pretty much same on trying to constify bpp.

This comment has been minimized.

Copy link
@fabiangreffrath

fabiangreffrath Sep 16, 2024

Owner

More like this:

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -100,7 +100,6 @@ static SDL_Texture *bluepane = NULL;
 static SDL_Texture *graypane = NULL;
 static SDL_Texture *orngpane = NULL;
 static int pane_alpha;
-static unsigned int rmask, gmask, bmask, amask; // [crispy] moved up here
 extern pixel_t* pal_color; // [crispy] evil hack to get FPS dots working as in Vanilla
 #else
 static SDL_Color palette[256];
@@ -1631,10 +1630,6 @@ static void SetVideoMode(void)
     if (argbbuffer == NULL)
     {
 #ifdef CRISPY_TRUECOLOR
-        int bpp;
-
-        SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB8888, &bpp,
-                                   &rmask, &gmask, &bmask, &amask);
         argbbuffer = SDL_CreateRGBSurfaceWithFormat(
                      0, SCREENWIDTH, SCREENHEIGHT, 32, SDL_PIXELFORMAT_ARGB8888);

@@ -2112,6 +2107,12 @@ void I_BindVideoVariables(void)
 }

 #ifdef CRISPY_TRUECOLOR
+
+#define amask (0xFF000000U)
+#define rmask (0x00FF0000U)
+#define gmask (0x0000FF00U)
+#define bmask (0x000000FFU)
+
 const pixel_t I_BlendAdd (const pixel_t bg, const pixel_t fg)
 {
        uint32_t r, g, b;

This comment has been minimized.

Copy link
@JNechaevsky

JNechaevsky Sep 16, 2024

Author Collaborator

😮 Totally impressive, how is that possible. Will PR shortly, thank you!

argbbuffer = SDL_CreateRGBSurfaceWithFormat(
0, SCREENWIDTH, SCREENHEIGHT, 32, SDL_PIXELFORMAT_ARGB8888);

Expand Down

0 comments on commit 3201b93

Please sign in to comment.