Hardware per pixel alpha blitting

Hello, can someone show me code for loading PNG with alpha in HW surface and
blitting it using hwaccel? I am using SDL_image library (IMG_Load) to load
bmp, and although I open display in HW doublebuf mode, surfaces are never
loaded in video mem. Also on my geforce 6600 I get these caps:

vi->hw_available: 1
vi->wm_available: 1
vi->blit_hw: 1
vi->blit_hw_CC: 1
vi->blit_hw_A: 0
vi->blit_sw: 1
vi->blit_sw_CC: 1
vi->blit_sw_A: 0
vi->blit_fill: 1
vi->video_mem: 124284
vi->vfmt->BitsPerPixel: 16
vi->vfmt->BytesPerPixel: 2
vi->vfmt->colorkey: 0
vi->vfmt->alpha: 255
vi->vfmt->Rmask, Gmask, Bmask, Amask: 63488, 2016, 31, 0
vi->vfmt->Rshift, Gshift, Bshift, Ashift: 11, 5, 0, 0
vi->vfmt->Rmask, Rloss, Gloss, Bloss, Aloss: 3, 2, 3, 8

I also tried SDL_ConvertSurface(img, img->format, SDL_HWSURFACE|SDL_HWACCEL);,
with no success.

Why is blit_hw_A 0, and blit_sw_A 0, on this card? What is the simplest way to
load png alpha (per pixel) image into video surface (and/or system mem) and
blit it using hardware acceleration? Is it possible at all? If not whats the
fastest way to blit alpha PNG?

Thank you in advance.

Amir Cicak wrote:

Why is blit_hw_A 0, and blit_sw_A 0, on this card? What is the simplest way to
load png alpha (per pixel) image into video surface (and/or system mem) and
blit it using hardware acceleration? Is it possible at all? If not whats the
fastest way to blit alpha PNG?

Are you using SDL under Windows? SDL’s DirectDraw driver, which is used
by default under Windows, cannot accelerate alpha blends as DirectDraw
itself doesn’t support them. glSDL, on the other hand, does support
accelerated alpha blending (under Windows, among other platforms.)

To load a png file (using SDL_image) onto a surface in video memory, use
the following code:

// Load an image from a file and into a surface in system memory.
SDL_Surface imageFromDisk = IMG_Load(“MyImage.png”);
if (imageFromDisk == NULL) { /
error */ }

// Create a surface in video memory and copy imageFromDisk’s contents to it.
SDL_Surface imageInVideoMem = SDL_DisplayFormatAlpha(imageFromDisk);
SDL_FreeSurface(imageFromDisk); // Free up some memory by deallocating
imageFromDisk.
if (imageInVideoMem == NULL) { /
error */ }

// Provided that the screen was created in hardware, and that your video
card, its driver, and the
// SDL backend being used support accelerated alpha blends, using
SDL_BlitSurface to overlay
// imageInVideoMem onto the screen should be accelerated…

// Blend imageInVideoMem onto the screen.
SDL_Surface *screen = SDL_GetVideoSurface();
SDL_BlitSurface(imageInVideoMem, NULL, screen, NULL);–
David Ludwig
davidl at funkitron.com

David Ludwig wrote:

Amir Cicak wrote:

Why is blit_hw_A 0, and blit_sw_A 0, on this card? What is the
simplest way to load png alpha (per pixel) image into video surface
(and/or system mem) and blit it using hardware acceleration? Is it
possible at all? If not whats the fastest way to blit alpha PNG?

Are you using SDL under Windows? SDL’s DirectDraw driver, which is used
by default under Windows, cannot accelerate alpha blends as DirectDraw
itself doesn’t support them.

Actually, no video backend accelerates alpha blits right now.

glSDL, on the other hand, does support
accelerated alpha blending (under Windows, among other platforms.)

Under windows, linux, OS X and possibly every platform with accelerated
OpenGL.

Stephane