The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
I'm getting blank surfaces... any idea why?
Julian Marchant
Guest

Ever since I started maintaining Project: Starfighter (
http://starfighter.nongnu.org ), I've been scratching my head over this.
I don't know when it happened, because this was some time before I
started maintaining it, but a certain collection of surfaces that are
supposed to be reddened versions of ships are often, but not always,
blank instead. I don't see any consistent pattern in how it happens, or
any code that should fail in this particular way. The bug can be seen in
this video:

https://goblinrefuge.com/mediagoblin/u/onpon4/m/project-starfighter-1-3-gameplay/

All the game's source code can be found in the public Git repository:

https://savannah.nongnu.org/git/?group=starfighter

I've verified that the surfaces are blank (or perhaps NULL, does
SDL_BlitSurface accept NULL for the first argument?), rather than some
other code just failing to draw the surface, by causing the surface
that's supposed to be reddened to always be used; this causes the ship
in question (the player, in my test) to be invisible.

This is the code that is supposed to generate the reddened ships:

http://pastebin.com/f1SiGEbN

This code originally did have some problems which I fixed, though I
don't remember what they were, so I originally supposed that maybe the
method just didn't work with certain colors or certain formats or
something. I didn't find any such pattern, but what really discredited
that hypothesis is that the following code, which used to be what was
used before the previous maintainer of Starfighter changed it to more or
less the current implementation, fails in exactly the same way, even
though it worked fine before:

http://pastebin.com/sVCtp4s5

At this point, my only remaining guess is that this code somehow broke
when Starfighter was upgraded from SDL 1.2 to SDL 2.0 (which, again, was
done before I started maintaining Starfighter). But I don't see a
problem in that regard. Maybe it's just because of my fairly rudimentary
understanding of SDL, though. Is there anything problematic in here?
Anything that might cause the entirety of certain images to be erased,
or perhaps for them to be replaced with NULL (or perhaps
SDL_CreateRGBSurface can return NULL)?

Sorry if the question is a little vague. Sad

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Jonny D


Joined: 12 Sep 2009
Posts: 932
One thing right off is that you should do your pixel access before you unlock the surface (i.e. move the pixel access loop to between lock and unlock).  It's not clear if your surfaces actually do need locking (most don't!), so this likely won't fix your problem.

Jonny D






On Sun, Apr 26, 2015 at 2:33 PM, Julian Marchant wrote:
Quote:
Ever since I started maintaining Project: Starfighter (
http://starfighter.nongnu.org ), I've been scratching my head over this.
I don't know when it happened, because this was some time before I
started maintaining it, but a certain collection of surfaces that are
supposed to be reddened versions of ships are often, but not always,
blank instead. I don't see any consistent pattern in how it happens, or
any code that should fail in this particular way. The bug can be seen in
this video:

https://goblinrefuge.com/mediagoblin/u/onpon4/m/project-starfighter-1-3-gameplay/

All the game's source code can be found in the public Git repository:

https://savannah.nongnu.org/git/?group=starfighter

I've verified that the surfaces are blank (or perhaps NULL, does
SDL_BlitSurface accept NULL for the first argument?), rather than some
other code just failing to draw the surface, by causing the surface
that's supposed to be reddened to always be used; this causes the ship
in question (the player, in my test) to be invisible.

This is the code that is supposed to generate the reddened ships:

http://pastebin.com/f1SiGEbN

This code originally did have some problems which I fixed, though I
don't remember what they were, so I originally supposed that maybe the
method just didn't work with certain colors or certain formats or
something. I didn't find any such pattern, but what really discredited
that hypothesis is that the following code, which used to be what was
used before the previous maintainer of Starfighter changed it to more or
less the current implementation, fails in exactly the same way, even
though it worked fine before:

http://pastebin.com/sVCtp4s5

At this point, my only remaining guess is that this code somehow broke
when Starfighter was upgraded from SDL 1.2 to SDL 2.0 (which, again, was
done before I started maintaining Starfighter). But I don't see a
problem in that regard. Maybe it's just because of my fairly rudimentary
understanding of SDL, though. Is there anything problematic in here?
Anything that might cause the entirety of certain images to be erased,
or perhaps for them to be replaced with NULL (or perhaps
SDL_CreateRGBSurface can return NULL)?

Sorry if the question is a little vague. Sad

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Julian Marchant
Guest

On 04/26/2015 05:49 PM, Jonathan Dearborn wrote:
Quote:
One thing right off is that you should do your pixel access before you
unlock the surface (i.e. move the pixel access loop to between lock and
unlock). It's not clear if your surfaces actually do need locking (most
don't!), so this likely won't fix your problem.

Yep, that didn't make any meaningful difference, but thanks for pointing
this out anyway. Smile

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Driedfruit
Guest

That likely won't help, but FYI

On Sun, 26 Apr 2015 14:33:03 -0400
Julian Marchant wrote:

Quote:
(or perhaps NULL, does SDL_BlitSurface accept NULL for the first
argument?),

Nope, that's not supported. First argument must be an SDL_Surface.

Quote:
(or perhaps SDL_CreateRGBSurface can return NULL)?

That indeed can happen (see SDL_GetError in such case), but probably is
not it, as that would crash later on.

* * *

Considering you're doing pixel-level manipulations, I'd investigate
that in more detail.

You're saying it's not happening every time, so it could be something
nasty and un-related, RE:C memory access.

--
driedfruit
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Julian Marchant
Guest

On 04/28/2015 08:50 AM, Driedfruit wrote:
Quote:
Considering you're doing pixel-level manipulations, I'd investigate
that in more detail.

You're saying it's not happening every time, so it could be something
nasty and un-related, RE:C memory access.

Yep. But as I already said, confusingly, the old method, which instead
just blits a rectangle onto the whole image, still fails, and on exactly
the same images:

http://pastebin.com/iXWwKHgD

