SDL blits

Hi,

I was working today with blits to copy portions from one texture to 

another. I use 32bpp textures, WITH alpha channel, however, when I blit
from one surface to another, the alpha channel is not copied. Is that
supposed to happen? If I explicitly set the alpha channel in the target
surface to an arbitrary value (like 255) everything becomes visible, so
the blit IS copying points, but not the alpha channel.

I am working with SDL 1.2.7 under Win32.


Best regards,

Paulo V W Radtke - Chien Loco Jogos de Garagem?

http://blog.chienloco.com
http://www.chienloco.com

Paulo V W Radtke wrote:

the blit IS copying points, but not the alpha channel.

read the docs for SDL_SetAlpha

like from the manpage:
Note that RGBA->RGBA blits (with SDL_SRCALPHA set)
keep the alpha of the destination surface. This
means that you cannot compose two arbitrary RGBA
surfaces this way and get the result you would
expect from “overlaying” them; the destination
alpha will work as a mask.

if you want alpha to be copied from the source surface, disable
alpha on the source, then blit. you can then reenable alpha if
you want to, on that surface.

-LIM-

Hi,

Paulo V W Radtke schrieb:

I was working today with blits to copy portions from one texture to 

another. I use 32bpp textures, WITH alpha channel, however, when I blit
from one surface to another, the alpha channel is not copied. Is that
supposed to happen? If I explicitly set the alpha channel in the target
surface to an arbitrary value (like 255) everything becomes visible, so
the blit IS copying points, but not the alpha channel.

If you’re working with textures anyway, you might use glTexSubImage2D s
see http://www.fh-wedel.de/~ko/OpenGLDoc/gl/texsubimage2d.html.

Another possibility is to write your own alpha blitter function, or use
an existing one. I know I’ve used one from the pygame source code before.

-Sebastian

Another possibility is to write your own alpha blitter function, or use
an existing one. I know I’ve used one from the pygame source code before.

Actually I have already done my blitter functions in OpenGL, the 

problem was that I had to process ONE texture before sending it to
OpenGL, which I was using SDL blits between SDL surfaces in the system
memory.

However, I may change the way I select the rectangles inside the 

texture, this function you referred is just more intuitive than a bunch
of relative point calculations inside the texture :).

Best regards,

Paulo V W Radtke - Chien Loco Jogos de Garagem?

http://blog.chienloco.com
http://www.chienloco.com