-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Here it is (please note, it is included in c++ classes but i have cut&pasted
it here)
-
setvideomode:
surface = SDL_SetVideoMode( x_res, y_res, 32, SDL_SWSURFACE ); // nothing
changes if i use SDL_HWSURFACE. -
next to this, i have a “SpriteData” class which does the following:
sprite[x] = SDL_CreateRGBSurface( SDL_SWSURFACE, width, height,
SDL_GetVideoSurface()->format->Rmask,
SDL_GetVideoSurface()->format->Gmask,
SDL_GetVideoSurface()->format->Bmask,
SDL_GetVideoSurface()->format->Amask );SDL_SetColorKey( sprite[x], SDL_SCRCOLORKEY, SDL_MapRGB(sprite[x]->format,
0,0,0) );(i also tried to call SDL_DisplayFormat, but no luck)
-
I copy pixel data on the surface:
for ( y = 0; y < height; y++ )
{
tmp = &sprite[x]->pixels[ ywidth ];
memcpy( tmp, row_bytes[y], width4);
}
(please note: the data is loaded from a png using libpng)
-
then i create 4 intermediate surface:
buffer[y] = SDL_CreateRGBSurface(SDL_SWSURFACE, x_res/4, y_res/4,
SDL_GetVideoSurface()->format->Rmask,
SDL_GetVideoSurface()->format->Gmask,
SDL_GetVideoSurface()->format->Bmask,
SDL_GetVideoSurface()->format->Amask );(i dont set any colorkey here)
-
next, during gameplay, i copy the sprites on the intermediate surfaces,
there are also all the calculations needed to copy a surface into adjacent
intermediate surfaces if the sprite overlap two or more of them, but i omit
it here:rectd.x = x_pos;
rectd.y = y_pos;
rects.x = start_x;
rects.y = start_y;
rects.w = end_x-start_x;
rects.h = end_y-start_y;
SDL_BlitSurface( buffer[y], &rectd, sprite->GetSurface(x), &rects);
(here the color keyng is supposed to work if i am not wrong!) -
last, after all the sprites update is done, i update the video surface:
SDL_BlitSurface( surface, &rectd,buffer[y], &rects);
END) i had not transparencing. I have also tested the following:
a) the color (0,0,0) is present in the sprite(s) and it is in the correct
position in the image (checked with gimp)
b) after loading the sprites, the row_bytes contains exactly the same values
as found in gimp (es: 0,0,0 for the first top left pixel)
Whats strange is the pixel format, it is 32bit but the masks are:
r: 0x00ff0000
g: 0x0000ff00
b: 0x000000ff
a: 0x00000000
seems no alpha avalaible. Why?
thank you…
!
Willy Gardiol - @Willy_Gardiol
goemon.polito.it/~gardiol
Use linux for your freedom.
"Ho visto quest’anno a Kabul bambini
dilaniati dalle mine: grumi di garza
e sangue su brande sudice in lazzaretti.
Bambini i cui occhi e i cui orecchi non
hanno mai visto un disegno, ascoltato
una musica."
Vauro, Appunti di guerra (2002)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+VekWQ9qolN/zUk4RAmUZAKCuhRwKGz5kARI/HpxbTkKZUGtiCwCePEH4
7LlEj62lnobMhnpHaodK13U=
=mMQU
-----END PGP SIGNATURE-----