And even more confusing, I've actually confirmed that the player's ship,
one of the ships that have this problem, is definitely using the right
image, and this loop is definitely running properly for it. (I printed
all the indexes that went entirely through the loop, then printed the
index used when the player's ship was supposed to be reddened; the
player reddened ships were indexes 60 and 61, and these were both in the
printed list of indexes.)

Hm... I've found another version that fails exactly the same way:

for (int i = SHIP_HIT_INDEX ; i < MAX_SHIPSHAPES ; i++)
{
if (shipShape[i - SHIP_HIT_INDEX] == NULL)
continue;
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w,
shipShape[i - SHIP_HIT_INDEX]->h);
blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
}

However! This works just fine (once I modify code elsewhere to not free
the images twice):

for (int i = SHIP_HIT_INDEX ; i < MAX_SHIPSHAPES ; i++)
{
shipShape[i] = shipShape[i - SHIP_HIT_INDEX];
}

I further decided to make sure it wasn't the graphics freeing that was
causing it, by not freeing the copies in the previous version (which of
course is causing a memory leak on my system, but got to rule this out).
And it failed exactly the same way. So it's got something to do with
Starfighter's createSurface function, or its blit function. No wonder I
was so confused!

Anyway, thanks to everyone who gave input. I haven't solved this yet,
but I have an idea of where to look now. Smile

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Julian Marchant
Guest

Does anyone see anything wrong with this function?

http://pastebin.com/qBNwfiuu

Looking at createSurface, it seems to just be a copy-paste of the
example from the documentation, so I doubt that's the problem. That
makes blit the only remaining candidate that makes sense.

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Julian Marchant
Guest

