How to make a region mask with Bitmap 2D game

Hi,

I want to define a region (for mouse detection ) and a mask for drawing a simple 2D sprite ?
i define a BMP file(24 bit) with the sprite or button,and a second BMP file(24 bit) with the mask (black and white).
i want to draw the sprite only if the pixel in the mask is black.
i want to define a fonction how draw the sprite :
you load the sprite BMP image in a screen buffer
you load the mask sprite BMP image in a second screen buffer.
the fonction draw the sprite

a second function define the Region detection of the sprite ,with the mask(black/white)BMP file , and scale the region and the front screen buffer.

the avantage:
if you want to change the drawing of the sprite and is corresponding black/white mask, for example ,i draw a rectangular button fisrt, and at the end, i want to do an ovale button,i just open photoshop, i redraw my ovale button,in a BMP file (same name) , i redraw the black and white mask in a BMP file (same name) ,and the graphisme of my game haved changed !
the detection of the sprite region and the draw of the sprite haved changed automaticaly !

it 's possible with opengl ?
i obliged to define polygone for sprite or button in a simply 2D game ?
i haved find documentation on standard function,but nosample code or tutorials demonstration of 2D exploitation !!!
nothing on 2D sprite !
it’s more simple to do a complex 3D object than to do a simple 2D sprite !!
i haved choice opengl since a thinking its better for the portability, and when you devellope on PC ,its the only solution to draw in full srcreen ,did you try to devellope MFC program ? (it’s to hard to devellope on PC ,the code are to ?/§!!/à@)
a gaz station !

i dont want to use DirectX

i haved devellope a 2D game on Macintosh, i have find documentation sample etcc…
my game working good ! (powerPC MACOS 9)

and i use the technique of BMP masking for the sprite and region !
i can redraw all the sprite of my game and the mask !
the detection of the region change automaticaly

i read documetation on STENCIL BUFFER ,it may be the solution ? how it work ?
i dont find any sample on 2D, simple image and mask !
i dont want to define polygons for my 2D sprite its to hard (and if my sprite is complex ,i have obligate to define many polygons for only a simpple 2D sprite!)

so help please !

i am beginer on opengl ,but i know how to load bitmap(24 bit),draw the bitmap on a fullscreen opengl, detect mouse and kayboard events .
i dont find sample code on how to exploit 2D with opengl !

willy

[This message has been edited by willy (edited 02-13-2003).]

Making sprites with openGL is easy.

First you draw your sprites images with a paint program like paint shop pro.

Then you load them as texture maps, and put each on it own quad.

Once textures are loaded onto quads, you just draw them in the order needed.

One large quad could have a background image, smaller quads would have moving objects.

also let you create masks for shadows and other effects by using texture maped object.

nehe.gamedev.net had a tutor on simple game with sprites useing the method. I think it is tutor 32.

thanks a lot

i haved map the texture to the QUAD it work fine .
my problem was the image size was not a multiple of power of 2 !
i define ma image size 256*256 and the mapping work .
but my image is a BMP , i have my sprite in the center of the image ,and white color around the sprite ,how can i mask the white color of the sprite ?
and if i want my sprite have a white color ?
the white color of the sprite doesnt appears ?

i try to play with function glDepthFunc,glAlphaFunc but no result :
i see the entire image (white color include)or nothing (black)

i think the solution is in Alpha test but i dont know how it work realy ?

some can help me ?

You image size can easy be adjusted by using any good paint program like paint shop pro, so that it is a power of 2.

Did you look at the tutor on nehe.gamedev.net?
It will show you how to make a alpha mask to do everything that you want with a sprite.

Note if you use a standard BMP, then you must create a second BMP to define the Alpha mask area.

Other wise use TGA file format to which supports alpha mask and only need on file for both. And also any good paint program will let you convert a BMP to TGA and even create a alpha mask.

The alpha channel mask, defines what areas which are to be transparent. Which will not be dependent on color.

Originally posted by willy:
[b]thanks a lot

i haved map the texture to the QUAD it work fine .
my problem was the image size was not a multiple of power of 2 !
i define ma image size 256*256 and the mapping work .
but my image is a BMP , i have my sprite in the center of the image ,and white color around the sprite ,how can i mask the white color of the sprite ?
and if i want my sprite have a white color ?
the white color of the sprite doesnt appears ?

i try to play with function glDepthFunc,glAlphaFunc but no result :
i see the entire image (white color include)or nothing (black)

i think the solution is in Alpha test but i dont know how it work realy ?

some can help me ?

[/b]

Ok ,i have transform my image in to TGA and it work !
now i have to change all my sprites in TGA format, it is better for sprite
and gestion of mask with alpha test
and so 1 file and more free memory

thank for all

now i will testing sprite animation on a background