OK, here's something else. I made the thing print all the pixel data of
the first four "reddened" images before they were reddened. 60-61 are
ones I know don't work (they're the player's ship), and 62-63 are ones I
know do work (they're the "dual fighter" enemy). This is what I got:

60 (32-bit):
0 0 0 0 1 266271 202028 1062241 5136747 5794415 5465191 4609140 4477557
921963 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65793 2832702 4216414 1785953
5205373 6323592 3425098 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65793 263172 0
856853 5533818 6060418 5666191 3233143 6916501 6324108 1185820 1 0 0 0 0
0 0 0 0 0 0 0 0 0 1052943 3948345 2105374 5137000 5994111 5335926
3427938 599887 3231333 3560040 2044740 791840 987667 1316115 131585 0 0
0 0 0 0 0 0 0 0 1250322 6777183 8817533 8621440 7175289 7570050 5927296
5140103 3362924 2902116 3821153 5728882 6649721 7899012 3819079 1844006
1383197 790288 131587 0 0 0 0 0 1513751 3882037 6381908 9868645 7895380
3885397 8227474 10858922 9941688 8166567 10469836 9941947 8163993
7241862 5856094 7174010 6713205 7439500 6585219 5794929 4675677 3555652
2239280 330258 516 4738119 10922397 15329738 15921309 9080433 7493
2376038 7305588 8094846 5004898 6784400 8759992 4936279 3155750 4076595
2893349 2893608 5526614 7176845 7049385 6983850 5996183 4153211 993869
268855 2632231 5067079 12172165 12369503 4806214 136746 1386554 5267034
4608848 2766648 3493461 4679279 2304556 1908768 1908253 1775382 1841433
2170655 2701119 1717576 1387840 1387841 1189948 465457 201772 460807
1513489 5592641 7697981 4804658 2831670 3489341 4147781 2438969 2241590
2703169 2768705 2043183 2372919 2372662 1779497 1515811 1318689 1450533
1252381 988438 725008 395530 1 0 0 1579286 5790801 4409146 2961959
2501932 2436912 1319986 728625 728882 663089 1122347 2438201 3490370
4739919 1514523 329737 197893 131587 0 0 0 0 0 0 0 658185 1776922 789772
1516069 2636094 3031109 1651010 70440 728623 860209 595749 463132 724495
987407 197378 0 0 0 0 0 0 0 0 0 0 0 0 0 395530 3361103 3690325 1716289
1255739 3229261 2571073 461582 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1713447 3229776 599364 4941168 5007214 3030594 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 266270 267561 335422 5531504 5465708 5070690 4214387 4412021
1119592 0 0 0 0 0 0 0 0 0 0 0
61 (32-bit):
0 0 0 0 0 0 0 0 0 0 0 921963 4477557 4609140 5465191 5794415 5136747
1062241 202028 266271 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3425098
6323592 5205373 1785953 4216414 2832702 65793 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1185820 6324108 6916501 3233143 5666191 6060418 5533818 856853 0
263172 65793 0 0 0 0 0 0 0 0 0 0 131585 1316115 987667 791840 2044740
3560040 3231333 599887 3427938 5335926 5994111 5137000 2105374 3948345
1052943 0 0 0 0 0 0 131587 790288 1383197 1844006 3819079 7899012
6649721 5728882 3821153 2902116 3362924 5140103 5927296 7570050 7175289
8621440 8817533 6777183 1250322 0 516 330258 2239280 3555652 4675677
5794929 6585219 7439500 6713205 7174010 5856094 7241862 8163993 9941947
10469836 8166567 9941688 10858922 8227474 3885397 7895380 9868645
6381908 3882037 1513751 268855 993869 4153211 5996183 6983850 7049385
7176845 5526614 2893608 2893349 4076595 3155750 4936279 8759992 6784400
5004898 8094846 7305588 2376038 7493 9080433 15921309 15329738 10922397
4738119 201772 465457 1189948 1387841 1387840 1717576 2701119 2170655
1841433 1775382 1908253 1908768 2304556 4679279 3493461 2766648 4608848
5267034 1386554 136746 4806214 12369503 12172165 5067079 2632231 0 1
395530 725008 988438 1252381 1450533 1318689 1515811 1779497 2372662
2372919 2043183 2768705 2703169 2241590 2438969 4147781 3489341 2831670
4804658 7697981 5592641 1513489 460807 0 0 0 0 0 0 131587 197893 329737
1514523 4739919 3490370 2438201 1122347 663089 728882 728625 1319986
2436912 2501932 2961959 4409146 5790801 1579286 0 0 0 0 0 0 0 0 0 0
197378 987407 724495 463132 595749 860209 728623 70440 1651010 3031109
2636094 1516069 789772 1776922 658185 0 0 0 0 0 0 0 0 0 0 0 0 0 1 461582
2571073 3229261 1255739 1716289 3690325 3361103 395530 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 3030594 5007214 4941168 599364 3229776 1713447 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1119592 4412021 4214387 5070690 5465708 5531504
335422 267561 266270 0 0 0 0 0
62 (32-bit):
0 0 0 0 4285618222 4289237609 4286670652 4285618222 4285618222
4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4287197252
4285618222 4285157672 4285157672 4285618222 4281015046 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 4283053075 4282526991 4284631330 4284631330
4285157672 4286144565 4279963650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4286151545 4282401088 4281413937 4281413937 4280887593 4280295456
4279769112 4279242768 4279242768 4279242768 0 0 0 0 0 0 0 0 0 0 0 0
4279769112 4282993225 4282993225 4284572257 4284045913 4286151545
4283519569 4283519569 4283519569 4283519569 4283519569 4283519569
4283519569 4282993225 4282401088 4281413937 4279769112 4279769112 0 0 0
0 0 0 0 4279769112 4282993225 4287269769 4287269769 4288322713
4287861906 4289901745 4285033064 4285033064 4284572257 4284572257
4284572257 4284572257 4284572257 4286151545 4287269769 4285033064
4282401088 4282401088 4281413937 4279769112 0 0 0 0 0 4280887593
4284045913 4294770682 4294770682 4291481033 4291020226 4291481033
4279769112 4279769112 4282526991 4282526991 4283053075 4284104988
4284104988 4284631330 4284631330 4284631330 4285157672 4285157672
4285157672 4284631330 4283053075 4281015046 4281015046 0 0 4281413937
4282993225 4288849057 4288849057 4286151545 4285033064 4287269769
4288250198 4288250198 4289237609 4289237609 4289237609 4289763954
4289763954 4291805088 4293385929 4292859067 4290290557 4290290557
4287723853 4287197252 4286144565 4284631330 4284631330 4283053075
4281015046 4281413937 4280887593 4283519569 4283519569 4284045913
4283519569 4286151545 4280887593 4280887593 4282526991 4282526991
4283053075 4284104988 4284104988 4284631330 4284631330 4285157672
4285618222 4285618222 4285157672 4284631330 4283053075 4281015046
4281015046 0 0 4280295456 4284572257 4281874744 4281874744 4281874744
4282401088 4285625201 4284045913 4284045913 4284572257 4284572257
4284572257 4284572257 4284572257 4285625201 4287861906 4285033064
4282401088 4282401088 4281413937 4279769112 0 0 0 0 0 0 4281413937
4286151545 4286151545 4284572257 4280887593 4282401088 4281413937
4281413937 4282401088 4282401088 4282401088 4282401088 4282401088
4282401088 4282401088 4281413937 4279769112 4279769112 0 0 0 0 0 0 0 0 0
0 0 0 4285033064 4282401088 4280887593 4280887593 4280295456 4280295456
4279242768 4278716424 4278716424 4278716424 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 4284104988 4282526991 4282526991 4282526991 4284104988 4284631330
4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4278978304 4288250198
4285157672 4285157672 4285157672 4284104988 4281015046 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 4281540872 4286144565 4286144565 4283053075
4283053075 4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
63 (32-bit):
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046 4285618222 4285618222
4286670652 4289237609 4285618222 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4281015046 4285618222 4285157672 4285157672 4285618222 4287197252 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4279963650 4286144565 4285157672
4284631330 4284631330 4282526991 4283053075 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 4279242768 4279242768 4279242768 4279769112 4280295456 4280887593
4281413937 4281413937 4282401088 4286151545 0 0 0 0 0 0 0 0 0 0 0 0
4279769112 4279769112 4281413937 4282401088 4282993225 4283519569
4283519569 4283519569 4283519569 4283519569 4283519569 4283519569
4286151545 4284045913 4284572257 4282993225 4282993225 4279769112 0 0 0
0 0 0 4279769112 4281413937 4282401088 4282401088 4285033064 4287269769
4286151545 4284572257 4284572257 4284572257 4284572257 4284572257
4285033064 4285033064 4289901745 4287861906 4288322713 4287269769
4287269769 4282993225 4279769112 0 0 4281015046 4281015046 4283053075
4284631330 4285157672 4285157672 4285157672 4284631330 4284631330
4284631330 4284104988 4284104988 4283053075 4282526991 4282526991
4279769112 4279769112 4291481033 4291020226 4291481033 4294770682
4294770682 4284045913 4280887593 4281015046 4283053075 4284631330
4284631330 4286144565 4287197252 4287723853 4290290557 4290290557
4292859067 4293385929 4291805088 4289763954 4289763954 4289237609
4289237609 4289237609 4288250198 4288250198 4287269769 4285033064
4286151545 4288849057 4288849057 4282993225 4281413937 0 0 4281015046
4281015046 4283053075 4284631330 4285157672 4285618222 4285618222
4285157672 4284631330 4284631330 4284104988 4284104988 4283053075
4282526991 4282526991 4280887593 4280887593 4286151545 4283519569
4284045913 4283519569 4283519569 4280887593 4281413937 0 0 0 0 0
4279769112 4281413937 4282401088 4282401088 4285033064 4287861906
4285625201 4284572257 4284572257 4284572257 4284572257 4284572257
4284045913 4284045913 4285625201 4282401088 4281874744 4281874744
4281874744 4284572257 4280295456 0 0 0 0 0 0 0 4279769112 4279769112
4281413937 4282401088 4282401088 4282401088 4282401088 4282401088
4282401088 4282401088 4281413937 4281413937 4282401088 4280887593
4284572257 4286151545 4286151545 4281413937 0 0 0 0 0 0 0 0 0 0 0 0
4278716424 4278716424 4278716424 4279242768 4280295456 4280295456
4280887593 4280887593 4282401088 4285033064 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 4281015046 4284631330 4284104988 4282526991 4282526991
4282526991 4284104988 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046
4284104988 4285157672 4285157672 4285157672 4288250198 4278978304 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046 4283053075 4283053075
4286144565 4286144565 4281540872 0 0 0 0

One thing I couldn't help but notice was that the dual fighter's
non-zero pixels are all much higher than the player's pixel values. In
fact, I initially accidentally used %d instead of %u, and couldn't help
that this caused the dual fighter's pixels to all be printed as negative
numbers. But the player's pixel values still aren't zero.

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Jonny D


Joined: 12 Sep 2009
Posts: 932
The most likely reason for the dual fighter's pixel values being higher is because the alpha channel is being stored in the high byte (i.e. pixels are packed as ARGB or ABGR).  The player ship has 0 for that byte, making it fully transparent everywhere.  That's my guess as to your problem.  To make it more clear, I think a better format for printing these values is something like:printf("%08X", value);


You can see the separate bytes in that format.


I'm not certain how you'd fix it or what the immediate cause is yet.



Jonny D






On Wed, Apr 29, 2015 at 1:00 PM, Julian Marchant wrote:
Quote:
OK, here's something else. I made the thing print all the pixel data of
the first four "reddened" images before they were reddened. 60-61 are
ones I know don't work (they're the player's ship), and 62-63 are ones I
know do work (they're the "dual fighter" enemy). This is what I got:

60 (32-bit):
0 0 0 0 1 266271 202028 1062241 5136747 5794415 5465191 4609140 4477557
921963 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65793 2832702 4216414 1785953
5205373 6323592 3425098 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65793 263172 0
856853 5533818 6060418 5666191 3233143 6916501 6324108 1185820 1 0 0 0 0
0 0 0 0 0 0 0 0 0 1052943 3948345 2105374 5137000 5994111 5335926
3427938 599887 3231333 3560040 2044740 791840 987667 1316115 131585 0 0
0 0 0 0 0 0 0 0 1250322 6777183 8817533 8621440 7175289 7570050 5927296
5140103 3362924 2902116 3821153 5728882 6649721 7899012 3819079 1844006
1383197 790288 131587 0 0 0 0 0 1513751 3882037 6381908 9868645 7895380
3885397 8227474 10858922 9941688 8166567 10469836 9941947 8163993
7241862 5856094 7174010 6713205 7439500 6585219 5794929 4675677 3555652
2239280 330258 516 4738119 10922397 15329738 15921309 9080433 7493
2376038 7305588 8094846 5004898 6784400 8759992 4936279 3155750 4076595
2893349 2893608 5526614 7176845 7049385 6983850 5996183 4153211 993869
268855 2632231 5067079 12172165 12369503 4806214 136746 1386554 5267034
4608848 2766648 3493461 4679279 2304556 1908768 1908253 1775382 1841433
2170655 2701119 1717576 1387840 1387841 1189948 465457 201772 460807
1513489 5592641 7697981 4804658 2831670 3489341 4147781 2438969 2241590
2703169 2768705 2043183 2372919 2372662 1779497 1515811 1318689 1450533
1252381 988438 725008 395530 1 0 0 1579286 5790801 4409146 2961959
2501932 2436912 1319986 728625 728882 663089 1122347 2438201 3490370
4739919 1514523 329737 197893 131587 0 0 0 0 0 0 0 658185 1776922 789772
1516069 2636094 3031109 1651010 70440 728623 860209 595749 463132 724495
987407 197378 0 0 0 0 0 0 0 0 0 0 0 0 0 395530 3361103 3690325 1716289
1255739 3229261 2571073 461582 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1713447 3229776 599364 4941168 5007214 3030594 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 266270 267561 335422 5531504 5465708 5070690 4214387 4412021
1119592 0 0 0 0 0 0 0 0 0 0 0
61 (32-bit):
0 0 0 0 0 0 0 0 0 0 0 921963 4477557 4609140 5465191 5794415 5136747
1062241 202028 266271 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3425098
6323592 5205373 1785953 4216414 2832702 65793 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1185820 6324108 6916501 3233143 5666191 6060418 5533818 856853 0
263172 65793 0 0 0 0 0 0 0 0 0 0 131585 1316115 987667 791840 2044740
3560040 3231333 599887 3427938 5335926 5994111 5137000 2105374 3948345
1052943 0 0 0 0 0 0 131587 790288 1383197 1844006 3819079 7899012
6649721 5728882 3821153 2902116 3362924 5140103 5927296 7570050 7175289
8621440 8817533 6777183 1250322 0 516 330258 2239280 3555652 4675677
5794929 6585219 7439500 6713205 7174010 5856094 7241862 8163993 9941947
10469836 8166567 9941688 10858922 8227474 3885397 7895380 9868645
6381908 3882037 1513751 268855 993869 4153211 5996183 6983850 7049385
7176845 5526614 2893608 2893349 4076595 3155750 4936279 8759992 6784400
5004898 8094846 7305588 2376038 7493 9080433 15921309 15329738 10922397
4738119 201772 465457 1189948 1387841 1387840 1717576 2701119 2170655
1841433 1775382 1908253 1908768 2304556 4679279 3493461 2766648 4608848
5267034 1386554 136746 4806214 12369503 12172165 5067079 2632231 0 1
395530 725008 988438 1252381 1450533 1318689 1515811 1779497 2372662
2372919 2043183 2768705 2703169 2241590 2438969 4147781 3489341 2831670
4804658 7697981 5592641 1513489 460807 0 0 0 0 0 0 131587 197893 329737
1514523 4739919 3490370 2438201 1122347 663089 728882 728625 1319986
2436912 2501932 2961959 4409146 5790801 1579286 0 0 0 0 0 0 0 0 0 0
197378 987407 724495 463132 595749 860209 728623 70440 1651010 3031109
2636094 1516069 789772 1776922 658185 0 0 0 0 0 0 0 0 0 0 0 0 0 1 461582
2571073 3229261 1255739 1716289 3690325 3361103 395530 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 3030594 5007214 4941168 599364 3229776 1713447 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1119592 4412021 4214387 5070690 5465708 5531504
335422 267561 266270 0 0 0 0 0
62 (32-bit):
0 0 0 0 4285618222 4289237609 4286670652 4285618222 4285618222
4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4287197252
4285618222 4285157672 4285157672 4285618222 4281015046 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 4283053075 4282526991 4284631330 4284631330
4285157672 4286144565 4279963650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4286151545 4282401088 4281413937 4281413937 4280887593 4280295456
4279769112 4279242768 4279242768 4279242768 0 0 0 0 0 0 0 0 0 0 0 0
4279769112 4282993225 4282993225 4284572257 4284045913 4286151545
4283519569 4283519569 4283519569 4283519569 4283519569 4283519569
4283519569 4282993225 4282401088 4281413937 4279769112 4279769112 0 0 0
0 0 0 0 4279769112 4282993225 4287269769 4287269769 4288322713
4287861906 4289901745 4285033064 4285033064 4284572257 4284572257
4284572257 4284572257 4284572257 4286151545 4287269769 4285033064
4282401088 4282401088 4281413937 4279769112 0 0 0 0 0 4280887593
4284045913 4294770682 4294770682 4291481033 4291020226 4291481033
4279769112 4279769112 4282526991 4282526991 4283053075 4284104988
4284104988 4284631330 4284631330 4284631330 4285157672 4285157672
4285157672 4284631330 4283053075 4281015046 4281015046 0 0 4281413937
4282993225 4288849057 4288849057 4286151545 4285033064 4287269769
4288250198 4288250198 4289237609 4289237609 4289237609 4289763954
4289763954 4291805088 4293385929 4292859067 4290290557 4290290557
4287723853 4287197252 4286144565 4284631330 4284631330 4283053075
4281015046 4281413937 4280887593 4283519569 4283519569 4284045913
4283519569 4286151545 4280887593 4280887593 4282526991 4282526991
4283053075 4284104988 4284104988 4284631330 4284631330 4285157672
4285618222 4285618222 4285157672 4284631330 4283053075 4281015046
4281015046 0 0 4280295456 4284572257 4281874744 4281874744 4281874744
4282401088 4285625201 4284045913 4284045913 4284572257 4284572257
4284572257 4284572257 4284572257 4285625201 4287861906 4285033064
4282401088 4282401088 4281413937 4279769112 0 0 0 0 0 0 4281413937
4286151545 4286151545 4284572257 4280887593 4282401088 4281413937
4281413937 4282401088 4282401088 4282401088 4282401088 4282401088
4282401088 4282401088 4281413937 4279769112 4279769112 0 0 0 0 0 0 0 0 0
0 0 0 4285033064 4282401088 4280887593 4280887593 4280295456 4280295456
4279242768 4278716424 4278716424 4278716424 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 4284104988 4282526991 4282526991 4282526991 4284104988 4284631330
4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4278978304 4288250198
4285157672 4285157672 4285157672 4284104988 4281015046 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 4281540872 4286144565 4286144565 4283053075
4283053075 4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
63 (32-bit):
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046 4285618222 4285618222
4286670652 4289237609 4285618222 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4281015046 4285618222 4285157672 4285157672 4285618222 4287197252 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4279963650 4286144565 4285157672
4284631330 4284631330 4282526991 4283053075 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 4279242768 4279242768 4279242768 4279769112 4280295456 4280887593
4281413937 4281413937 4282401088 4286151545 0 0 0 0 0 0 0 0 0 0 0 0
4279769112 4279769112 4281413937 4282401088 4282993225 4283519569
4283519569 4283519569 4283519569 4283519569 4283519569 4283519569
4286151545 4284045913 4284572257 4282993225 4282993225 4279769112 0 0 0
0 0 0 4279769112 4281413937 4282401088 4282401088 4285033064 4287269769
4286151545 4284572257 4284572257 4284572257 4284572257 4284572257
4285033064 4285033064 4289901745 4287861906 4288322713 4287269769
4287269769 4282993225 4279769112 0 0 4281015046 4281015046 4283053075
4284631330 4285157672 4285157672 4285157672 4284631330 4284631330
4284631330 4284104988 4284104988 4283053075 4282526991 4282526991
4279769112 4279769112 4291481033 4291020226 4291481033 4294770682
4294770682 4284045913 4280887593 4281015046 4283053075 4284631330
4284631330 4286144565 4287197252 4287723853 4290290557 4290290557
4292859067 4293385929 4291805088 4289763954 4289763954 4289237609
4289237609 4289237609 4288250198 4288250198 4287269769 4285033064
4286151545 4288849057 4288849057 4282993225 4281413937 0 0 4281015046
4281015046 4283053075 4284631330 4285157672 4285618222 4285618222
4285157672 4284631330 4284631330 4284104988 4284104988 4283053075
4282526991 4282526991 4280887593 4280887593 4286151545 4283519569
4284045913 4283519569 4283519569 4280887593 4281413937 0 0 0 0 0
4279769112 4281413937 4282401088 4282401088 4285033064 4287861906
4285625201 4284572257 4284572257 4284572257 4284572257 4284572257
4284045913 4284045913 4285625201 4282401088 4281874744 4281874744
4281874744 4284572257 4280295456 0 0 0 0 0 0 0 4279769112 4279769112
4281413937 4282401088 4282401088 4282401088 4282401088 4282401088
4282401088 4282401088 4281413937 4281413937 4282401088 4280887593
4284572257 4286151545 4286151545 4281413937 0 0 0 0 0 0 0 0 0 0 0 0
4278716424 4278716424 4278716424 4279242768 4280295456 4280295456
4280887593 4280887593 4282401088 4285033064 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 4281015046 4284631330 4284104988 4282526991 4282526991
4282526991 4284104988 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046
4284104988 4285157672 4285157672 4285157672 4288250198 4278978304 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046 4283053075 4283053075
4286144565 4286144565 4281540872 0 0 0 0

One thing I couldn't help but notice was that the dual fighter's
non-zero pixels are all much higher than the player's pixel values. In
fact, I initially accidentally used %d instead of %u, and couldn't help
that this caused the dual fighter's pixels to all be printed as negative
numbers. But the player's pixel values still aren't zero.

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Sascha Schwarz


Joined: 28 Apr 2015
Posts: 5
Location: Germany
I can't quite wrap my head around it, but I had some success with
a) removing the SDL_SetColorKey() calls in the code to mark black as transparent and
b) replacing some of the png-graphics with altered versions*).

Somehow colorkeying/alphablending and the pngs don't seem to play nice together.

*) e.g. removing the alpha channel and setting black as transparent in firefly1.png
Code:
pngcrush -d gfx_crushed -c 2 -trns 0 0 0 0 0  gfx/firefly1.png
I'm getting blank surfaces... any idea why?
Jonny D


Joined: 12 Sep 2009
Posts: 932
Oh, it's possible that this is the classic SDL_BlitSurface() blend semantic that trips up people from time to time.  In SDL1.2, SDL_BlitSurface() does color blending, but then uses the *destination* alpha value for the resulting alpha.  This means that when you blend a surface into your new, transparent black surface, you end up with a fully transparent result (though the colors are still there).  In SDL 2, I'm not sure if this semantic was preserved, but the alpha value might still not be what you expect when you want to actually copy the image.

I'm still not totally sure why there's a discrepancy between different ship images, though...


To see if this is the problem, use this kind of thing:
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w,
                        shipShape[i - SHIP_HIT_INDEX]->h);
SDL_SetSurfaceBlendMode(shipShape[i], SDL_BLENDMODE_NONE);

blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
SDL_SetSurfaceBlendMode(shipShape[i], SDL_BLENDMODE_BLEND);

Jonny D






On Wed, Apr 29, 2015 at 4:38 PM, Jonathan Dearborn wrote:
Quote:
The most likely reason for the dual fighter's pixel values being higher is because the alpha channel is being stored in the high byte (i.e. pixels are packed as ARGB or ABGR).  The player ship has 0 for that byte, making it fully transparent everywhere.  That's my guess as to your problem.  To make it more clear, I think a better format for printing these values is something like:printf("%08X", value);


You can see the separate bytes in that format.


I'm not certain how you'd fix it or what the immediate cause is yet.



Jonny D






On Wed, Apr 29, 2015 at 1:00 PM, Julian Marchant wrote:
Quote:
OK, here's something else. I made the thing print all the pixel data of
the first four "reddened" images before they were reddened. 60-61 are
ones I know don't work (they're the player's ship), and 62-63 are ones I
know do work (they're the "dual fighter" enemy). This is what I got:

60 (32-bit):
0 0 0 0 1 266271 202028 1062241 5136747 5794415 5465191 4609140 4477557
921963 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65793 2832702 4216414 1785953
5205373 6323592 3425098 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65793 263172 0
856853 5533818 6060418 5666191 3233143 6916501 6324108 1185820 1 0 0 0 0
0 0 0 0 0 0 0 0 0 1052943 3948345 2105374 5137000 5994111 5335926
3427938 599887 3231333 3560040 2044740 791840 987667 1316115 131585 0 0
0 0 0 0 0 0 0 0 1250322 6777183 8817533 8621440 7175289 7570050 5927296
5140103 3362924 2902116 3821153 5728882 6649721 7899012 3819079 1844006
1383197 790288 131587 0 0 0 0 0 1513751 3882037 6381908 9868645 7895380
3885397 8227474 10858922 9941688 8166567 10469836 9941947 8163993
7241862 5856094 7174010 6713205 7439500 6585219 5794929 4675677 3555652
2239280 330258 516 4738119 10922397 15329738 15921309 9080433 7493
2376038 7305588 8094846 5004898 6784400 8759992 4936279 3155750 4076595
2893349 2893608 5526614 7176845 7049385 6983850 5996183 4153211 993869
268855 2632231 5067079 12172165 12369503 4806214 136746 1386554 5267034
4608848 2766648 3493461 4679279 2304556 1908768 1908253 1775382 1841433
2170655 2701119 1717576 1387840 1387841 1189948 465457 201772 460807
1513489 5592641 7697981 4804658 2831670 3489341 4147781 2438969 2241590
2703169 2768705 2043183 2372919 2372662 1779497 1515811 1318689 1450533
1252381 988438 725008 395530 1 0 0 1579286 5790801 4409146 2961959
2501932 2436912 1319986 728625 728882 663089 1122347 2438201 3490370
4739919 1514523 329737 197893 131587 0 0 0 0 0 0 0 658185 1776922 789772
1516069 2636094 3031109 1651010 70440 728623 860209 595749 463132 724495
987407 197378 0 0 0 0 0 0 0 0 0 0 0 0 0 395530 3361103 3690325 1716289
1255739 3229261 2571073 461582 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1713447 3229776 599364 4941168 5007214 3030594 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 266270 267561 335422 5531504 5465708 5070690 4214387 4412021
1119592 0 0 0 0 0 0 0 0 0 0 0
61 (32-bit):
0 0 0 0 0 0 0 0 0 0 0 921963 4477557 4609140 5465191 5794415 5136747
1062241 202028 266271 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3425098
6323592 5205373 1785953 4216414 2832702 65793 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1185820 6324108 6916501 3233143 5666191 6060418 5533818 856853 0
263172 65793 0 0 0 0 0 0 0 0 0 0 131585 1316115 987667 791840 2044740
3560040 3231333 599887 3427938 5335926 5994111 5137000 2105374 3948345
1052943 0 0 0 0 0 0 131587 790288 1383197 1844006 3819079 7899012
6649721 5728882 3821153 2902116 3362924 5140103 5927296 7570050 7175289
8621440 8817533 6777183 1250322 0 516 330258 2239280 3555652 4675677
5794929 6585219 7439500 6713205 7174010 5856094 7241862 8163993 9941947
10469836 8166567 9941688 10858922 8227474 3885397 7895380 9868645
6381908 3882037 1513751 268855 993869 4153211 5996183 6983850 7049385
7176845 5526614 2893608 2893349 4076595 3155750 4936279 8759992 6784400
5004898 8094846 7305588 2376038 7493 9080433 15921309 15329738 10922397
4738119 201772 465457 1189948 1387841 1387840 1717576 2701119 2170655
1841433 1775382 1908253 1908768 2304556 4679279 3493461 2766648 4608848
5267034 1386554 136746 4806214 12369503 12172165 5067079 2632231 0 1
395530 725008 988438 1252381 1450533 1318689 1515811 1779497 2372662
2372919 2043183 2768705 2703169 2241590 2438969 4147781 3489341 2831670
4804658 7697981 5592641 1513489 460807 0 0 0 0 0 0 131587 197893 329737
1514523 4739919 3490370 2438201 1122347 663089 728882 728625 1319986
2436912 2501932 2961959 4409146 5790801 1579286 0 0 0 0 0 0 0 0 0 0
197378 987407 724495 463132 595749 860209 728623 70440 1651010 3031109
2636094 1516069 789772 1776922 658185 0 0 0 0 0 0 0 0 0 0 0 0 0 1 461582
2571073 3229261 1255739 1716289 3690325 3361103 395530 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 3030594 5007214 4941168 599364 3229776 1713447 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1119592 4412021 4214387 5070690 5465708 5531504
335422 267561 266270 0 0 0 0 0
62 (32-bit):
0 0 0 0 4285618222 4289237609 4286670652 4285618222 4285618222
4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4287197252
4285618222 4285157672 4285157672 4285618222 4281015046 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 4283053075 4282526991 4284631330 4284631330
4285157672 4286144565 4279963650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4286151545 4282401088 4281413937 4281413937 4280887593 4280295456
4279769112 4279242768 4279242768 4279242768 0 0 0 0 0 0 0 0 0 0 0 0
4279769112 4282993225 4282993225 4284572257 4284045913 4286151545
4283519569 4283519569 4283519569 4283519569 4283519569 4283519569
4283519569 4282993225 4282401088 4281413937 4279769112 4279769112 0 0 0
0 0 0 0 4279769112 4282993225 4287269769 4287269769 4288322713
4287861906 4289901745 4285033064 4285033064 4284572257 4284572257
4284572257 4284572257 4284572257 4286151545 4287269769 4285033064
4282401088 4282401088 4281413937 4279769112 0 0 0 0 0 4280887593
4284045913 4294770682 4294770682 4291481033 4291020226 4291481033
4279769112 4279769112 4282526991 4282526991 4283053075 4284104988
4284104988 4284631330 4284631330 4284631330 4285157672 4285157672
4285157672 4284631330 4283053075 4281015046 4281015046 0 0 4281413937
4282993225 4288849057 4288849057 4286151545 4285033064 4287269769
4288250198 4288250198 4289237609 4289237609 4289237609 4289763954
4289763954 4291805088 4293385929 4292859067 4290290557 4290290557
4287723853 4287197252 4286144565 4284631330 4284631330 4283053075
4281015046 4281413937 4280887593 4283519569 4283519569 4284045913
4283519569 4286151545 4280887593 4280887593 4282526991 4282526991
4283053075 4284104988 4284104988 4284631330 4284631330 4285157672
4285618222 4285618222 4285157672 4284631330 4283053075 4281015046
4281015046 0 0 4280295456 4284572257 4281874744 4281874744 4281874744
4282401088 4285625201 4284045913 4284045913 4284572257 4284572257
4284572257 4284572257 4284572257 4285625201 4287861906 4285033064
4282401088 4282401088 4281413937 4279769112 0 0 0 0 0 0 4281413937
4286151545 4286151545 4284572257 4280887593 4282401088 4281413937
4281413937 4282401088 4282401088 4282401088 4282401088 4282401088
4282401088 4282401088 4281413937 4279769112 4279769112 0 0 0 0 0 0 0 0 0
0 0 0 4285033064 4282401088 4280887593 4280887593 4280295456 4280295456
4279242768 4278716424 4278716424 4278716424 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 4284104988 4282526991 4282526991 4282526991 4284104988 4284631330
4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4278978304 4288250198
4285157672 4285157672 4285157672 4284104988 4281015046 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 4281540872 4286144565 4286144565 4283053075
4283053075 4281015046 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
63 (32-bit):
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046 4285618222 4285618222
4286670652 4289237609 4285618222 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4281015046 4285618222 4285157672 4285157672 4285618222 4287197252 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4279963650 4286144565 4285157672
4284631330 4284631330 4282526991 4283053075 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 4279242768 4279242768 4279242768 4279769112 4280295456 4280887593
4281413937 4281413937 4282401088 4286151545 0 0 0 0 0 0 0 0 0 0 0 0
4279769112 4279769112 4281413937 4282401088 4282993225 4283519569
4283519569 4283519569 4283519569 4283519569 4283519569 4283519569
4286151545 4284045913 4284572257 4282993225 4282993225 4279769112 0 0 0
0 0 0 4279769112 4281413937 4282401088 4282401088 4285033064 4287269769
4286151545 4284572257 4284572257 4284572257 4284572257 4284572257
4285033064 4285033064 4289901745 4287861906 4288322713 4287269769
4287269769 4282993225 4279769112 0 0 4281015046 4281015046 4283053075
4284631330 4285157672 4285157672 4285157672 4284631330 4284631330
4284631330 4284104988 4284104988 4283053075 4282526991 4282526991
4279769112 4279769112 4291481033 4291020226 4291481033 4294770682
4294770682 4284045913 4280887593 4281015046 4283053075 4284631330
4284631330 4286144565 4287197252 4287723853 4290290557 4290290557
4292859067 4293385929 4291805088 4289763954 4289763954 4289237609
4289237609 4289237609 4288250198 4288250198 4287269769 4285033064
4286151545 4288849057 4288849057 4282993225 4281413937 0 0 4281015046
4281015046 4283053075 4284631330 4285157672 4285618222 4285618222
4285157672 4284631330 4284631330 4284104988 4284104988 4283053075
4282526991 4282526991 4280887593 4280887593 4286151545 4283519569
4284045913 4283519569 4283519569 4280887593 4281413937 0 0 0 0 0
4279769112 4281413937 4282401088 4282401088 4285033064 4287861906
4285625201 4284572257 4284572257 4284572257 4284572257 4284572257
4284045913 4284045913 4285625201 4282401088 4281874744 4281874744
4281874744 4284572257 4280295456 0 0 0 0 0 0 0 4279769112 4279769112
4281413937 4282401088 4282401088 4282401088 4282401088 4282401088
4282401088 4282401088 4281413937 4281413937 4282401088 4280887593
4284572257 4286151545 4286151545 4281413937 0 0 0 0 0 0 0 0 0 0 0 0
4278716424 4278716424 4278716424 4279242768 4280295456 4280295456
4280887593 4280887593 4282401088 4285033064 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 4281015046 4284631330 4284104988 4282526991 4282526991
4282526991 4284104988 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046
4284104988 4285157672 4285157672 4285157672 4288250198 4278978304 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4281015046 4283053075 4283053075
4286144565 4286144565 4281540872 0 0 0 0

One thing I couldn't help but notice was that the dual fighter's
non-zero pixels are all much higher than the player's pixel values. In
fact, I initially accidentally used %d instead of %u, and couldn't help
that this caused the dual fighter's pixels to all be printed as negative
numbers. But the player's pixel values still aren't zero.

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org







I'm getting blank surfaces... any idea why?
Julian Marchant
Guest

Quote:
Oh, it's possible that this is the classic SDL_BlitSurface() blend semantic
that trips up people from time to time. In SDL1.2, SDL_BlitSurface() does
color blending, but then uses the *destination* alpha value for the
resulting alpha. This means that when you blend a surface into your new,
transparent black surface, you end up with a fully transparent result
(though the colors are still there). In SDL 2, I'm not sure if this
semantic was preserved, but the alpha value might still not be what you
expect when you want to actually copy the image.

I'm still not totally sure why there's a discrepancy between different ship
images, though...

To see if this is the problem, use this kind of thing:
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w,
shipShape[i - SHIP_HIT_INDEX]->h);
SDL_SetSurfaceBlendMode(shipShape[i], SDL_BLENDMODE_NONE);
blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
SDL_SetSurfaceBlendMode(shipShape[i], SDL_BLENDMODE_BLEND);

Adding those lines setting the blend mode doesn't seem to make any
difference. However! shipShape[i] is the dest, not the source, and the
documentation suggests it's the source surface's blend mode that
matters, so I tried setting shipShape[i - SHIP_HIT_INDEX]'s blend mode
to SDL_BLENDMODE_NONE, and that completely obliterated the problem! So
it seems you were right.

So then, should I just leave it at temporarily setting the blend mode of
the ship images to none (since the code is supposed to be copying the
image anyway), or should I do something else?

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Jonny D


Joined: 12 Sep 2009
Posts: 932
Ah yep, that's what I should have put.  This is the right way to do it.  Turning off blending temporarily is how you directly copy the pixels from one surface to another via blit.  You'll want blending re-enabled afterward for normal rendering.

Jonny D


On Wednesday, April 29, 2015, Julian Marchant wrote:
Quote:
> Oh, it's possible that this is the classic SDL_BlitSurface() blend semantic
Quote:
that trips up people from time to time.  In SDL1.2, SDL_BlitSurface() does
color blending, but then uses the *destination* alpha value for the
resulting alpha.  This means that when you blend a surface into your new,
transparent black surface, you end up with a fully transparent result
(though the colors are still there).  In SDL 2, I'm not sure if this
semantic was preserved, but the alpha value might still not be what you
expect when you want to actually copy the image.

I'm still not totally sure why there's a discrepancy between different ship
images, though...

To see if this is the problem, use this kind of thing:
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w,
                         shipShape[i - SHIP_HIT_INDEX]->h);
SDL_SetSurfaceBlendMode(shipShape[i], SDL_BLENDMODE_NONE);
blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
SDL_SetSurfaceBlendMode(shipShape[i], SDL_BLENDMODE_BLEND);

Adding those lines setting the blend mode doesn't seem to make any
difference. However! shipShape[i] is the dest, not the source, and the
documentation suggests it's the source surface's blend mode that
matters, so I tried setting shipShape[i - SHIP_HIT_INDEX]'s blend mode
to SDL_BLENDMODE_NONE, and that completely obliterated the problem! So
it seems you were right.

So then, should I just leave it at temporarily setting the blend mode of
the ship images to none (since the code is supposed to be copying the
image anyway), or should I do something else?

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list
[url=javascript:;][/url]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
I'm getting blank surfaces... any idea why?
Julian Marchant
Guest

On 04/29/2015 07:00 PM, Jonathan Dearborn wrote:
Quote:
Ah yep, that's what I should have put. This is the right way to do it.
Turning off blending temporarily is how you directly copy the pixels from
one surface to another via blit. You'll want blending re-enabled afterward
for normal rendering.

Alright, thanks for the help. Smile

--
Julian Marchant
https://onpon4.github.io

Protect your privacy with GnuPG:
https://emailselfdefense.fsf.org
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org